shithub: aacdec

Download patch

ref: e879a90e5469b503113ae27a84999c403f4f17d8
parent: 90b0884012b832806f2ba2c2c6f6eef91f398edb
author: menno <menno>
date: Sun May 7 14:09:41 EDT 2006

FAAD2 update

--- a/README
+++ b/README
@@ -14,7 +14,7 @@
 
 ******************************************************************************
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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
@@ -33,13 +33,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 ******************************************************************************
 
 
--- a/common/mp4ff/Makefile.am
+++ b/common/mp4ff/Makefile.am
@@ -1,8 +1,8 @@
-noinst_LIBRARIES = libmp4ff.a
+noinst_LTLIBRARIES = libmp4ff.la
 
-libmp4ff_a_CFLAGS = -DUSE_TAGGING=1
+libmp4ff_la_CFLAGS = -DUSE_TAGGING=1
 
-libmp4ff_a_SOURCES = mp4ff.c mp4atom.c mp4meta.c mp4sample.c mp4util.c \
+libmp4ff_la_SOURCES = mp4ff.c mp4atom.c mp4meta.c mp4sample.c mp4util.c \
    mp4tagupdate.c mp4ff.h mp4ffint.h mp4ff_int_types.h \
    drms.h drms.c drmstables.h
 
--- a/common/mp4ff/mp4atom.c
+++ b/common/mp4ff/mp4atom.c
@@ -1,28 +1,33 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
-**
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**  
 ** 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
+** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
+** in, for example, the about-box or help/startup screen.
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: mp4atom.c,v 1.22 2005/02/01 13:15:55 menno Exp $
+** $Id: mp4atom.c,v 1.23 2006/05/07 18:09:00 menno Exp $
 **/
 
 #include <stdlib.h>
--- a/common/mp4ff/mp4ff.c
+++ b/common/mp4ff/mp4ff.c
@@ -1,28 +1,33 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
-**
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**  
 ** 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
+** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
+** in, for example, the about-box or help/startup screen.
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: mp4ff.c,v 1.17 2005/02/01 13:15:55 menno Exp $
+** $Id: mp4ff.c,v 1.18 2006/05/07 18:09:00 menno Exp $
 **/
 
 #include <stdlib.h>
--- a/common/mp4ff/mp4ff.h
+++ b/common/mp4ff/mp4ff.h
@@ -1,28 +1,33 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
-**
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**  
 ** 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
+** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
+** in, for example, the about-box or help/startup screen.
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: mp4ff.h,v 1.22 2005/02/01 13:15:55 menno Exp $
+** $Id: mp4ff.h,v 1.23 2006/05/07 18:09:00 menno Exp $
 **/
 
 #ifndef MP4FF_H
--- a/common/mp4ff/mp4ffint.h
+++ b/common/mp4ff/mp4ffint.h
@@ -1,28 +1,33 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
-**
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**  
 ** 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
+** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
+** in, for example, the about-box or help/startup screen.
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: mp4ffint.h,v 1.19 2005/02/01 13:15:55 menno Exp $
+** $Id: mp4ffint.h,v 1.20 2006/05/07 18:09:00 menno Exp $
 **/
 
 #ifndef MP4FF_INTERNAL_H
@@ -347,7 +352,7 @@
 mp4ff_t *mp4ff_open_edit(mp4ff_callback_t *f);
 #endif
 void mp4ff_close(mp4ff_t *ff);
-void mp4ff_track_add(mp4ff_t *f);
+//void mp4ff_track_add(mp4ff_t *f);
 int32_t parse_sub_atoms(mp4ff_t *f, const uint64_t total_size,int meta_only);
 int32_t parse_atoms(mp4ff_t *f,int meta_only);
 
--- a/common/mp4ff/mp4meta.c
+++ b/common/mp4ff/mp4meta.c
@@ -1,28 +1,33 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
-**
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**  
 ** 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
+** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
+** in, for example, the about-box or help/startup screen.
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: mp4meta.c,v 1.16 2005/02/01 13:15:55 menno Exp $
+** $Id: mp4meta.c,v 1.17 2006/05/07 18:09:00 menno Exp $
 **/
 
 #ifdef USE_TAGGING
--- a/common/mp4ff/mp4sample.c
+++ b/common/mp4ff/mp4sample.c
@@ -1,28 +1,33 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
-**
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**  
 ** 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
+** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
+** in, for example, the about-box or help/startup screen.
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: mp4sample.c,v 1.17 2005/02/01 13:15:55 menno Exp $
+** $Id: mp4sample.c,v 1.18 2006/05/07 18:09:00 menno Exp $
 **/
 
 #include <stdlib.h>
--- a/common/mp4ff/mp4util.c
+++ b/common/mp4ff/mp4util.c
@@ -1,28 +1,33 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
-**
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**  
 ** 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
+** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
+** in, for example, the about-box or help/startup screen.
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: mp4util.c,v 1.17 2005/02/01 13:15:55 menno Exp $
+** $Id: mp4util.c,v 1.18 2006/05/07 18:09:00 menno Exp $
 **/
 
 #include "mp4ffint.h"
--- a/frontend/Makefile.am
+++ b/frontend/Makefile.am
@@ -4,7 +4,7 @@
    -I$(top_srcdir)/common/mp4ff
 
 faad_LDADD = $(top_builddir)/libfaad/libfaad.la \
-	$(top_builddir)/common/mp4ff/libmp4ff.a
+	$(top_builddir)/common/mp4ff/libmp4ff.la
 
 faad_SOURCES = main.c \
 	audio.c audio.h \
--- a/frontend/audio.c
+++ b/frontend/audio.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: audio.c,v 1.25 2005/02/01 13:15:56 menno Exp $
+** $Id: audio.c,v 1.26 2006/05/07 18:09:00 menno Exp $
 **/
 
 #ifdef _WIN32
--- a/frontend/audio.h
+++ b/frontend/audio.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: audio.h,v 1.16 2005/02/01 13:15:56 menno Exp $
+** $Id: audio.h,v 1.17 2006/05/07 18:09:00 menno Exp $
 **/
 
 #ifndef AUDIO_H_INCLUDED
--- a/frontend/faad.dsp
+++ b/frontend/faad.dsp
@@ -25,7 +25,7 @@
 # PROP AllowPerConfigDependencies 0
 # PROP Scc_ProjName ""
 # PROP Scc_LocalPath ""
-CPP=cl.exe
+CPP=xicl6.exe
 RSC=rc.exe
 
 !IF  "$(CFG)" == "faad - Win32 Release"
@@ -48,7 +48,7 @@
 BSC32=bscmake.exe
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
-LINK32=link.exe
+LINK32=xilink6.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
 # ADD LINK32 Advapi32.lib /nologo /subsystem:console /machine:I386
 # SUBTRACT LINK32 /profile
@@ -73,7 +73,7 @@
 BSC32=bscmake.exe
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
-LINK32=link.exe
+LINK32=xilink6.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
 # ADD LINK32 Advapi32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
 
@@ -112,10 +112,6 @@
 # End Source File
 # Begin Source File
 
-SOURCE=..\common\mp4v2\mp4.h
-# End Source File
-# Begin Source File
-
 SOURCE=..\common\mp4ff\mp4ff.h
 # End Source File
 # Begin Source File
@@ -124,19 +120,7 @@
 # End Source File
 # Begin Source File
 
-SOURCE=..\common\mp4v2\mpeg4ip.h
-# End Source File
-# Begin Source File
-
 SOURCE=..\include\neaacdec.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\common\mp4v2\systems.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\common\mp4v2\win32_ver.h
 # End Source File
 # End Group
 # End Target
--- a/frontend/main.c
+++ b/frontend/main.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: main.c,v 1.77 2005/02/01 13:15:56 menno Exp $
+** $Id: main.c,v 1.78 2006/05/07 18:09:00 menno Exp $
 **/
 
 #ifdef _WIN32
@@ -40,6 +40,7 @@
 
 #include <fcntl.h>
 #include <stdio.h>
+#include <stdarg.h>
 #include <stdlib.h>
 #include <getopt.h>
 
@@ -1057,7 +1058,8 @@
             { "info",       0, 0, 'i' },
             { "stdio",      0, 0, 'w' },
             { "stdio",      0, 0, 'g' },
-            { "help",       0, 0, 'h' }
+            { "help",       0, 0, 'h' },
+            { 0, 0, 0, 0 }
         };
 
         c = getopt_long(argc, argv, "o:a:s:f:b:l:wgdhitq",
--- a/include/faad.h
+++ b/include/faad.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: faad.h,v 1.48 2005/02/01 13:15:56 menno Exp $
+** $Id: faad.h,v 1.49 2006/05/07 18:09:00 menno Exp $
 **/
 
 /* warn people for update */
--- a/include/neaacdec.h
+++ b/include/neaacdec.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: neaacdec.h,v 1.6 2005/02/01 13:15:56 menno Exp $
+** $Id: neaacdec.h,v 1.7 2006/05/07 18:09:00 menno Exp $
 **/
 
 #ifndef __NEAACDEC_H__
--- a/libfaad/analysis.h
+++ b/libfaad/analysis.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: analysis.h,v 1.15 2005/02/01 13:15:56 menno Exp $
+** $Id: analysis.h,v 1.16 2006/05/07 18:09:00 menno Exp $
 **/
 
 #ifndef __ANALYSIS_H__
--- a/libfaad/bits.c
+++ b/libfaad/bits.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: bits.c,v 1.40 2005/02/01 13:15:56 menno Exp $
+** $Id: bits.c,v 1.41 2006/05/07 18:09:00 menno Exp $
 **/
 
 #include "common.h"
@@ -34,7 +34,6 @@
 #include "structs.h"
 
 #include <stdlib.h>
-#include <string.h>
 #include "bits.h"
 
 /* initialize buffer, call once before first getbits or showbits */
@@ -45,25 +44,38 @@
     if (ld == NULL)
         return;
 
-    memset(ld, 0, sizeof(bitfile));
+    // useless
+    //memset(ld, 0, sizeof(bitfile));
 
     if (buffer_size == 0 || _buffer == NULL)
     {
         ld->error = 1;
-        ld->no_more_reading = 1;
         return;
     }
 
-    ld->buffer = faad_malloc((buffer_size+12)*sizeof(uint8_t));
-    memset(ld->buffer, 0, (buffer_size+12)*sizeof(uint8_t));
-    memcpy(ld->buffer, _buffer, buffer_size*sizeof(uint8_t));
+    ld->buffer = _buffer;
 
     ld->buffer_size = buffer_size;
+    ld->bytes_left  = buffer_size;
 
-    tmp = getdword((uint32_t*)ld->buffer);
+    if (ld->bytes_left >= 4)
+    {
+        tmp = getdword((uint32_t*)ld->buffer);
+        ld->bytes_left -= 4;
+    } else {
+        tmp = getdword_n((uint32_t*)ld->buffer, ld->bytes_left);
+        ld->bytes_left = 0;
+    }
     ld->bufa = tmp;
 
-    tmp = getdword((uint32_t*)ld->buffer + 1);
+    if (ld->bytes_left >= 4)
+    {
+        tmp = getdword((uint32_t*)ld->buffer + 1);
+        ld->bytes_left -= 4;
+    } else {
+        tmp = getdword_n((uint32_t*)ld->buffer + 1, ld->bytes_left);
+        ld->bytes_left = 0;
+    }
     ld->bufb = tmp;
 
     ld->start = (uint32_t*)ld->buffer;
@@ -71,21 +83,12 @@
 
     ld->bits_left = 32;
 
-    ld->bytes_used = 0;
-    ld->no_more_reading = 0;
     ld->error = 0;
 }
 
 void faad_endbits(bitfile *ld)
 {
-    if (ld)
-    {
-        if (ld->buffer)
-        {
-            faad_free(ld->buffer);
-            ld->buffer = NULL;
-        }
-    }
+    // void
 }
 
 uint32_t faad_get_processed_bits(bitfile *ld)
@@ -95,12 +98,12 @@
 
 uint8_t faad_byte_align(bitfile *ld)
 {
-    uint8_t remainder = (uint8_t)((32 - ld->bits_left) % 8);
+    int remainder = (32 - ld->bits_left) & 0x7;
 
     if (remainder)
     {
         faad_flushbits(ld, 8 - remainder);
-        return (8 - remainder);
+        return (uint8_t)(8 - remainder);
     }
     return 0;
 }
@@ -110,20 +113,22 @@
     uint32_t tmp;
 
     ld->bufa = ld->bufb;
-    if (ld->no_more_reading == 0)
+    if (ld->bytes_left >= 4)
     {
         tmp = getdword(ld->tail);
-        ld->tail++;
+        ld->bytes_left -= 4;
     } else {
-        tmp = 0;
+        tmp = getdword_n(ld->tail, ld->bytes_left);
+        ld->bytes_left = 0;
     }
     ld->bufb = tmp;
+    ld->tail++;
     ld->bits_left += (32 - bits);
-    ld->bytes_used += 4;
-    if (ld->bytes_used == ld->buffer_size)
-        ld->no_more_reading = 1;
-    if (ld->bytes_used > ld->buffer_size)
-        ld->error = 1;
+    //ld->bytes_left -= 4;
+//    if (ld->bytes_left == 0)
+//        ld->no_more_reading = 1;
+//    if (ld->bytes_left < 0)
+//        ld->error = 1;
 }
 
 /* rewind to beginning */
@@ -131,30 +136,79 @@
 {
     uint32_t tmp;
 
-    tmp = ld->start[0];
-#ifndef ARCH_IS_BIG_ENDIAN
-    BSWAP(tmp);
-#endif
+    ld->bytes_left = ld->buffer_size;
+
+    if (ld->bytes_left >= 4)
+    {
+        tmp = getdword((uint32_t*)ld->start[0]);
+        ld->bytes_left -= 4;
+    } else {
+        tmp = getdword_n((uint32_t*)ld->start[0], ld->bytes_left);
+        ld->bytes_left = 0;
+    }
     ld->bufa = tmp;
 
-    tmp = ld->start[1];
-#ifndef ARCH_IS_BIG_ENDIAN
-    BSWAP(tmp);
-#endif
+    if (ld->bytes_left >= 4)
+    {
+        tmp = getdword((uint32_t*)ld->start[1] + 1);
+        ld->bytes_left -= 4;
+    } else {
+        tmp = getdword_n((uint32_t*)ld->start[1] + 1, ld->bytes_left);
+        ld->bytes_left = 0;
+    }
     ld->bufb = tmp;
+
     ld->bits_left = 32;
     ld->tail = &ld->start[2];
-    ld->bytes_used = 0;
-    ld->no_more_reading = 0;
 }
 
+/* reset to a certain point */
+void faad_resetbits(bitfile *ld, int bits)
+{
+    uint32_t tmp;
+    int words = bits >> 5;
+    int remainder = bits & 0x1F;
+
+    ld->bytes_left = ld->buffer_size - words*4;
+
+    if (ld->bytes_left >= 4)
+    {
+        tmp = getdword(&ld->start[words]);
+        ld->bytes_left -= 4;
+    } else {
+        tmp = getdword_n(&ld->start[words], ld->bytes_left);
+        ld->bytes_left = 0;
+    }
+    ld->bufa = tmp;
+
+    if (ld->bytes_left >= 4)
+    {
+        tmp = getdword(&ld->start[words+1]);
+        ld->bytes_left -= 4;
+    } else {
+        tmp = getdword_n(&ld->start[words+1], ld->bytes_left);
+        ld->bytes_left = 0;
+    }
+    ld->bufb = tmp;
+
+    ld->bits_left = 32 - remainder;
+    ld->tail = &ld->start[words+2];
+
+    /* recheck for reading too many bytes */
+    ld->error = 0;
+//    if (ld->bytes_left == 0)
+//        ld->no_more_reading = 1;
+//    if (ld->bytes_left < 0)
+//        ld->error = 1;
+}
+
 uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits
                        DEBUGDEC)
 {
-    uint16_t i;
-    uint8_t temp;
-    uint16_t bytes = (uint16_t)bits / 8;
-    uint8_t remainder = (uint8_t)bits % 8;
+    int i;
+    unsigned int temp;
+    int bytes = bits >> 3;
+    int remainder = bits & 0x7;
 
     uint8_t *buffer = (uint8_t*)faad_malloc((bytes+1)*sizeof(uint8_t));
 
@@ -165,9 +219,9 @@
 
     if (remainder)
     {
-        temp = (uint8_t)faad_getbits(ld, remainder DEBUGVAR(print,var,dbg)) << (8-remainder);
+        temp = faad_getbits(ld, remainder DEBUGVAR(print,var,dbg)) << (8-remainder);
 
-        buffer[bytes] = temp;
+        buffer[bytes] = (uint8_t)temp;
     }
 
     return buffer;
@@ -212,7 +266,8 @@
     if (ld->bits_left == 0)
         ld->bits_left = 32;
 
-    ld->bytes_used = 0;
-    ld->no_more_reading = 0;
+    ld->bytes_left = ld->buffer_size;
     ld->error = 0;
 }
+
+/* EOF */
--- a/libfaad/bits.h
+++ b/libfaad/bits.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: bits.h,v 1.41 2005/02/01 13:15:56 menno Exp $
+** $Id: bits.h,v 1.42 2006/05/07 18:09:00 menno Exp $
 **/
 
 #ifndef __BITS_H__
@@ -42,8 +42,10 @@
 #include <stdio.h>
 #endif
 
-#define BYTE_NUMBIT 8
-#define bit2byte(a) ((a+7)/BYTE_NUMBIT)
+#define BYTE_NUMBIT     8
+#define BYTE_NUMBIT_LD  3
+//#define bit2byte(a) ((a+7)/BYTE_NUMBIT)
+#define bit2byte(a) ((a+7)>>BYTE_NUMBIT_LD)
 
 typedef struct _bitfile
 {
@@ -52,25 +54,16 @@
     uint32_t bufb;
     uint32_t bits_left;
     uint32_t buffer_size; /* size of the buffer in bytes */
-    uint32_t bytes_used;
-    uint8_t no_more_reading;
+    uint32_t bytes_left;
     uint8_t error;
     uint32_t *tail;
     uint32_t *start;
-    void *buffer;
+    const void *buffer;
 } bitfile;
 
 
-#if defined (_WIN32) && !defined(_WIN32_WCE) && !defined(__MINGW32__)
-#define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax
-#elif defined(LINUX) || defined(DJGPP) || defined(__MINGW32__)
-#define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) )
-#else
-#define BSWAP(a) \
-    ((a) = ( ((a)&0xff)<<24) | (((a)&0xff00)<<8) | (((a)>>8)&0xff00) | (((a)>>24)&0xff))
-#endif
-
-static uint32_t bitmask[] = {
+#if 0
+static uint32_t const bitmask[] = {
     0x0, 0x1, 0x3, 0x7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, 0x1FF,
     0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF,
     0x1FFFF, 0x3FFFF, 0x7FFFF, 0xFFFFF, 0x1FFFFF, 0x3FFFFF,
@@ -79,6 +72,7 @@
     /* added bitmask 32, correct?!?!?! */
     , 0xFFFFFFFF
 };
+#endif
 
 void faad_initbits(bitfile *ld, const void *buffer, const uint32_t buffer_size);
 void faad_endbits(bitfile *ld);
@@ -88,6 +82,7 @@
 uint32_t faad_get_processed_bits(bitfile *ld);
 void faad_flushbits_ex(bitfile *ld, uint32_t bits);
 void faad_rewindbits(bitfile *ld);
+void faad_resetbits(bitfile *ld, int bits);
 uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits
                        DEBUGDEC);
 #ifdef DRM
@@ -98,7 +93,6 @@
 /* circumvent memory alignment errors on ARM */
 static INLINE uint32_t getdword(void *mem)
 {
-#ifdef ARM
     uint32_t tmp;
 #ifndef ARCH_IS_BIG_ENDIAN
     ((uint8_t*)&tmp)[0] = ((uint8_t*)mem)[3];
@@ -113,14 +107,39 @@
 #endif
 
     return tmp;
-#else
-    uint32_t tmp;
-    tmp = *(uint32_t*)mem;
+}
+
+/* reads only n bytes from the stream instead of the standard 4 */
+static /*INLINE*/ uint32_t getdword_n(void *mem, int n)
+{
+    uint32_t tmp = 0;
 #ifndef ARCH_IS_BIG_ENDIAN
-    BSWAP(tmp);
+    switch (n)
+    {
+    case 3:
+        ((uint8_t*)&tmp)[1] = ((uint8_t*)mem)[2];
+    case 2:
+        ((uint8_t*)&tmp)[2] = ((uint8_t*)mem)[1];
+    case 1:
+        ((uint8_t*)&tmp)[3] = ((uint8_t*)mem)[0];
+    default:
+        break;
+    }
+#else
+    switch (n)
+    {
+    case 3:
+        ((uint8_t*)&tmp)[2] = ((uint8_t*)mem)[2];
+    case 2:
+        ((uint8_t*)&tmp)[1] = ((uint8_t*)mem)[1];
+    case 1:
+        ((uint8_t*)&tmp)[0] = ((uint8_t*)mem)[0];
+    default:
+        break;
+    }
 #endif
+
     return tmp;
-#endif
 }
 
 static INLINE uint32_t faad_showbits(bitfile *ld, uint32_t bits)
@@ -127,11 +146,13 @@
 {
     if (bits <= ld->bits_left)
     {
-        return (ld->bufa >> (ld->bits_left - bits)) & bitmask[bits];
+        //return (ld->bufa >> (ld->bits_left - bits)) & bitmask[bits];
+        return (ld->bufa << (32 - ld->bits_left)) >> (32 - bits);
     }
 
     bits -= ld->bits_left;
-    return ((ld->bufa & bitmask[ld->bits_left]) << bits) | (ld->bufb >> (32 - bits));
+    //return ((ld->bufa & bitmask[ld->bits_left]) << bits) | (ld->bufb >> (32 - bits));
+    return ((ld->bufa & ((1<<ld->bits_left)-1)) << bits) | (ld->bufb >> (32 - bits));
 }
 
 static INLINE void faad_flushbits(bitfile *ld, uint32_t bits)
@@ -149,11 +170,11 @@
 }
 
 /* return next n bits (right adjusted) */
-static INLINE uint32_t faad_getbits(bitfile *ld, uint32_t n DEBUGDEC)
+static /*INLINE*/ uint32_t faad_getbits(bitfile *ld, uint32_t n DEBUGDEC)
 {
     uint32_t ret;
 
-    if (ld->no_more_reading || n == 0)
+    if (n == 0)
         return 0;
 
     ret = faad_showbits(ld, n);
@@ -235,22 +256,19 @@
         ld->start--;
         ld->bits_left += (32 - bits);
 
-        ld->bytes_used += 4;
-        if (ld->bytes_used == ld->buffer_size)
-            ld->no_more_reading = 1;
-        if (ld->bytes_used > ld->buffer_size)
+        ld->bytes_left -= 4;
+//        if (ld->bytes_left == 0)
+//            ld->no_more_reading = 1;
+        if (ld->bytes_left < 0)
             ld->error = 1;
     }
 }
 
-static INLINE uint32_t faad_getbits_rev(bitfile *ld, uint32_t n
+static /*INLINE*/ uint32_t faad_getbits_rev(bitfile *ld, uint32_t n
                                         DEBUGDEC)
 {
     uint32_t ret;
 
-    if (ld->no_more_reading)
-        return 0;
-
     if (n == 0)
         return 0;
 
@@ -266,10 +284,47 @@
 }
 
 #ifdef DRM
+/* CRC lookup table for G8 polynome in DRM standard */
+static const uint8_t crc_table_G8[256] = {
+    0x0, 0x1d, 0x3a, 0x27, 0x74, 0x69, 0x4e, 0x53,
+    0xe8, 0xf5, 0xd2, 0xcf, 0x9c, 0x81, 0xa6, 0xbb,
+    0xcd, 0xd0, 0xf7, 0xea, 0xb9, 0xa4, 0x83, 0x9e,
+    0x25, 0x38, 0x1f, 0x2, 0x51, 0x4c, 0x6b, 0x76,
+    0x87, 0x9a, 0xbd, 0xa0, 0xf3, 0xee, 0xc9, 0xd4,
+    0x6f, 0x72, 0x55, 0x48, 0x1b, 0x6, 0x21, 0x3c,
+    0x4a, 0x57, 0x70, 0x6d, 0x3e, 0x23, 0x4, 0x19,
+    0xa2, 0xbf, 0x98, 0x85, 0xd6, 0xcb, 0xec, 0xf1,
+    0x13, 0xe, 0x29, 0x34, 0x67, 0x7a, 0x5d, 0x40,
+    0xfb, 0xe6, 0xc1, 0xdc, 0x8f, 0x92, 0xb5, 0xa8,
+    0xde, 0xc3, 0xe4, 0xf9, 0xaa, 0xb7, 0x90, 0x8d,
+    0x36, 0x2b, 0xc, 0x11, 0x42, 0x5f, 0x78, 0x65,
+    0x94, 0x89, 0xae, 0xb3, 0xe0, 0xfd, 0xda, 0xc7,
+    0x7c, 0x61, 0x46, 0x5b, 0x8, 0x15, 0x32, 0x2f,
+    0x59, 0x44, 0x63, 0x7e, 0x2d, 0x30, 0x17, 0xa,
+    0xb1, 0xac, 0x8b, 0x96, 0xc5, 0xd8, 0xff, 0xe2,
+    0x26, 0x3b, 0x1c, 0x1, 0x52, 0x4f, 0x68, 0x75,
+    0xce, 0xd3, 0xf4, 0xe9, 0xba, 0xa7, 0x80, 0x9d,
+    0xeb, 0xf6, 0xd1, 0xcc, 0x9f, 0x82, 0xa5, 0xb8,
+    0x3, 0x1e, 0x39, 0x24, 0x77, 0x6a, 0x4d, 0x50,
+    0xa1, 0xbc, 0x9b, 0x86, 0xd5, 0xc8, 0xef, 0xf2,
+    0x49, 0x54, 0x73, 0x6e, 0x3d, 0x20, 0x7, 0x1a,
+    0x6c, 0x71, 0x56, 0x4b, 0x18, 0x5, 0x22, 0x3f,
+    0x84, 0x99, 0xbe, 0xa3, 0xf0, 0xed, 0xca, 0xd7,
+    0x35, 0x28, 0xf, 0x12, 0x41, 0x5c, 0x7b, 0x66,
+    0xdd, 0xc0, 0xe7, 0xfa, 0xa9, 0xb4, 0x93, 0x8e,
+    0xf8, 0xe5, 0xc2, 0xdf, 0x8c, 0x91, 0xb6, 0xab,
+    0x10, 0xd, 0x2a, 0x37, 0x64, 0x79, 0x5e, 0x43,
+    0xb2, 0xaf, 0x88, 0x95, 0xc6, 0xdb, 0xfc, 0xe1,
+    0x5a, 0x47, 0x60, 0x7d, 0x2e, 0x33, 0x14, 0x9,
+    0x7f, 0x62, 0x45, 0x58, 0xb, 0x16, 0x31, 0x2c,
+    0x97, 0x8a, 0xad, 0xb0, 0xe3, 0xfe, 0xd9, 0xc4,
+};
+
 static uint8_t faad_check_CRC(bitfile *ld, uint16_t len)
 {
-    uint8_t CRC;
-    uint16_t r=255;  /* Initialize to all ones */
+    int bytes, rem;
+    unsigned int CRC;
+    unsigned int r=255;  /* Initialize to all ones */
 
     /* CRC polynome used x^8 + x^4 + x^3 + x^2 +1 */
 #define GPOLY 0435
@@ -276,10 +331,17 @@
 
     faad_rewindbits(ld);
 
-    CRC = (uint8_t) ~faad_getbits(ld, 8
-        DEBUGVAR(1,999,"faad_check_CRC(): CRC"));          /* CRC is stored inverted */
+    CRC = (unsigned int) ~faad_getbits(ld, 8
+        DEBUGVAR(1,999,"faad_check_CRC(): CRC")) & 0xFF;          /* CRC is stored inverted */
 
-    for (; len>0; len--)
+    bytes = len >> 3;
+    rem = len & 0x7;
+
+    for (; bytes > 0; bytes--)
+    {
+        r = crc_table_G8[( r ^ faad_getbits(ld, 8 DEBUGVAR(1,998,"")) ) & 0xFF];
+    }
+    for (; rem > 0; rem--)
     {
         r = ( (r << 1) ^ (( ( faad_get1bit(ld
             DEBUGVAR(1,998,""))  & 1) ^ ((r >> 7) & 1)) * GPOLY )) & 0xFF;
--- a/libfaad/cfft.c
+++ b/libfaad/cfft.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: cfft.c,v 1.31 2005/02/01 13:28:51 menno Exp $
+** $Id: cfft.c,v 1.32 2006/05/07 18:09:00 menno Exp $
 **/
 
 /*
--- a/libfaad/cfft.h
+++ b/libfaad/cfft.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: cfft.h,v 1.21 2005/02/01 13:28:51 menno Exp $
+** $Id: cfft.h,v 1.22 2006/05/07 18:09:00 menno Exp $
 **/
 
 #ifndef __CFFT_H__
--- a/libfaad/cfft_tab.h
+++ b/libfaad/cfft_tab.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: cfft_tab.h,v 1.18 2005/02/01 13:15:56 menno Exp $
+** $Id: cfft_tab.h,v 1.19 2006/05/07 18:09:00 menno Exp $
 **/
 
 #ifndef __CFFT_TAB_H__
--- a/libfaad/codebook/hcb.h
+++ b/libfaad/codebook/hcb.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,10 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
+** in, for example, the about-box or help/startup screen.
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: hcb.h,v 1.6 2003/09/09 18:12:01 menno Exp $
+** $Id: hcb.h,v 1.7 2006/05/07 18:09:41 menno Exp $
 **/
 
 #ifndef __HCB_H__
--- a/libfaad/codebook/hcb_1.h
+++ b/libfaad/codebook/hcb_1.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,10 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
+** in, for example, the about-box or help/startup screen.
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: hcb_1.h,v 1.3 2003/09/09 18:12:01 menno Exp $
+** $Id: hcb_1.h,v 1.4 2006/05/07 18:09:41 menno Exp $
 **/
 
 /* 2-step huffman table HCB_1 */
--- a/libfaad/codebook/hcb_10.h
+++ b/libfaad/codebook/hcb_10.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,10 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
+** in, for example, the about-box or help/startup screen.
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: hcb_10.h,v 1.3 2003/09/09 18:12:01 menno Exp $
+** $Id: hcb_10.h,v 1.4 2006/05/07 18:09:41 menno Exp $
 **/
 
 /* 2-step huffman table HCB_10 */
--- a/libfaad/codebook/hcb_11.h
+++ b/libfaad/codebook/hcb_11.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,10 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
+** in, for example, the about-box or help/startup screen.
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: hcb_11.h,v 1.3 2003/09/09 18:12:01 menno Exp $
+** $Id: hcb_11.h,v 1.4 2006/05/07 18:09:41 menno Exp $
 **/
 
 /* 2-step huffman table HCB_11 */
--- a/libfaad/codebook/hcb_2.h
+++ b/libfaad/codebook/hcb_2.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,10 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
+** in, for example, the about-box or help/startup screen.
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: hcb_2.h,v 1.3 2003/09/09 18:12:01 menno Exp $
+** $Id: hcb_2.h,v 1.4 2006/05/07 18:09:41 menno Exp $
 **/
 
 /* 2-step huffman table HCB_2 */
--- a/libfaad/codebook/hcb_3.h
+++ b/libfaad/codebook/hcb_3.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,10 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
+** in, for example, the about-box or help/startup screen.
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: hcb_3.h,v 1.3 2003/09/09 18:12:01 menno Exp $
+** $Id: hcb_3.h,v 1.4 2006/05/07 18:09:41 menno Exp $
 **/
 
 /* Binary search huffman table HCB_3 */
--- a/libfaad/codebook/hcb_4.h
+++ b/libfaad/codebook/hcb_4.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,10 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
+** in, for example, the about-box or help/startup screen.
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: hcb_4.h,v 1.3 2003/09/09 18:12:01 menno Exp $
+** $Id: hcb_4.h,v 1.4 2006/05/07 18:09:41 menno Exp $
 **/
 
 /* 2-step huffman table HCB_4 */
--- a/libfaad/codebook/hcb_5.h
+++ b/libfaad/codebook/hcb_5.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,10 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
+** in, for example, the about-box or help/startup screen.
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: hcb_5.h,v 1.3 2003/09/09 18:12:01 menno Exp $
+** $Id: hcb_5.h,v 1.4 2006/05/07 18:09:41 menno Exp $
 **/
 
 /* Binary search huffman table HCB_5 */
--- a/libfaad/codebook/hcb_6.h
+++ b/libfaad/codebook/hcb_6.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,10 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
+** in, for example, the about-box or help/startup screen.
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: hcb_6.h,v 1.3 2003/09/09 18:12:01 menno Exp $
+** $Id: hcb_6.h,v 1.4 2006/05/07 18:09:41 menno Exp $
 **/
 
 /* 2-step huffman table HCB_6 */
--- a/libfaad/codebook/hcb_7.h
+++ b/libfaad/codebook/hcb_7.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,10 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
+** in, for example, the about-box or help/startup screen.
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: hcb_7.h,v 1.3 2003/09/09 18:12:01 menno Exp $
+** $Id: hcb_7.h,v 1.4 2006/05/07 18:09:41 menno Exp $
 **/
 
 /* Binary search huffman table HCB_7 */
--- a/libfaad/codebook/hcb_8.h
+++ b/libfaad/codebook/hcb_8.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,10 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
+** in, for example, the about-box or help/startup screen.
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: hcb_8.h,v 1.3 2003/09/09 18:12:01 menno Exp $
+** $Id: hcb_8.h,v 1.4 2006/05/07 18:09:41 menno Exp $
 **/
 
 /* 2-step huffman table HCB_8 */
--- a/libfaad/codebook/hcb_9.h
+++ b/libfaad/codebook/hcb_9.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,10 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
+** in, for example, the about-box or help/startup screen.
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: hcb_9.h,v 1.3 2003/09/09 18:12:01 menno Exp $
+** $Id: hcb_9.h,v 1.4 2006/05/07 18:09:41 menno Exp $
 **/
 
 /* Binary search huffman table HCB_9 */
--- a/libfaad/codebook/hcb_sf.h
+++ b/libfaad/codebook/hcb_sf.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,10 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
+** in, for example, the about-box or help/startup screen.
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: hcb_sf.h,v 1.5 2004/02/04 19:55:02 menno Exp $
+** $Id: hcb_sf.h,v 1.6 2006/05/07 18:09:41 menno Exp $
 **/
 
 /* Binary search huffman table HCB_SF */
--- a/libfaad/common.c
+++ b/libfaad/common.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: common.c,v 1.23 2005/02/01 13:23:34 menno Exp $
+** $Id: common.c,v 1.24 2006/05/07 18:09:00 menno Exp $
 **/
 
 /* just some common functions that could be used anywhere */
@@ -234,16 +234,16 @@
  *  which gives a period of 18.410.713.077.675.721.215. The result is the
  *  XORed values of both generators.
  */
-uint32_t random_int(void)
+uint32_t ne_rng(uint32_t *__r1, uint32_t *__r2)
 {
     uint32_t  t1, t2, t3, t4;
 
-    t3   = t1 = __r1;   t4   = t2 = __r2;       // Parity calculation is done via table lookup, this is also available
-    t1  &= 0xF5;        t2 >>= 25;              // on CPUs without parity, can be implemented in C and avoid unpredictable
+    t3   = t1 = *__r1;  t4   = t2 = *__r2;      // Parity calculation is done via table lookup, this is also available
+    t1  &= 0xF5;        t2 >>= 25;              // on CPUs without parity, can be implemented in C and avoid unpredictable
     t1   = Parity [t1]; t2  &= 0x63;            // jumps and slow rotate through the carry flag operations.
     t1 <<= 31;          t2   = Parity [t2];
 
-    return (__r1 = (t3 >> 1) | t1 ) ^ (__r2 = (t4 + t4) | t2 );
+    return (*__r1 = (t3 >> 1) | t1 ) ^ (*__r2 = (t4 + t4) | t2 );
 }
 
 uint32_t ones32(uint32_t x)
--- a/libfaad/common.h
+++ b/libfaad/common.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: common.h,v 1.66 2005/02/01 13:23:35 menno Exp $
+** $Id: common.h,v 1.67 2006/05/07 18:09:00 menno Exp $
 **/
 
 #ifndef __COMMON_H__
@@ -399,7 +399,7 @@
 
 /* common functions */
 uint8_t cpu_has_sse(void);
-uint32_t random_int(void);
+uint32_t ne_rng(uint32_t *__r1, uint32_t *__r2);
 uint32_t ones32(uint32_t x);
 uint32_t floor_log2(uint32_t x);
 uint32_t wl_min_lzc(uint32_t x);
--- a/libfaad/decoder.c
+++ b/libfaad/decoder.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: decoder.c,v 1.108 2005/02/01 13:28:51 menno Exp $
+** $Id: decoder.c,v 1.109 2006/05/07 18:09:00 menno Exp $
 **/
 
 #include "common.h"
@@ -121,6 +121,9 @@
     hDecoder->frame = 0;
     hDecoder->sample_buffer = NULL;
 
+    hDecoder->__r1 = 1;
+    hDecoder->__r2 = 1;
+
     for (i = 0; i < MAX_CHANNELS; i++)
     {
         hDecoder->window_shape_prev[i] = 0;
@@ -199,6 +202,7 @@
     return 0;
 }
 
+
 int32_t NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder, uint8_t *buffer,
                                  uint32_t buffer_size,
                                  uint32_t *samplerate, uint8_t *channels)
@@ -208,6 +212,7 @@
     adif_header adif;
     adts_header adts;
 
+
     if ((hDecoder == NULL) || (samplerate == NULL) || (channels == NULL))
         return -1;
 
@@ -262,7 +267,6 @@
         }
         faad_endbits(&ld);
     }
-    hDecoder->channelConfiguration = *channels;
 
 #if (defined(PS_DEC) || defined(DRM_PS))
     /* check if we have a mono file */
@@ -273,6 +277,8 @@
     }
 #endif
 
+    hDecoder->channelConfiguration = *channels;
+
 #ifdef SBR_DEC
     /* implicit signalling */
     if (*samplerate <= 24000 && !(hDecoder->config.dontUpSampleImplicitSBR))
@@ -427,8 +433,8 @@
     if ((channels == DRMCH_MONO) || (channels == DRMCH_STEREO))
         (*hDecoder)->sbr_present_flag = 0;
     else
-        (*hDecoder)->sbr_present_flag = 1;    
-#endif        
+        (*hDecoder)->sbr_present_flag = 1;
+#endif
 
     (*hDecoder)->fb = filter_bank_init((*hDecoder)->frameLength);
 
@@ -530,8 +536,14 @@
         chdir = hInfo->num_front_channels;
         if (chdir & 1)
         {
+#if (defined(PS_DEC) || defined(DRM_PS))
+            /* When PS is enabled output is always stereo */
+            hInfo->channel_position[chpos++] = FRONT_CHANNEL_LEFT;
+            hInfo->channel_position[chpos++] = FRONT_CHANNEL_RIGHT;
+#else
             hInfo->channel_position[chpos++] = FRONT_CHANNEL_CENTER;
             chdir--;
+#endif
         }
         for (i = 0; i < chdir; i += 2)
         {
@@ -570,8 +582,15 @@
         switch (hDecoder->channelConfiguration)
         {
         case 1:
+#if (defined(PS_DEC) || defined(DRM_PS))
+            /* When PS is enabled output is always stereo */
+            hInfo->num_front_channels = 2;
+            hInfo->channel_position[0] = FRONT_CHANNEL_LEFT;
+            hInfo->channel_position[1] = FRONT_CHANNEL_RIGHT;
+#else
             hInfo->num_front_channels = 1;
             hInfo->channel_position[0] = FRONT_CHANNEL_CENTER;
+#endif
             break;
         case 2:
             hInfo->num_front_channels = 2;
@@ -734,59 +753,7 @@
 static void conceal_output(NeAACDecHandle hDecoder, uint16_t frame_len,
                            uint8_t out_ch, void *sample_buffer)
 {
-    uint16_t i;
-    int16_t   *short_sample_buffer = (int16_t*)sample_buffer;
-    int32_t   *int_sample_buffer = (int32_t*)sample_buffer;
-#ifndef FIXED_POINT
-    float32_t *float_sample_buffer = (float32_t*)sample_buffer;
-    double    *double_sample_buffer = (double*)sample_buffer;
-#endif
-
-    static const int8_t mute_tab[ERROR_STATE_INIT+1] = { 0, 1, 1, 2, 2, 3, 3 };
-
-    if (hDecoder->error_state > 0)
-    {
-        switch (hDecoder->config.outputFormat)
-        {
-        case FAAD_FMT_16BIT:
-            for (i = 0; i < out_ch*frame_len; i++)
-            {
-                short_sample_buffer[i] >>= mute_tab[hDecoder->error_state];
-                //short_sample_buffer[i] = 0;
-            }
-
-            break;
-        case FAAD_FMT_24BIT:
-        case FAAD_FMT_32BIT:
-#ifdef FIXED_POINT
-        case FAAD_FMT_FIXED:
-#endif
-            for (i = 0; i < out_ch*frame_len; i++)
-            {
-                int_sample_buffer[i] >>= mute_tab[hDecoder->error_state];
-                //int_sample_buffer[i] = 0;
-            }
-            break;
-#ifndef FIXED_POINT
-        case FAAD_FMT_FLOAT:
-            for (i = 0; i < out_ch*frame_len; i++)
-            {
-                float_sample_buffer[i] /= (float)(1<<mute_tab[hDecoder->error_state]);
-                //float_sample_buffer[i] = 0;
-            }
-            break;
-        case FAAD_FMT_DOUBLE:
-            for (i = 0; i < out_ch*frame_len; i++)
-            {
-                double_sample_buffer[i] /= (float)(1<<mute_tab[hDecoder->error_state]);
-                //double_sample_buffer[i] = 0;
-            }
-            break;
-#endif
-        }
-
-        hDecoder->error_state--;
-    }
+    return;
 }
 #endif
 
@@ -797,7 +764,7 @@
     uint16_t i;
     uint8_t channels = 0;
     uint8_t output_channels = 0;
-    bitfile ld;
+    bitfile ld = {0};
     uint32_t bitsconsumed;
     uint16_t frame_len;
     void *sample_buffer;
@@ -821,6 +788,16 @@
 
     memset(hInfo, 0, sizeof(NeAACDecFrameInfo));
     memset(hDecoder->internal_channel, 0, MAX_CHANNELS*sizeof(hDecoder->internal_channel[0]));
+
+#ifdef USE_TIME_LIMIT
+    if ((TIME_LIMIT * get_sample_rate(hDecoder->sf_index)) > hDecoder->TL_count)
+    {
+        hDecoder->TL_count += 1024;
+    } else {
+        hInfo->error = (NUM_ERROR_MESSAGES-1);
+        goto error;
+    }
+#endif
 
 
     /* check for some common metadata tag types in the bitstream
--- a/libfaad/decoder.h
+++ b/libfaad/decoder.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: decoder.h,v 1.45 2005/02/01 13:15:57 menno Exp $
+** $Id: decoder.h,v 1.46 2006/05/07 18:09:00 menno Exp $
 **/
 
 #ifndef __DECODER_H__
--- a/libfaad/drc.c
+++ b/libfaad/drc.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: drc.c,v 1.25 2005/02/01 13:15:57 menno Exp $
+** $Id: drc.c,v 1.26 2006/05/07 18:09:00 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/drc.h
+++ b/libfaad/drc.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: drc.h,v 1.19 2005/02/01 13:15:57 menno Exp $
+** $Id: drc.h,v 1.20 2006/05/07 18:09:00 menno Exp $
 **/
 
 #ifndef __DRC_H__
--- a/libfaad/drm_dec.c
+++ b/libfaad/drm_dec.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: drm_dec.c,v 1.6 2005/02/01 13:15:57 menno Exp $
+** $Id: drm_dec.c,v 1.7 2006/05/07 18:09:00 menno Exp $
 **/
 
 #include <stdlib.h>
--- a/libfaad/drm_dec.h
+++ b/libfaad/drm_dec.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: drm_dec.h,v 1.5 2005/02/01 13:15:57 menno Exp $
+** $Id: drm_dec.h,v 1.6 2006/05/07 18:09:00 menno Exp $
 **/
 
 #ifndef __DRM_DEC_H__
--- a/libfaad/error.c
+++ b/libfaad/error.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: error.c,v 1.29 2005/02/01 13:15:57 menno Exp $
+** $Id: error.c,v 1.30 2006/05/07 18:09:00 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/error.h
+++ b/libfaad/error.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: error.h,v 1.23 2005/02/01 13:15:57 menno Exp $
+** $Id: error.h,v 1.24 2006/05/07 18:09:00 menno Exp $
 **/
 
 #ifndef __ERROR_H__
--- a/libfaad/filtbank.c
+++ b/libfaad/filtbank.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: filtbank.c,v 1.42 2005/02/01 13:28:56 menno Exp $
+** $Id: filtbank.c,v 1.43 2006/05/07 18:09:00 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/filtbank.h
+++ b/libfaad/filtbank.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: filtbank.h,v 1.24 2005/02/01 13:28:56 menno Exp $
+** $Id: filtbank.h,v 1.25 2006/05/07 18:09:00 menno Exp $
 **/
 
 #ifndef __FILTBANK_H__
--- a/libfaad/fixed.h
+++ b/libfaad/fixed.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: fixed.h,v 1.27 2005/02/01 13:15:57 menno Exp $
+** $Id: fixed.h,v 1.28 2006/05/07 18:09:00 menno Exp $
 **/
 
 #ifndef __FIXED_H__
--- a/libfaad/hcr.c
+++ b/libfaad/hcr.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: hcr.c,v 1.19 2005/02/01 13:15:57 menno Exp $
+** $Id: hcr.c,v 1.20 2006/05/07 18:09:00 menno Exp $
 **/
 
 #include "common.h"
@@ -278,7 +278,7 @@
         for (sfb = 0; sfb < ics->max_sfb; sfb++)
         {
             /* loop over all in this sfb, 4 lines per loop */
-            for (w_idx = 0; 4*w_idx < (ics->swb_offset[sfb+1] - ics->swb_offset[sfb]); w_idx++)
+            for (w_idx = 0; 4*w_idx < (min(ics->swb_offset[sfb+1], ics->swb_offset_max) - ics->swb_offset[sfb]); w_idx++)
             {
                 for(g = 0; g < ics->num_window_groups; g++)
                 {
@@ -293,7 +293,7 @@
                             if (is_good_cb(this_CB, this_sec_CB))                              
                             {
                                 /* precalculate some stuff */
-                                uint16_t sect_sfb_size = ics->sect_sfb_offset[g][sfb+1] - ics->sect_sfb_offset[g][sfb];
+                                uint16_t sect_sfb_size = min(ics->swb_offset[sfb+1], ics->swb_offset_max) - ics->swb_offset[sfb];
                                 uint8_t inc = (this_sec_CB < FIRST_PAIR_HCB) ? QUAD_LEN : PAIR_LEN;
                                 uint16_t group_cws_count = (4*ics->window_group_length[g])/inc;
                                 uint8_t segwidth = segmentWidth(this_sec_CB);
--- a/libfaad/huffman.c
+++ b/libfaad/huffman.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: huffman.c,v 1.23 2005/02/01 13:15:57 menno Exp $
+** $Id: huffman.c,v 1.24 2006/05/07 18:09:00 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/huffman.h
+++ b/libfaad/huffman.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: huffman.h,v 1.25 2005/02/01 13:15:57 menno Exp $
+** $Id: huffman.h,v 1.26 2006/05/07 18:09:00 menno Exp $
 **/
 
 #ifndef __HUFFMAN_H__
--- a/libfaad/ic_predict.c
+++ b/libfaad/ic_predict.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: ic_predict.c,v 1.24 2005/02/01 13:15:57 menno Exp $
+** $Id: ic_predict.c,v 1.25 2006/05/07 18:09:00 menno Exp $
 **/
 
 #include "common.h"
@@ -214,7 +214,7 @@
                 if (is_noise(ics, g, sfb))
                 {
                     offs = ics->swb_offset[sfb];
-                    offs2 = ics->swb_offset[sfb+1];
+                    offs2 = min(ics->swb_offset[sfb+1], ics->swb_offset_max);
 
                     for (i = offs; i < offs2; i++)
                         reset_pred_state(&state[i]);
@@ -246,7 +246,7 @@
         for (sfb = 0; sfb < max_pred_sfb(sf_index); sfb++)
         {
             uint16_t low  = ics->swb_offset[sfb];
-            uint16_t high = ics->swb_offset[sfb+1];
+            uint16_t high = min(ics->swb_offset[sfb+1], ics->swb_offset_max);
 
             for (bin = low; bin < high; bin++)
             {
--- a/libfaad/ic_predict.h
+++ b/libfaad/ic_predict.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: ic_predict.h,v 1.20 2005/02/01 13:15:57 menno Exp $
+** $Id: ic_predict.h,v 1.21 2006/05/07 18:09:00 menno Exp $
 **/
 
 #ifdef MAIN_DEC
--- a/libfaad/iq_table.h
+++ b/libfaad/iq_table.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: iq_table.h,v 1.17 2005/02/01 13:15:57 menno Exp $
+** $Id: iq_table.h,v 1.18 2006/05/07 18:09:00 menno Exp $
 **/
 
 #ifndef IQ_TABLE_H__
--- a/libfaad/is.c
+++ b/libfaad/is.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: is.c,v 1.25 2005/02/01 13:15:57 menno Exp $
+** $Id: is.c,v 1.26 2006/05/07 18:09:01 menno Exp $
 **/
 
 #include "common.h"
@@ -89,7 +89,7 @@
 
                     /* Scale from left to right channel,
                        do not touch left channel */
-                    for (i = icsr->swb_offset[sfb]; i < icsr->swb_offset[sfb+1]; i++)
+                    for (i = icsr->swb_offset[sfb]; i < min(icsr->swb_offset[sfb+1], ics->swb_offset_max); i++)
                     {
 #ifndef FIXED_POINT
                         r_spec[(group*nshort)+i] = MUL_R(l_spec[(group*nshort)+i], scale);
--- a/libfaad/is.h
+++ b/libfaad/is.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: is.h,v 1.17 2005/02/01 13:15:57 menno Exp $
+** $Id: is.h,v 1.18 2006/05/07 18:09:01 menno Exp $
 **/
 
 #ifndef __IS_H__
--- a/libfaad/kbd_win.h
+++ b/libfaad/kbd_win.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: kbd_win.h,v 1.18 2005/02/01 13:15:57 menno Exp $
+** $Id: kbd_win.h,v 1.19 2006/05/07 18:09:01 menno Exp $
 **/
 
 #ifndef __KBD_WIN_H__
--- a/libfaad/lt_predict.c
+++ b/libfaad/lt_predict.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: lt_predict.c,v 1.24 2005/02/01 13:15:57 menno Exp $
+** $Id: lt_predict.c,v 1.25 2006/05/07 18:09:01 menno Exp $
 **/
 
 
@@ -122,7 +122,7 @@
                 if (ltp->long_used[sfb])
                 {
                     uint16_t low  = ics->swb_offset[sfb];
-                    uint16_t high = ics->swb_offset[sfb+1];
+                    uint16_t high = min(ics->swb_offset[sfb+1], ics->swb_offset_max);
 
                     for (bin = low; bin < high; bin++)
                     {
--- a/libfaad/lt_predict.h
+++ b/libfaad/lt_predict.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: lt_predict.h,v 1.17 2005/02/01 13:15:57 menno Exp $
+** $Id: lt_predict.h,v 1.18 2006/05/07 18:09:01 menno Exp $
 **/
 
 #ifdef LTP_DEC
--- a/libfaad/mdct.c
+++ b/libfaad/mdct.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: mdct.c,v 1.44 2005/02/01 13:15:57 menno Exp $
+** $Id: mdct.c,v 1.45 2006/05/07 18:09:01 menno Exp $
 **/
 
 /*
--- a/libfaad/mdct.h
+++ b/libfaad/mdct.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: mdct.h,v 1.27 2005/02/01 13:28:56 menno Exp $
+** $Id: mdct.h,v 1.28 2006/05/07 18:09:01 menno Exp $
 **/
 
 #ifndef __MDCT_H__
--- a/libfaad/mdct_tab.h
+++ b/libfaad/mdct_tab.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: mdct_tab.h,v 1.4 2005/02/01 13:15:57 menno Exp $
+** $Id: mdct_tab.h,v 1.5 2006/05/07 18:09:01 menno Exp $
 **/
 
 #ifndef __MDCT_TAB_H__
--- a/libfaad/mp4.c
+++ b/libfaad/mp4.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: mp4.c,v 1.33 2005/02/01 13:15:57 menno Exp $
+** $Id: mp4.c,v 1.34 2006/05/07 18:09:01 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/mp4.h
+++ b/libfaad/mp4.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: mp4.h,v 1.22 2005/02/01 13:15:57 menno Exp $
+** $Id: mp4.h,v 1.23 2006/05/07 18:09:01 menno Exp $
 **/
 
 #ifndef __MP4_H__
--- a/libfaad/ms.c
+++ b/libfaad/ms.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: ms.c,v 1.18 2005/02/01 13:15:58 menno Exp $
+** $Id: ms.c,v 1.19 2006/05/07 18:09:01 menno Exp $
 **/
 
 #include "common.h"
@@ -63,7 +63,7 @@
                     if ((ics->ms_used[g][sfb] || ics->ms_mask_present == 2) &&
                         !is_intensity(icsr, g, sfb) && !is_noise(ics, g, sfb))
                     {
-                        for (i = ics->swb_offset[sfb]; i < ics->swb_offset[sfb+1]; i++)
+                        for (i = ics->swb_offset[sfb]; i < min(ics->swb_offset[sfb+1], ics->swb_offset_max); i++)
                         {
                             k = (group*nshort) + i;
                             tmp = l_spec[k] - r_spec[k];
--- a/libfaad/ms.h
+++ b/libfaad/ms.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: ms.h,v 1.16 2005/02/01 13:15:58 menno Exp $
+** $Id: ms.h,v 1.17 2006/05/07 18:09:01 menno Exp $
 **/
 
 #ifndef __MS_H__
--- a/libfaad/output.c
+++ b/libfaad/output.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: output.c,v 1.43 2005/02/01 13:15:58 menno Exp $
+** $Id: output.c,v 1.44 2006/05/07 18:09:01 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/output.h
+++ b/libfaad/output.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: output.h,v 1.22 2005/02/01 13:15:58 menno Exp $
+** $Id: output.h,v 1.23 2006/05/07 18:09:01 menno Exp $
 **/
 
 #ifndef __OUTPUT_H__
--- a/libfaad/pns.c
+++ b/libfaad/pns.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: pns.c,v 1.35 2005/02/01 13:15:58 menno Exp $
+** $Id: pns.c,v 1.36 2006/05/07 18:09:01 menno Exp $
 **/
 
 #include "common.h"
@@ -38,7 +38,8 @@
 
 /* static function declarations */
 static void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t size,
-                            uint8_t sub);
+                            uint8_t sub,
+                            /* RNG states */ uint32_t *__r1, uint32_t *__r2);
 
 
 #ifdef FIXED_POINT
@@ -73,7 +74,7 @@
     return root;
 }
 
-static real_t pow2_table[] =
+static real_t const pow2_table[] =
 {
     COEF_CONST(1.0),
     COEF_CONST(1.18920711500272),
@@ -88,7 +89,8 @@
    multiplication/accumulation per random value.
 */
 static INLINE void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t size,
-                                   uint8_t sub)
+                                   uint8_t sub,
+                                   /* RNG states */ uint32_t *__r1, uint32_t *__r2)
 {
 #ifndef FIXED_POINT
     uint16_t i;
@@ -98,7 +100,7 @@
 
     for (i = 0; i < size; i++)
     {
-        real_t tmp = scale*(real_t)(int32_t)random_int();
+        real_t tmp = scale*(real_t)(int32_t)ne_rng(__r1, __r2);
         spec[i] = tmp;
         energy += tmp*tmp;
     }
@@ -117,7 +119,7 @@
     for (i = 0; i < size; i++)
     {
         /* this can be replaced by a 16 bit random generator!!!! */
-        real_t tmp = (int32_t)random_int();
+        real_t tmp = (int32_t)ne_rng(__r1, __r2);
         if (tmp < 0)
             tmp = -(tmp & ((1<<(REAL_BITS-1))-1));
         else
@@ -157,7 +159,8 @@
 
 void pns_decode(ic_stream *ics_left, ic_stream *ics_right,
                 real_t *spec_left, real_t *spec_right, uint16_t frame_len,
-                uint8_t channel_pair, uint8_t object_type)
+                uint8_t channel_pair, uint8_t object_type,
+                /* RNG states */ uint32_t *__r1, uint32_t *__r2)
 {
     uint8_t g, sfb, b;
     uint16_t size, offs;
@@ -207,11 +210,11 @@
 #endif
 
                     offs = ics_left->swb_offset[sfb];
-                    size = ics_left->swb_offset[sfb+1] - offs;
+                    size = min(ics_left->swb_offset[sfb+1], ics_left->swb_offset_max) - offs;
 
                     /* Generate random vector */
                     gen_rand_vector(&spec_left[(group*nshort)+offs],
-                        ics_left->scale_factors[g][sfb], size, sub);
+                        ics_left->scale_factors[g][sfb], size, sub, __r1, __r2);
                 }
 
 /* From the spec:
@@ -238,7 +241,7 @@
                             uint16_t c;
 
                             offs = ics_right->swb_offset[sfb];
-                            size = ics_right->swb_offset[sfb+1] - offs;
+                            size = min(ics_right->swb_offset[sfb+1], ics_right->swb_offset_max) - offs;
 
                             for (c = 0; c < size; c++)
                             {
@@ -255,11 +258,11 @@
 #endif
 
                             offs = ics_right->swb_offset[sfb];
-                            size = ics_right->swb_offset[sfb+1] - offs;
+                            size = min(ics_right->swb_offset[sfb+1], ics_right->swb_offset_max) - offs;
 
                             /* Generate random vector */
                             gen_rand_vector(&spec_right[(group*nshort)+offs],
-                                ics_right->scale_factors[g][sfb], size, sub);
+                                ics_right->scale_factors[g][sfb], size, sub, __r1, __r2);
                         }
                     }
                 }
--- a/libfaad/pns.h
+++ b/libfaad/pns.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: pns.h,v 1.24 2005/02/01 13:15:58 menno Exp $
+** $Id: pns.h,v 1.25 2006/05/07 18:09:01 menno Exp $
 **/
 
 #ifndef __PNS_H__
@@ -43,7 +43,8 @@
 
 void pns_decode(ic_stream *ics_left, ic_stream *ics_right,
                 real_t *spec_left, real_t *spec_right, uint16_t frame_len,
-                uint8_t channel_pair, uint8_t object_type);
+                uint8_t channel_pair, uint8_t object_type,
+                /* RNG states */ uint32_t *__r1, uint32_t *__r2);
 
 static INLINE uint8_t is_noise(ic_stream *ics, uint8_t group, uint8_t sfb)
 {
--- a/libfaad/ps_dec.c
+++ b/libfaad/ps_dec.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: ps_dec.c,v 1.11 2005/02/01 13:15:58 menno Exp $
+** $Id: ps_dec.c,v 1.12 2006/05/07 18:09:01 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/ps_dec.h
+++ b/libfaad/ps_dec.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: ps_dec.h,v 1.9 2005/02/01 13:15:58 menno Exp $
+** $Id: ps_dec.h,v 1.10 2006/05/07 18:09:01 menno Exp $
 **/
 
 #ifndef __PS_DEC_H__
--- a/libfaad/ps_syntax.c
+++ b/libfaad/ps_syntax.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: ps_syntax.c,v 1.7 2005/02/01 13:15:58 menno Exp $
+** $Id: ps_syntax.c,v 1.8 2006/05/07 18:09:01 menno Exp $
 **/
 
 #include "common.h"
@@ -385,7 +385,10 @@
 
     /* we are here, but no header has been read yet */
     if (ps->header_read == 0)
+    {
+        ps->ps_data_available = 0;
         return 1;
+    }
 
     ps->frame_class = (uint8_t)faad_get1bit(ld
         DEBUGVAR(1,1006,"ps_data(): frame_class"));
--- a/libfaad/ps_tables.h
+++ b/libfaad/ps_tables.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: ps_tables.h,v 1.4 2005/02/01 13:15:58 menno Exp $
+** $Id: ps_tables.h,v 1.5 2006/05/07 18:09:01 menno Exp $
 **/
 
 #ifndef __PS_TABLES_H__
--- a/libfaad/pulse.c
+++ b/libfaad/pulse.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: pulse.c,v 1.18 2005/02/01 13:15:58 menno Exp $
+** $Id: pulse.c,v 1.19 2006/05/07 18:09:01 menno Exp $
 **/
 #include "common.h"
 #include "structs.h"
@@ -41,7 +41,7 @@
     uint16_t k;
     pulse_info *pul = &(ics->pul);
 
-    k = ics->swb_offset[pul->pulse_start_sfb];
+    k = min(ics->swb_offset[pul->pulse_start_sfb], ics->swb_offset_max);
 
     for (i = 0; i <= pul->number_pulse; i++)
     {
--- a/libfaad/pulse.h
+++ b/libfaad/pulse.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: pulse.h,v 1.17 2005/02/01 13:15:58 menno Exp $
+** $Id: pulse.h,v 1.18 2006/05/07 18:09:01 menno Exp $
 **/
 
 #ifndef __PULSE_H__
--- a/libfaad/rvlc.c
+++ b/libfaad/rvlc.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: rvlc.c,v 1.18 2005/02/01 13:15:58 menno Exp $
+** $Id: rvlc.c,v 1.19 2006/05/07 18:09:01 menno Exp $
 **/
 
 /* RVLC scalefactor decoding
--- a/libfaad/rvlc.h
+++ b/libfaad/rvlc.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: rvlc.h,v 1.14 2005/02/01 13:15:58 menno Exp $
+** $Id: rvlc.h,v 1.15 2006/05/07 18:09:01 menno Exp $
 **/
 
 #ifndef __RVLC_SCF_H__
--- a/libfaad/sbr_dct.c
+++ b/libfaad/sbr_dct.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,17 +19,22 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_dct.c,v 1.16 2005/02/01 13:15:58 menno Exp $
+** $Id: sbr_dct.c,v 1.17 2006/05/07 18:09:01 menno Exp $
 **/
 
+
+/* Most of the DCT/DST codes here are generated using Spiral which is GPL
+ * For more info see: http://www.spiral.net/
+ */
+
 #include "common.h"
 
 #ifdef SBR_DEC
@@ -1862,413 +1867,6 @@
         out_imag[i] = MUL_C(x_re, dct4_64_tab[i + 4*32]) + tmp;
     }
 
-}
-
-void DST4_32(real_t *y, real_t *x)
-{
-    real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9;
-    real_t f10, f11, f12, f13, f14, f15, f16, f17, f18, f19;
-    real_t f20, f21, f22, f23, f24, f25, f26, f27, f28, f29;
-    real_t f30, f31, f32, f33, f34, f35, f36, f37, f38, f39;
-    real_t f40, f41, f42, f43, f44, f45, f46, f47, f48, f49;
-    real_t f50, f51, f52, f53, f54, f55, f56, f57, f58, f59;
-    real_t f60, f61, f62, f63, f64, f65, f66, f67, f68, f69;
-    real_t f70, f71, f72, f73, f74, f75, f76, f77, f78, f79;
-    real_t f80, f81, f82, f83, f84, f85, f86, f87, f88, f89;
-    real_t f90, f91, f92, f93, f94, f95, f96, f97, f98, f99;
-    real_t f100, f101, f102, f103, f104, f105, f106, f107, f108, f109;
-    real_t f110, f111, f112, f113, f114, f115, f116, f117, f118, f119;
-    real_t f120, f121, f122, f123, f124, f125, f126, f127, f128, f129;
-    real_t f130, f131, f132, f133, f134, f135, f136, f137, f138, f139;
-    real_t f140, f141, f142, f143, f144, f145, f146, f147, f148, f149;
-    real_t f150, f151, f152, f153, f154, f155, f156, f157, f158, f159;
-    real_t f160, f161, f162, f163, f164, f165, f166, f167, f168, f169;
-    real_t f170, f171, f172, f173, f174, f175, f176, f177, f178, f179;
-    real_t f180, f181, f182, f183, f184, f185, f186, f187, f188, f189;
-    real_t f190, f191, f192, f193, f194, f195, f196, f197, f198, f199;
-    real_t f200, f201, f202, f203, f204, f205, f206, f207, f208, f209;
-    real_t f210, f211, f212, f213, f214, f215, f216, f217, f218, f219;
-    real_t f220, f221, f222, f223, f224, f225, f226, f227, f228, f229;
-    real_t f230, f231, f232, f233, f234, f235, f236, f237, f238, f239;
-    real_t f240, f241, f242, f243, f244, f245, f246, f247, f248, f249;
-    real_t f250, f251, f252, f253, f254, f255, f256, f257, f258, f259;
-    real_t f260, f261, f262, f263, f264, f265, f266, f267, f268, f269;
-    real_t f270, f271, f272, f273, f274, f275, f276, f277, f278, f279;
-    real_t f280, f281, f282, f283, f284, f285, f286, f287, f288, f289;
-    real_t f290, f291, f292, f293, f294, f295, f296, f297, f298, f299;
-    real_t f300, f301, f302, f303, f304, f305, f306, f307, f308, f309;
-    real_t f310, f311, f312, f313, f314, f315, f316, f317, f318, f319;
-    real_t f320, f321, f322, f323, f324, f325, f326, f327, f328, f329;
-    real_t f330, f331, f332, f333, f334, f335;
-
-    f0 = x[0] - x[1];
-    f1 = x[2] - x[1];
-    f2 = x[2] - x[3];
-    f3 = x[4] - x[3];
-    f4 = x[4] - x[5];
-    f5 = x[6] - x[5];
-    f6 = x[6] - x[7];
-    f7 = x[8] - x[7];
-    f8 = x[8] - x[9];
-    f9 = x[10] - x[9];
-    f10 = x[10] - x[11];
-    f11 = x[12] - x[11];
-    f12 = x[12] - x[13];
-    f13 = x[14] - x[13];
-    f14 = x[14] - x[15];
-    f15 = x[16] - x[15];
-    f16 = x[16] - x[17];
-    f17 = x[18] - x[17];
-    f18 = x[18] - x[19];
-    f19 = x[20] - x[19];
-    f20 = x[20] - x[21];
-    f21 = x[22] - x[21];
-    f22 = x[22] - x[23];
-    f23 = x[24] - x[23];
-    f24 = x[24] - x[25];
-    f25 = x[26] - x[25];
-    f26 = x[26] - x[27];
-    f27 = x[28] - x[27];
-    f28 = x[28] - x[29];
-    f29 = x[30] - x[29];
-    f30 = x[30] - x[31];
-    f31 = MUL_F(FRAC_CONST(0.7071067811865476), f15);
-    f32 = x[0] - f31;
-    f33 = x[0] + f31;
-    f34 = f7 + f23;
-    f35 = MUL_C(COEF_CONST(1.3065629648763766), f7);
-    f36 = MUL_F(FRAC_CONST(-0.9238795325112866), f34);
-    f37 = MUL_F(FRAC_CONST(-0.5411961001461967), f23);
-    f38 = f35 + f36;
-    f39 = f37 - f36;
-    f40 = f33 - f39;
-    f41 = f33 + f39;
-    f42 = f32 - f38;
-    f43 = f32 + f38;
-    f44 = f11 - f19;
-    f45 = f11 + f19;
-    f46 = MUL_F(FRAC_CONST(0.7071067811865476), f45);
-    f47 = f3 - f46;
-    f48 = f3 + f46;
-    f49 = MUL_F(FRAC_CONST(0.7071067811865476), f44);
-    f50 = f49 - f27;
-    f51 = f49 + f27;
-    f52 = f51 + f48;
-    f53 = MUL_F(FRAC_CONST(-0.7856949583871021), f51);
-    f54 = MUL_F(FRAC_CONST(0.9807852804032304), f52);
-    f55 = MUL_C(COEF_CONST(1.1758756024193588), f48);
-    f56 = f53 + f54;
-    f57 = f55 - f54;
-    f58 = f50 + f47;
-    f59 = MUL_F(FRAC_CONST(-0.2758993792829430), f50);
-    f60 = MUL_F(FRAC_CONST(0.8314696123025452), f58);
-    f61 = MUL_C(COEF_CONST(1.3870398453221475), f47);
-    f62 = f59 + f60;
-    f63 = f61 - f60;
-    f64 = f41 - f56;
-    f65 = f41 + f56;
-    f66 = f43 - f62;
-    f67 = f43 + f62;
-    f68 = f42 - f63;
-    f69 = f42 + f63;
-    f70 = f40 - f57;
-    f71 = f40 + f57;
-    f72 = f5 - f9;
-    f73 = f5 + f9;
-    f74 = f13 - f17;
-    f75 = f13 + f17;
-    f76 = f21 - f25;
-    f77 = f21 + f25;
-    f78 = MUL_F(FRAC_CONST(0.7071067811865476), f75);
-    f79 = f1 - f78;
-    f80 = f1 + f78;
-    f81 = f73 + f77;
-    f82 = MUL_C(COEF_CONST(1.3065629648763766), f73);
-    f83 = MUL_F(FRAC_CONST(-0.9238795325112866), f81);
-    f84 = MUL_F(FRAC_CONST(-0.5411961001461967), f77);
-    f85 = f82 + f83;
-    f86 = f84 - f83;
-    f87 = f80 - f86;
-    f88 = f80 + f86;
-    f89 = f79 - f85;
-    f90 = f79 + f85;
-    f91 = MUL_F(FRAC_CONST(0.7071067811865476), f74);
-    f92 = f29 - f91;
-    f93 = f29 + f91;
-    f94 = f76 + f72;
-    f95 = MUL_C(COEF_CONST(1.3065629648763766), f76);
-    f96 = MUL_F(FRAC_CONST(-0.9238795325112866), f94);
-    f97 = MUL_F(FRAC_CONST(-0.5411961001461967), f72);
-    f98 = f95 + f96;
-    f99 = f97 - f96;
-    f100 = f93 - f99;
-    f101 = f93 + f99;
-    f102 = f92 - f98;
-    f103 = f92 + f98;
-    f104 = f101 + f88;
-    f105 = MUL_F(FRAC_CONST(-0.8971675863426361), f101);
-    f106 = MUL_F(FRAC_CONST(0.9951847266721968), f104);
-    f107 = MUL_C(COEF_CONST(1.0932018670017576), f88);
-    f108 = f105 + f106;
-    f109 = f107 - f106;
-    f110 = f90 - f103;
-    f111 = MUL_F(FRAC_CONST(-0.6666556584777466), f103);
-    f112 = MUL_F(FRAC_CONST(0.9569403357322089), f110);
-    f113 = MUL_C(COEF_CONST(1.2472250129866713), f90);
-    f114 = f112 - f111;
-    f115 = f113 - f112;
-    f116 = f102 + f89;
-    f117 = MUL_F(FRAC_CONST(-0.4105245275223571), f102);
-    f118 = MUL_F(FRAC_CONST(0.8819212643483549), f116);
-    f119 = MUL_C(COEF_CONST(1.3533180011743529), f89);
-    f120 = f117 + f118;
-    f121 = f119 - f118;
-    f122 = f87 - f100;
-    f123 = MUL_F(FRAC_CONST(-0.1386171691990915), f100);
-    f124 = MUL_F(FRAC_CONST(0.7730104533627370), f122);
-    f125 = MUL_C(COEF_CONST(1.4074037375263826), f87);
-    f126 = f124 - f123;
-    f127 = f125 - f124;
-    f128 = f65 - f108;
-    f129 = f65 + f108;
-    f130 = f67 - f114;
-    f131 = f67 + f114;
-    f132 = f69 - f120;
-    f133 = f69 + f120;
-    f134 = f71 - f126;
-    f135 = f71 + f126;
-    f136 = f70 - f127;
-    f137 = f70 + f127;
-    f138 = f68 - f121;
-    f139 = f68 + f121;
-    f140 = f66 - f115;
-    f141 = f66 + f115;
-    f142 = f64 - f109;
-    f143 = f64 + f109;
-    f144 = f0 + f30;
-    f145 = MUL_C(COEF_CONST(1.0478631305325901), f0);
-    f146 = MUL_F(FRAC_CONST(-0.9987954562051724), f144);
-    f147 = MUL_F(FRAC_CONST(-0.9497277818777548), f30);
-    f148 = f145 + f146;
-    f149 = f147 - f146;
-    f150 = f4 + f26;
-    f151 = MUL_F(FRAC_CONST(1.2130114330978077), f4);
-    f152 = MUL_F(FRAC_CONST(-0.9700312531945440), f150);
-    f153 = MUL_F(FRAC_CONST(-0.7270510732912803), f26);
-    f154 = f151 + f152;
-    f155 = f153 - f152;
-    f156 = f8 + f22;
-    f157 = MUL_C(COEF_CONST(1.3315443865537255), f8);
-    f158 = MUL_F(FRAC_CONST(-0.9039892931234433), f156);
-    f159 = MUL_F(FRAC_CONST(-0.4764341996931612), f22);
-    f160 = f157 + f158;
-    f161 = f159 - f158;
-    f162 = f12 + f18;
-    f163 = MUL_C(COEF_CONST(1.3989068359730781), f12);
-    f164 = MUL_F(FRAC_CONST(-0.8032075314806453), f162);
-    f165 = MUL_F(FRAC_CONST(-0.2075082269882124), f18);
-    f166 = f163 + f164;
-    f167 = f165 - f164;
-    f168 = f16 + f14;
-    f169 = MUL_C(COEF_CONST(1.4125100802019777), f16);
-    f170 = MUL_F(FRAC_CONST(-0.6715589548470187), f168);
-    f171 = MUL_F(FRAC_CONST(0.0693921705079402), f14);
-    f172 = f169 + f170;
-    f173 = f171 - f170;
-    f174 = f20 + f10;
-    f175 = MUL_C(COEF_CONST(1.3718313541934939), f20);
-    f176 = MUL_F(FRAC_CONST(-0.5141027441932219), f174);
-    f177 = MUL_F(FRAC_CONST(0.3436258658070501), f10);
-    f178 = f175 + f176;
-    f179 = f177 - f176;
-    f180 = f24 + f6;
-    f181 = MUL_C(COEF_CONST(1.2784339185752409), f24);
-    f182 = MUL_F(FRAC_CONST(-0.3368898533922200), f180);
-    f183 = MUL_F(FRAC_CONST(0.6046542117908008), f6);
-    f184 = f181 + f182;
-    f185 = f183 - f182;
-    f186 = f28 + f2;
-    f187 = MUL_C(COEF_CONST(1.1359069844201433), f28);
-    f188 = MUL_F(FRAC_CONST(-0.1467304744553624), f186);
-    f189 = MUL_F(FRAC_CONST(0.8424460355094185), f2);
-    f190 = f187 + f188;
-    f191 = f189 - f188;
-    f192 = f149 - f173;
-    f193 = f149 + f173;
-    f194 = f148 - f172;
-    f195 = f148 + f172;
-    f196 = f155 - f179;
-    f197 = f155 + f179;
-    f198 = f154 - f178;
-    f199 = f154 + f178;
-    f200 = f161 - f185;
-    f201 = f161 + f185;
-    f202 = f160 - f184;
-    f203 = f160 + f184;
-    f204 = f167 - f191;
-    f205 = f167 + f191;
-    f206 = f166 - f190;
-    f207 = f166 + f190;
-    f208 = f192 + f194;
-    f209 = MUL_C(COEF_CONST(1.1758756024193588), f192);
-    f210 = MUL_F(FRAC_CONST(-0.9807852804032304), f208);
-    f211 = MUL_F(FRAC_CONST(-0.7856949583871021), f194);
-    f212 = f209 + f210;
-    f213 = f211 - f210;
-    f214 = f196 + f198;
-    f215 = MUL_C(COEF_CONST(1.3870398453221475), f196);
-    f216 = MUL_F(FRAC_CONST(-0.5555702330196022), f214);
-    f217 = MUL_F(FRAC_CONST(0.2758993792829431), f198);
-    f218 = f215 + f216;
-    f219 = f217 - f216;
-    f220 = f200 + f202;
-    f221 = MUL_F(FRAC_CONST(0.7856949583871022), f200);
-    f222 = MUL_F(FRAC_CONST(0.1950903220161283), f220);
-    f223 = MUL_C(COEF_CONST(1.1758756024193586), f202);
-    f224 = f221 + f222;
-    f225 = f223 - f222;
-    f226 = f204 + f206;
-    f227 = MUL_F(FRAC_CONST(-0.2758993792829430), f204);
-    f228 = MUL_F(FRAC_CONST(0.8314696123025452), f226);
-    f229 = MUL_C(COEF_CONST(1.3870398453221475), f206);
-    f230 = f227 + f228;
-    f231 = f229 - f228;
-    f232 = f193 - f201;
-    f233 = f193 + f201;
-    f234 = f195 - f203;
-    f235 = f195 + f203;
-    f236 = f197 - f205;
-    f237 = f197 + f205;
-    f238 = f199 - f207;
-    f239 = f199 + f207;
-    f240 = f213 - f225;
-    f241 = f213 + f225;
-    f242 = f212 - f224;
-    f243 = f212 + f224;
-    f244 = f219 - f231;
-    f245 = f219 + f231;
-    f246 = f218 - f230;
-    f247 = f218 + f230;
-    f248 = f232 + f234;
-    f249 = MUL_C(COEF_CONST(1.3065629648763766), f232);
-    f250 = MUL_F(FRAC_CONST(-0.9238795325112866), f248);
-    f251 = MUL_F(FRAC_CONST(-0.5411961001461967), f234);
-    f252 = f249 + f250;
-    f253 = f251 - f250;
-    f254 = f236 + f238;
-    f255 = MUL_F(FRAC_CONST(0.5411961001461969), f236);
-    f256 = MUL_F(FRAC_CONST(0.3826834323650898), f254);
-    f257 = MUL_C(COEF_CONST(1.3065629648763766), f238);
-    f258 = f255 + f256;
-    f259 = f257 - f256;
-    f260 = f240 + f242;
-    f261 = MUL_C(COEF_CONST(1.3065629648763766), f240);
-    f262 = MUL_F(FRAC_CONST(-0.9238795325112866), f260);
-    f263 = MUL_F(FRAC_CONST(-0.5411961001461967), f242);
-    f264 = f261 + f262;
-    f265 = f263 - f262;
-    f266 = f244 + f246;
-    f267 = MUL_F(FRAC_CONST(0.5411961001461969), f244);
-    f268 = MUL_F(FRAC_CONST(0.3826834323650898), f266);
-    f269 = MUL_C(COEF_CONST(1.3065629648763766), f246);
-    f270 = f267 + f268;
-    f271 = f269 - f268;
-    f272 = f233 - f237;
-    f273 = f233 + f237;
-    f274 = f235 - f239;
-    f275 = f235 + f239;
-    f276 = f253 - f259;
-    f277 = f253 + f259;
-    f278 = f252 - f258;
-    f279 = f252 + f258;
-    f280 = f241 - f245;
-    f281 = f241 + f245;
-    f282 = f243 - f247;
-    f283 = f243 + f247;
-    f284 = f265 - f271;
-    f285 = f265 + f271;
-    f286 = f264 - f270;
-    f287 = f264 + f270;
-    f288 = f272 - f274;
-    f289 = f272 + f274;
-    f290 = MUL_F(FRAC_CONST(0.7071067811865474), f288);
-    f291 = MUL_F(FRAC_CONST(0.7071067811865474), f289);
-    f292 = f276 - f278;
-    f293 = f276 + f278;
-    f294 = MUL_F(FRAC_CONST(0.7071067811865474), f292);
-    f295 = MUL_F(FRAC_CONST(0.7071067811865474), f293);
-    f296 = f280 - f282;
-    f297 = f280 + f282;
-    f298 = MUL_F(FRAC_CONST(0.7071067811865474), f296);
-    f299 = MUL_F(FRAC_CONST(0.7071067811865474), f297);
-    f300 = f284 - f286;
-    f301 = f284 + f286;
-    f302 = MUL_F(FRAC_CONST(0.7071067811865474), f300);
-    f303 = MUL_F(FRAC_CONST(0.7071067811865474), f301);
-    f304 = f129 - f273;
-    f305 = f129 + f273;
-    f306 = f131 - f281;
-    f307 = f131 + f281;
-    f308 = f133 - f285;
-    f309 = f133 + f285;
-    f310 = f135 - f277;
-    f311 = f135 + f277;
-    f312 = f137 - f295;
-    f313 = f137 + f295;
-    f314 = f139 - f303;
-    f315 = f139 + f303;
-    f316 = f141 - f299;
-    f317 = f141 + f299;
-    f318 = f143 - f291;
-    f319 = f143 + f291;
-    f320 = f142 - f290;
-    f321 = f142 + f290;
-    f322 = f140 - f298;
-    f323 = f140 + f298;
-    f324 = f138 - f302;
-    f325 = f138 + f302;
-    f326 = f136 - f294;
-    f327 = f136 + f294;
-    f328 = f134 - f279;
-    f329 = f134 + f279;
-    f330 = f132 - f287;
-    f331 = f132 + f287;
-    f332 = f130 - f283;
-    f333 = f130 + f283;
-    f334 = f128 - f275;
-    f335 = f128 + f275;
-    y[31] = MUL_F(FRAC_CONST(0.5001506360206510), f305);
-    y[30] = MUL_F(FRAC_CONST(0.5013584524464084), f307);
-    y[29] = MUL_F(FRAC_CONST(0.5037887256810443), f309);
-    y[28] = MUL_F(FRAC_CONST(0.5074711720725553), f311);
-    y[27] = MUL_F(FRAC_CONST(0.5124514794082247), f313);
-    y[26] = MUL_F(FRAC_CONST(0.5187927131053328), f315);
-    y[25] = MUL_F(FRAC_CONST(0.5265773151542700), f317);
-    y[24] = MUL_F(FRAC_CONST(0.5359098169079920), f319);
-    y[23] = MUL_F(FRAC_CONST(0.5469204379855088), f321);
-    y[22] = MUL_F(FRAC_CONST(0.5597698129470802), f323);
-    y[21] = MUL_F(FRAC_CONST(0.5746551840326600), f325);
-    y[20] = MUL_F(FRAC_CONST(0.5918185358574165), f327);
-    y[19] = MUL_F(FRAC_CONST(0.6115573478825099), f329);
-    y[18] = MUL_F(FRAC_CONST(0.6342389366884031), f331);
-    y[17] = MUL_F(FRAC_CONST(0.6603198078137061), f333);
-    y[16] = MUL_F(FRAC_CONST(0.6903721282002123), f335);
-    y[15] = MUL_F(FRAC_CONST(0.7251205223771985), f334);
-    y[14] = MUL_F(FRAC_CONST(0.7654941649730891), f332);
-    y[13] = MUL_F(FRAC_CONST(0.8127020908144905), f330);
-    y[12] = MUL_F(FRAC_CONST(0.8683447152233481), f328);
-    y[11] = MUL_F(FRAC_CONST(0.9345835970364075), f326);
-    y[10] = MUL_C(COEF_CONST(1.0144082649970547), f324);
-    y[9] = MUL_C(COEF_CONST(1.1120716205797176), f322);
-    y[8] = MUL_C(COEF_CONST(1.2338327379765710), f320);
-    y[7] = MUL_C(COEF_CONST(1.3892939586328277), f318);
-    y[6] = MUL_C(COEF_CONST(1.5939722833856311), f316);
-    y[5] = MUL_C(COEF_CONST(1.8746759800084078), f314);
-    y[4] = MUL_C(COEF_CONST(2.2820500680051619), f312);
-    y[3] = MUL_C(COEF_CONST(2.9246284281582162), f310);
-    y[2] = MUL_C(COEF_CONST(4.0846110781292477), f308);
-    y[1] = MUL_C(COEF_CONST(6.7967507116736332), f306);
-    y[0] = MUL_R(REAL_CONST(20.3738781672314530), f304);
 }
 
 #endif
--- a/libfaad/sbr_dct.h
+++ b/libfaad/sbr_dct.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_dct.h,v 1.16 2005/02/01 13:15:59 menno Exp $
+** $Id: sbr_dct.h,v 1.17 2006/05/07 18:09:01 menno Exp $
 **/
 
 #ifndef __SBR_DCT_H__
--- a/libfaad/sbr_dec.c
+++ b/libfaad/sbr_dec.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_dec.c,v 1.40 2005/02/01 13:15:59 menno Exp $
+** $Id: sbr_dec.c,v 1.41 2006/05/07 18:09:01 menno Exp $
 **/
 
 
--- a/libfaad/sbr_dec.h
+++ b/libfaad/sbr_dec.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_dec.h,v 1.36 2005/02/01 13:15:59 menno Exp $
+** $Id: sbr_dec.h,v 1.37 2006/05/07 18:09:01 menno Exp $
 **/
 
 #ifndef __SBR_DEC_H__
@@ -188,6 +188,7 @@
 #endif
 #if (defined(PS_DEC) || defined(DRM_PS))
     uint8_t ps_used;
+    uint8_t psResetFlag;
 #endif
 
     /* to get it compiling */
--- a/libfaad/sbr_e_nf.c
+++ b/libfaad/sbr_e_nf.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_e_nf.c,v 1.18 2005/02/01 13:15:59 menno Exp $
+** $Id: sbr_e_nf.c,v 1.19 2006/05/07 18:09:01 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/sbr_e_nf.h
+++ b/libfaad/sbr_e_nf.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_e_nf.h,v 1.15 2005/02/01 13:15:59 menno Exp $
+** $Id: sbr_e_nf.h,v 1.16 2006/05/07 18:09:01 menno Exp $
 **/
 
 #ifndef __SBR_E_NF_H__
--- a/libfaad/sbr_fbt.c
+++ b/libfaad/sbr_fbt.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_fbt.c,v 1.18 2005/02/01 13:28:56 menno Exp $
+** $Id: sbr_fbt.c,v 1.19 2006/05/07 18:09:01 menno Exp $
 **/
 
 /* Calculate frequency band tables */
--- a/libfaad/sbr_fbt.h
+++ b/libfaad/sbr_fbt.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_fbt.h,v 1.15 2005/02/01 13:15:59 menno Exp $
+** $Id: sbr_fbt.h,v 1.16 2006/05/07 18:09:01 menno Exp $
 **/
 
 #ifndef __SBR_FBT_H__
--- a/libfaad/sbr_hfadj.c
+++ b/libfaad/sbr_hfadj.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_hfadj.c,v 1.19 2005/02/01 13:15:59 menno Exp $
+** $Id: sbr_hfadj.c,v 1.20 2006/05/07 18:09:01 menno Exp $
 **/
 
 /* High Frequency adjustment */
--- a/libfaad/sbr_hfadj.h
+++ b/libfaad/sbr_hfadj.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_hfadj.h,v 1.16 2005/02/01 13:15:59 menno Exp $
+** $Id: sbr_hfadj.h,v 1.17 2006/05/07 18:09:02 menno Exp $
 **/
 
 #ifndef __SBR_HFADJ_H__
--- a/libfaad/sbr_hfgen.c
+++ b/libfaad/sbr_hfgen.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_hfgen.c,v 1.23 2005/02/01 13:28:56 menno Exp $
+** $Id: sbr_hfgen.c,v 1.24 2006/05/07 18:09:02 menno Exp $
 **/
 
 /* High Frequency generation */
--- a/libfaad/sbr_hfgen.h
+++ b/libfaad/sbr_hfgen.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_hfgen.h,v 1.17 2005/02/01 13:15:59 menno Exp $
+** $Id: sbr_hfgen.h,v 1.18 2006/05/07 18:09:02 menno Exp $
 **/
 
 #ifndef __SBR_HFGEN_H__
--- a/libfaad/sbr_huff.c
+++ b/libfaad/sbr_huff.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_huff.c,v 1.18 2005/02/01 13:15:59 menno Exp $
+** $Id: sbr_huff.c,v 1.19 2006/05/07 18:09:02 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/sbr_huff.h
+++ b/libfaad/sbr_huff.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_huff.h,v 1.18 2005/02/01 13:15:59 menno Exp $
+** $Id: sbr_huff.h,v 1.19 2006/05/07 18:09:02 menno Exp $
 **/
 
 #ifndef __SBR_HUFF_H__
--- a/libfaad/sbr_noise.h
+++ b/libfaad/sbr_noise.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_noise.h,v 1.14 2005/02/01 13:15:59 menno Exp $
+** $Id: sbr_noise.h,v 1.15 2006/05/07 18:09:02 menno Exp $
 **/
 
 #ifndef __SBR_NOISE_H__
--- a/libfaad/sbr_qmf.c
+++ b/libfaad/sbr_qmf.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_qmf.c,v 1.28 2005/02/01 13:15:59 menno Exp $
+** $Id: sbr_qmf.c,v 1.29 2006/05/07 18:09:02 menno Exp $
 **/
 
 #include "common.h"
@@ -413,20 +413,20 @@
         for (k = 0; k < 32; k++)
         {
             x1[k] = MUL_F(QMF_RE(X[l][k]), RE(qmf32_pre_twiddle[k])) - MUL_F(QMF_IM(X[l][k]), IM(qmf32_pre_twiddle[k]));
-            x2[k] = MUL_F(QMF_IM(X[l][k]), RE(qmf32_pre_twiddle[k])) + MUL_F(QMF_RE(X[l][k]), IM(qmf32_pre_twiddle[k]));
+            x2[31-k] = MUL_F(QMF_IM(X[l][k]), RE(qmf32_pre_twiddle[k])) + MUL_F(QMF_RE(X[l][k]), IM(qmf32_pre_twiddle[k]));
 
 #ifndef FIXED_POINT
             x1[k] *= scale;
-            x2[k] *= scale;
+            x2[31-k] *= scale;
 #else
             x1[k] >>= 1;
-            x2[k] >>= 1;
+            x2[31-k] >>= 1;
 #endif
         }
 
         /* transform */
         DCT4_32(x1, x1);
-        DST4_32(x2, x2);
+        DCT4_32(x2, x2);
 
         for (n = 0; n < 32; n++)
         {
--- a/libfaad/sbr_qmf.h
+++ b/libfaad/sbr_qmf.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_qmf.h,v 1.22 2005/02/01 13:28:56 menno Exp $
+** $Id: sbr_qmf.h,v 1.23 2006/05/07 18:09:02 menno Exp $
 **/
 
 #ifndef __SBR_QMF_H__
--- a/libfaad/sbr_qmf_c.h
+++ b/libfaad/sbr_qmf_c.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_qmf_c.h,v 1.14 2005/02/01 13:15:59 menno Exp $
+** $Id: sbr_qmf_c.h,v 1.15 2006/05/07 18:09:02 menno Exp $
 **/
 
 #ifndef __SBR_QMF_C_H__
--- a/libfaad/sbr_syntax.c
+++ b/libfaad/sbr_syntax.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_syntax.c,v 1.35 2005/02/01 13:15:59 menno Exp $
+** $Id: sbr_syntax.c,v 1.36 2006/05/07 18:09:02 menno Exp $
 **/
 
 #include "common.h"
@@ -51,6 +51,7 @@
 #include "analysis.h"
 
 /* static function declarations */
+/* static function declarations */
 static void sbr_header(bitfile *ld, sbr_info *sbr);
 static uint8_t calc_sbr_tables(sbr_info *sbr, uint8_t start_freq, uint8_t stop_freq,
                                uint8_t samplerate_mode, uint8_t freq_scale,
@@ -136,16 +137,23 @@
 }
 
 /* table 2 */
-uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt)
+uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt,
+                           uint8_t psResetFlag)
 {
     uint8_t result = 0;
     uint16_t num_align_bits = 0;
-    uint16_t num_sbr_bits = (uint16_t)faad_get_processed_bits(ld);
+    uint16_t num_sbr_bits1 = (uint16_t)faad_get_processed_bits(ld);
+    uint16_t num_sbr_bits2;
 
     uint8_t saved_start_freq, saved_samplerate_mode;
     uint8_t saved_stop_freq, saved_freq_scale;
     uint8_t saved_alter_scale, saved_xover_band;
 
+#if (defined(PS_DEC) || defined(DRM_PS))
+    if (psResetFlag)
+        sbr->psResetFlag = psResetFlag;
+#endif
+
 #ifdef DRM
     if (!sbr->Is_DRM_SBR)
 #endif
@@ -219,14 +227,24 @@
         }
     } else {
         result = 1;
-    }     
-           
-     
-    num_sbr_bits = (uint16_t)faad_get_processed_bits(ld) - num_sbr_bits;
+    }
 
+    num_sbr_bits2 = (uint16_t)faad_get_processed_bits(ld) - num_sbr_bits1;
+
     /* check if we read more bits then were available for sbr */
-    if (8*cnt < num_sbr_bits) {
-            return 1;
+    if (8*cnt < num_sbr_bits2)
+    {
+        faad_resetbits(ld, num_sbr_bits1 + 8*cnt);
+        num_sbr_bits2 = 8*cnt;
+
+#ifdef PS_DEC
+        /* turn off PS for the unfortunate case that we randomly read some
+         * PS data that looks correct */
+        sbr->ps_used = 0;
+#endif
+
+        /* Make sure it doesn't decode SBR in this frame, or we'll get glitches */
+        return 1;
     }
 
 #ifdef DRM
@@ -234,7 +252,7 @@
 #endif
     {       
         /* -4 does not apply, bs_extension_type is re-read in this function */
-        num_align_bits = 8*cnt /*- 4*/ - num_sbr_bits;
+        num_align_bits = 8*cnt /*- 4*/ - num_sbr_bits2;
 
         while (num_align_bits > 7)
         {
@@ -843,6 +861,10 @@
         {
             sbr->ps = ps_init(get_sr_index(sbr->sample_rate));
         }
+        if (sbr->psResetFlag)
+        {
+            sbr->ps->header_read = 0;
+        }
         ret = ps_data(sbr->ps, ld, &header);
 
         /* enable PS if and only if: a header has been decoded */
@@ -849,6 +871,11 @@
         if (sbr->ps_used == 0 && header == 1)
         {
             sbr->ps_used = 1;
+        }
+
+        if (header == 1)
+        {
+            sbr->psResetFlag = 0;
         }
 
         return ret;
--- a/libfaad/sbr_syntax.h
+++ b/libfaad/sbr_syntax.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_syntax.h,v 1.20 2005/02/01 13:15:59 menno Exp $
+** $Id: sbr_syntax.h,v 1.21 2006/05/07 18:09:02 menno Exp $
 **/
 
 #ifndef __SBR_SYNTAX_H__
@@ -60,7 +60,8 @@
 #define NOISE_FLOOR_OFFSET 6
 
 
-uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt);
+uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt,
+                           uint8_t resetFlag);
 
 #ifdef __cplusplus
 }
--- a/libfaad/sbr_tf_grid.c
+++ b/libfaad/sbr_tf_grid.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_tf_grid.c,v 1.16 2005/02/01 13:15:59 menno Exp $
+** $Id: sbr_tf_grid.c,v 1.17 2006/05/07 18:09:02 menno Exp $
 **/
 
 /* Time/Frequency grid */
--- a/libfaad/sbr_tf_grid.h
+++ b/libfaad/sbr_tf_grid.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_tf_grid.h,v 1.14 2005/02/01 13:15:59 menno Exp $
+** $Id: sbr_tf_grid.h,v 1.15 2006/05/07 18:09:02 menno Exp $
 **/
 
 #ifndef __SBR_TF_GRID_H__
--- a/libfaad/sine_win.h
+++ b/libfaad/sine_win.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sine_win.h,v 1.16 2005/02/01 13:15:59 menno Exp $
+** $Id: sine_win.h,v 1.17 2006/05/07 18:09:02 menno Exp $
 **/
 
 #ifndef __SINE_WIN_H__
--- a/libfaad/specrec.c
+++ b/libfaad/specrec.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: specrec.c,v 1.57 2005/02/01 13:28:56 menno Exp $
+** $Id: specrec.c,v 1.58 2006/05/07 18:09:03 menno Exp $
 **/
 
 /*
@@ -358,6 +358,7 @@
             }
             ics->sect_sfb_offset[0][ics->num_swb] = hDecoder->frameLength;
             ics->swb_offset[ics->num_swb] = hDecoder->frameLength;
+            ics->swb_offset_max = hDecoder->frameLength;
         } else {
 #endif
             for (i = 0; i < ics->num_swb; i++)
@@ -367,6 +368,7 @@
             }
             ics->sect_sfb_offset[0][ics->num_swb] = hDecoder->frameLength;
             ics->swb_offset[ics->num_swb] = hDecoder->frameLength;
+            ics->swb_offset_max = hDecoder->frameLength;
 #ifdef LD_DEC
         }
 #endif
@@ -385,6 +387,7 @@
         for (i = 0; i < ics->num_swb; i++)
             ics->swb_offset[i] = swb_offset_128_window[sf_index][i];
         ics->swb_offset[ics->num_swb] = hDecoder->frameLength/8;
+        ics->swb_offset_max = hDecoder->frameLength/8;
 
         for (i = 0; i < ics->num_windows-1; i++) {
             if (bit_set(ics->scale_factor_grouping, 6-i) == 0)
@@ -682,7 +685,7 @@
 static uint8_t allocate_single_channel(NeAACDecHandle hDecoder, uint8_t channel,
                                        uint8_t output_channels)
 {
-    uint8_t mul = 1;
+    int mul = 1;
 
 #ifdef MAIN_DEC
     /* MAIN object type prediction */
@@ -783,7 +786,7 @@
 static uint8_t allocate_channel_pair(NeAACDecHandle hDecoder,
                                      uint8_t channel, uint8_t paired_channel)
 {
-    uint8_t mul = 1;
+    int mul = 1;
 
 #ifdef MAIN_DEC
     /* MAIN object type prediction */
@@ -888,7 +891,8 @@
 uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics,
                                    element *sce, int16_t *spec_data)
 {
-    uint8_t retval, output_channels;
+    uint8_t retval;
+    int output_channels;
     ALIGN real_t spec_coef[1024];
 
 #ifdef PROFILE
@@ -904,6 +908,8 @@
         output_channels = 2;
     else
         output_channels = 1;
+#else
+    output_channels = 1;
 #endif
 
     if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 0)
@@ -947,7 +953,8 @@
 
 
     /* pns decoding */
-    pns_decode(ics, NULL, spec_coef, NULL, hDecoder->frameLength, 0, hDecoder->object_type);
+    pns_decode(ics, NULL, spec_coef, NULL, hDecoder->frameLength, 0, hDecoder->object_type,
+        &(hDecoder->__r1), &(hDecoder->__r2));
 
 #ifdef MAIN_DEC
     /* MAIN object type prediction */
@@ -1031,8 +1038,8 @@
     if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
         && hDecoder->sbr_alloced[hDecoder->fr_ch_ele])
     {
-        uint8_t ele = hDecoder->fr_ch_ele;
-        uint8_t ch = sce->channel;
+        int ele = hDecoder->fr_ch_ele;
+        int ch = sce->channel;
 
         /* following case can happen when forceUpSampling == 1 */
         if (hDecoder->sbr[ele] == NULL)
@@ -1047,9 +1054,9 @@
         }
 
         if (sce->ics1.window_sequence == EIGHT_SHORT_SEQUENCE)
-            hDecoder->sbr[ele]->maxAACLine = 8*sce->ics1.swb_offset[max(sce->ics1.max_sfb-1, 0)];
+            hDecoder->sbr[ele]->maxAACLine = 8*min(sce->ics1.swb_offset[max(sce->ics1.max_sfb-1, 0)], sce->ics1.swb_offset_max);
         else
-            hDecoder->sbr[ele]->maxAACLine = sce->ics1.swb_offset[max(sce->ics1.max_sfb-1, 0)];
+            hDecoder->sbr[ele]->maxAACLine = min(sce->ics1.swb_offset[max(sce->ics1.max_sfb-1, 0)], sce->ics1.swb_offset_max);
 
         /* check if any of the PS tools is used */
 #if (defined(PS_DEC) || defined(DRM_PS))
@@ -1079,9 +1086,9 @@
     if ((hDecoder->ps_used[hDecoder->fr_ch_ele] == 0) &&
         (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 2))
     {
-        uint8_t ele = hDecoder->fr_ch_ele;
-        uint8_t ch = sce->channel;
-        uint16_t frame_size = (hDecoder->sbr_alloced[ele]) ? 2 : 1;
+        int ele = hDecoder->fr_ch_ele;
+        int ch = sce->channel;
+        int frame_size = (hDecoder->sbr_alloced[ele]) ? 2 : 1;
         frame_size *= hDecoder->frameLength*sizeof(real_t);
 
         memcpy(hDecoder->time_out[ch+1], hDecoder->time_out[ch], frame_size);
@@ -1127,10 +1134,13 @@
     /* pns decoding */
     if (ics1->ms_mask_present)
     {
-        pns_decode(ics1, ics2, spec_coef1, spec_coef2, hDecoder->frameLength, 1, hDecoder->object_type);
+        pns_decode(ics1, ics2, spec_coef1, spec_coef2, hDecoder->frameLength, 1, hDecoder->object_type,
+            &(hDecoder->__r1), &(hDecoder->__r2));
     } else {
-        pns_decode(ics1, NULL, spec_coef1, NULL, hDecoder->frameLength, 0, hDecoder->object_type);
-        pns_decode(ics2, NULL, spec_coef2, NULL, hDecoder->frameLength, 0, hDecoder->object_type);
+        pns_decode(ics1, NULL, spec_coef1, NULL, hDecoder->frameLength, 0, hDecoder->object_type,
+            &(hDecoder->__r1), &(hDecoder->__r2));
+        pns_decode(ics2, NULL, spec_coef2, NULL, hDecoder->frameLength, 0, hDecoder->object_type,
+            &(hDecoder->__r1), &(hDecoder->__r2));
     }
 
     /* mid/side decoding */
@@ -1282,9 +1292,9 @@
     if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
         && hDecoder->sbr_alloced[hDecoder->fr_ch_ele])
     {
-        uint8_t ele = hDecoder->fr_ch_ele;
-        uint8_t ch0 = cpe->channel;
-        uint8_t ch1 = cpe->paired_channel;
+        int ele = hDecoder->fr_ch_ele;
+        int ch0 = cpe->channel;
+        int ch1 = cpe->paired_channel;
 
         /* following case can happen when forceUpSampling == 1 */
         if (hDecoder->sbr[ele] == NULL)
@@ -1299,9 +1309,9 @@
         }
 
         if (cpe->ics1.window_sequence == EIGHT_SHORT_SEQUENCE)
-            hDecoder->sbr[ele]->maxAACLine = 8*cpe->ics1.swb_offset[max(cpe->ics1.max_sfb-1, 0)];
+            hDecoder->sbr[ele]->maxAACLine = 8*min(cpe->ics1.swb_offset[max(cpe->ics1.max_sfb-1, 0)], cpe->ics1.swb_offset_max);
         else
-            hDecoder->sbr[ele]->maxAACLine = cpe->ics1.swb_offset[max(cpe->ics1.max_sfb-1, 0)];
+            hDecoder->sbr[ele]->maxAACLine = min(cpe->ics1.swb_offset[max(cpe->ics1.max_sfb-1, 0)], cpe->ics1.swb_offset_max);
 
         retval = sbrDecodeCoupleFrame(hDecoder->sbr[ele],
             hDecoder->time_out[ch0], hDecoder->time_out[ch1],
--- a/libfaad/specrec.h
+++ b/libfaad/specrec.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: specrec.h,v 1.29 2005/02/01 13:15:59 menno Exp $
+** $Id: specrec.h,v 1.30 2006/05/07 18:09:03 menno Exp $
 **/
 
 #ifndef __SPECREC_H__
--- a/libfaad/ssr.c
+++ b/libfaad/ssr.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: ssr.c,v 1.16 2005/02/01 13:15:59 menno Exp $
+** $Id: ssr.c,v 1.17 2006/05/07 18:09:03 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/ssr.h
+++ b/libfaad/ssr.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: ssr.h,v 1.16 2005/02/01 13:15:59 menno Exp $
+** $Id: ssr.h,v 1.17 2006/05/07 18:09:03 menno Exp $
 **/
 
 #ifndef __SSR_H__
--- a/libfaad/ssr_fb.c
+++ b/libfaad/ssr_fb.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: ssr_fb.c,v 1.14 2005/02/01 13:15:59 menno Exp $
+** $Id: ssr_fb.c,v 1.15 2006/05/07 18:09:03 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/ssr_ipqf.c
+++ b/libfaad/ssr_ipqf.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: ssr_ipqf.c,v 1.15 2005/02/01 13:15:59 menno Exp $
+** $Id: ssr_ipqf.c,v 1.16 2006/05/07 18:09:03 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/structs.h
+++ b/libfaad/structs.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: structs.h,v 1.43 2005/02/01 13:28:56 menno Exp $
+** $Id: structs.h,v 1.44 2006/05/07 18:09:03 menno Exp $
 **/
 
 #ifndef __STRUCTS_H__
@@ -252,6 +252,7 @@
     uint8_t scale_factor_grouping;
     uint16_t sect_sfb_offset[8][15*8];
     uint16_t swb_offset[52];
+    uint16_t swb_offset_max;
 
     uint8_t sect_cb[8][15*8];
     uint16_t sect_start[8][15*8];
@@ -456,6 +457,10 @@
 #ifdef DRM
     uint8_t error_state;
 #endif
+
+    /* RNG states */
+    uint32_t __r1;
+    uint32_t __r2;
 
     /* Program Config Element */
     uint8_t pce_set;
--- a/libfaad/syntax.c
+++ b/libfaad/syntax.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: syntax.c,v 1.83 2005/02/01 13:15:59 menno Exp $
+** $Id: syntax.c,v 1.84 2006/05/07 18:09:03 menno Exp $
 **/
 
 /*
@@ -1080,7 +1080,8 @@
             hDecoder->sbr_present_flag = 1;
 
             /* parse the SBR data */
-            hDecoder->sbr[sbr_ele]->ret = sbr_extension_data(ld, hDecoder->sbr[sbr_ele], count);
+            hDecoder->sbr[sbr_ele]->ret = sbr_extension_data(ld, hDecoder->sbr[sbr_ele], count,
+                hDecoder->postSeekResetFlag);
 
 #if 0
             if (hDecoder->sbr[sbr_ele]->ret > 0)
@@ -1678,7 +1679,7 @@
 
             /* if "faad_getbits" detects error and returns "0", "k" is never
                incremented and we cannot leave the while loop */
-            if ((ld->error != 0) || (ld->no_more_reading))
+            if (ld->error != 0)
                 return 14;
 
 #ifdef ERROR_RESILIENCE
--- a/libfaad/syntax.h
+++ b/libfaad/syntax.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: syntax.h,v 1.55 2005/02/01 13:15:59 menno Exp $
+** $Id: syntax.h,v 1.56 2006/05/07 18:09:03 menno Exp $
 **/
 
 #ifndef __SYNTAX_H__
--- a/libfaad/tns.c
+++ b/libfaad/tns.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: tns.c,v 1.36 2005/02/01 13:16:00 menno Exp $
+** $Id: tns.c,v 1.37 2006/05/07 18:09:03 menno Exp $
 **/
 
 #include "common.h"
@@ -111,11 +111,11 @@
 
             start = min(bottom, max_tns_sfb(sr_index, object_type, (ics->window_sequence == EIGHT_SHORT_SEQUENCE)));
             start = min(start, ics->max_sfb);
-            start = ics->swb_offset[start];
+            start = min(ics->swb_offset[start], ics->swb_offset_max);
 
             end = min(top, max_tns_sfb(sr_index, object_type, (ics->window_sequence == EIGHT_SHORT_SEQUENCE)));
             end = min(end, ics->max_sfb);
-            end = ics->swb_offset[end];
+            end = min(ics->swb_offset[end], ics->swb_offset_max);
 
             size = end - start;
             if (size <= 0)
@@ -165,11 +165,11 @@
 
             start = min(bottom, max_tns_sfb(sr_index, object_type, (ics->window_sequence == EIGHT_SHORT_SEQUENCE)));
             start = min(start, ics->max_sfb);
-            start = ics->swb_offset[start];
+            start = min(ics->swb_offset[start], ics->swb_offset_max);
 
             end = min(top, max_tns_sfb(sr_index, object_type, (ics->window_sequence == EIGHT_SHORT_SEQUENCE)));
             end = min(end, ics->max_sfb);
-            end = ics->swb_offset[end];
+            end = min(ics->swb_offset[end], ics->swb_offset_max);
 
             size = end - start;
             if (size <= 0)
--- a/libfaad/tns.h
+++ b/libfaad/tns.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
 **  
 ** 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,15 +19,15 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in the
-** software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
+** Software using this code must display the following message visibly in or
+** on each copy of the software:
+** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
 ** in, for example, the about-box or help/startup screen.
 **
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: tns.h,v 1.20 2005/02/01 13:16:00 menno Exp $
+** $Id: tns.h,v 1.21 2006/05/07 18:09:03 menno Exp $
 **/
 
 #ifndef __TNS_H__