shithub: aacdec

Download patch

ref: 7272621bf3177cac339957f1a1f401b3c23f1dfa
parent: 0b79b1c3c52c4ad1535bf8429ae5b7c701c4a907
author: menno <menno>
date: Mon Feb 25 14:58:33 EST 2002

Added support for LD object type (Low Delay), only files without Error Resilience turned on can be decoded right now.

--- a/common/mp4v2/Makefile.am
+++ b/common/mp4v2/Makefile.am
@@ -1,6 +1,6 @@
-INCLUDES = -I$(top_srcdir)/include
+SUBDIRS = . test util
 
-include_HEADERS = mp4.h mpeg4ip.h systems.h
+INCLUDES = -I$(top_srcdir)/include
 
 AM_CXXFLAGS = -Wall 
 
--- a/common/mp4v2/isma.cpp
+++ b/common/mp4v2/isma.cpp
@@ -241,7 +241,7 @@
 
 	// bufferSizeDB needs to be set appropriately
 	MP4BitfieldProperty* pBufferSizeProperty = NULL;
-	pOdEsd->FindProperty("slConfigDescr.predefined", 
+	pOdEsd->FindProperty("decConfigDescr.bufferSizeDB",
 		(MP4Property**)&pBufferSizeProperty);
 	ASSERT(pBufferSizeProperty);
 	pBufferSizeProperty->SetValue(numBytes);
@@ -300,7 +300,7 @@
 
 	// bufferSizeDB needs to be set
 	pBufferSizeProperty = NULL;
-	pSceneEsd->FindProperty("slConfigDescr.predefined", 
+	pSceneEsd->FindProperty("decConfigDescr.bufferSizeDB",
 		(MP4Property**)&pBufferSizeProperty);
 	ASSERT(pBufferSizeProperty);
 	pBufferSizeProperty->SetValue(numBytes);
--- a/common/mp4v2/libmp4v2.dsp
+++ b/common/mp4v2/libmp4v2.dsp
@@ -1,484 +1,484 @@
-# Microsoft Developer Studio Project File - Name="libmp4v2" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=libmp4v2 - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "libmp4v2.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "libmp4v2.mak" CFG="libmp4v2 - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "libmp4v2 - Win32 Release" (based on "Win32 (x86) Static Library")
-!MESSAGE "libmp4v2 - Win32 Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE 
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-
-!IF  "$(CFG)" == "libmp4v2 - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-RSC=rc.exe
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ELSEIF  "$(CFG)" == "libmp4v2 - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir ""
-RSC=rc.exe
-# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ENDIF 
-
-# Begin Target
-
-# Name "libmp4v2 - Win32 Release"
-# Name "libmp4v2 - Win32 Debug"
-# Begin Group "source"
-
-# PROP Default_Filter ".c, .cpp"
-# Begin Source File
-
-SOURCE=.\atom_co64.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_cprt.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_ctts.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_dimm.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_dinf.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_dmax.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_dmed.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_dref.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_drep.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_edts.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_elst.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_esds.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_free.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_ftyp.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_hdlr.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_hinf.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_hmhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_hnti.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_iods.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_maxr.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mdat.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mdhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mdia.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mfhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_minf.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_moof.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_moov.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mp4a.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mp4s.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mp4v.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mvex.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mvhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_nmhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_nump.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_payt.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_pmax.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_root.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_rtp.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_sdp.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_smhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_snro.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stbl.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stco.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stdp.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stsc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stsd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stsh.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stss.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stsz.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stts.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tfhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tims.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tkhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tmax.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tmin.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tpyl.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_traf.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_trak.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tref.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_treftype.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_trex.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_trpy.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_trun.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tsro.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_udta.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_url.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_urn.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_vmhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\descriptors.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\isma.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4atom.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4container.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4descriptor.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4file.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4file_io.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4property.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4track.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4util.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\ocidescriptors.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\odcommands.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\qosqualifiers.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\rtphint.cpp
-# End Source File
-# End Group
-# Begin Group "include"
-
-# PROP Default_Filter ".h"
-# Begin Source File
-
-SOURCE=.\atoms.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\descriptors.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4array.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4atom.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4common.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4container.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4descriptor.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4file.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4property.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4track.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4util.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ocidescriptors.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\odcommands.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\qosqualifiers.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\rtphint.h
-# End Source File
-# End Group
-# End Target
-# End Project
+# Microsoft Developer Studio Project File - Name="libmp4v2" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=libmp4v2 - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "libmp4v2.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "libmp4v2.mak" CFG="libmp4v2 - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "libmp4v2 - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "libmp4v2 - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE 
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+
+!IF  "$(CFG)" == "libmp4v2 - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+RSC=rc.exe
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ELSEIF  "$(CFG)" == "libmp4v2 - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+RSC=rc.exe
+# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ENDIF 
+
+# Begin Target
+
+# Name "libmp4v2 - Win32 Release"
+# Name "libmp4v2 - Win32 Debug"
+# Begin Group "source"
+
+# PROP Default_Filter ".c, .cpp"
+# Begin Source File
+
+SOURCE=.\atom_co64.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_cprt.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_ctts.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_dimm.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_dinf.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_dmax.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_dmed.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_dref.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_drep.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_edts.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_elst.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_esds.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_free.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_ftyp.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_hdlr.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_hinf.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_hmhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_hnti.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_iods.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_maxr.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mdat.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mdhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mdia.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mfhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_minf.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_moof.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_moov.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mp4a.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mp4s.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mp4v.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mvex.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mvhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_nmhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_nump.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_payt.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_pmax.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_root.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_rtp.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_sdp.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_smhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_snro.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stbl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stco.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stdp.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stsc.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stsd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stsh.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stss.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stsz.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stts.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tfhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tims.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tkhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tmax.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tmin.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tpyl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_traf.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_trak.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tref.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_treftype.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_trex.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_trpy.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_trun.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tsro.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_udta.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_url.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_urn.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_vmhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\descriptors.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\isma.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4atom.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4container.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4descriptor.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4file.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4file_io.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4property.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4track.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4util.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ocidescriptors.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\odcommands.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\qosqualifiers.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\rtphint.cpp
+# End Source File
+# End Group
+# Begin Group "include"
+
+# PROP Default_Filter ".h"
+# Begin Source File
+
+SOURCE=.\atoms.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\descriptors.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4array.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4atom.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4common.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4container.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4descriptor.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4file.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4property.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4track.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4util.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ocidescriptors.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\odcommands.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\qosqualifiers.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\rtphint.h
+# End Source File
+# End Group
+# End Target
+# End Project
--- a/common/mp4v2/libmp4v260.dsp
+++ b/common/mp4v2/libmp4v260.dsp
@@ -1,488 +1,488 @@
-# Microsoft Developer Studio Project File - Name="libmp4v2" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=libmp4v2 - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "libmp4v260.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "libmp4v260.mak" CFG="libmp4v2 - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "libmp4v2 - Win32 Release" (based on "Win32 (x86) Static Library")
-!MESSAGE "libmp4v2 - Win32 Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "libmp4v2 - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD BASE RSC /l 0x409
-# ADD RSC /l 0x409
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ELSEIF  "$(CFG)" == "libmp4v2 - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /c
-# ADD BASE RSC /l 0x409
-# ADD RSC /l 0x409
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ENDIF 
-
-# Begin Target
-
-# Name "libmp4v2 - Win32 Release"
-# Name "libmp4v2 - Win32 Debug"
-# Begin Group "source"
-
-# PROP Default_Filter ".c, .cpp"
-# Begin Source File
-
-SOURCE=.\atom_co64.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_cprt.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_ctts.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_dimm.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_dinf.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_dmax.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_dmed.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_dref.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_drep.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_edts.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_elst.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_esds.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_free.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_ftyp.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_hdlr.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_hinf.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_hmhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_hnti.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_iods.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_maxr.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mdat.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mdhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mdia.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mfhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_minf.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_moof.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_moov.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mp4a.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mp4s.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mp4v.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mvex.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mvhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_nmhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_nump.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_payt.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_pmax.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_root.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_rtp.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_sdp.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_smhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_snro.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stbl.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stco.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stdp.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stsc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stsd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stsh.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stss.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stsz.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stts.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tfhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tims.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tkhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tmax.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tmin.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tpyl.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_traf.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_trak.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tref.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_treftype.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_trex.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_trpy.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_trun.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tsro.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_udta.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_url.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_urn.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_vmhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\descriptors.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\isma.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4atom.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4container.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4descriptor.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4file.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4file_io.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4property.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4track.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4util.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\ocidescriptors.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\odcommands.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\qosqualifiers.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\rtphint.cpp
-# End Source File
-# End Group
-# Begin Group "include"
-
-# PROP Default_Filter ".h"
-# Begin Source File
-
-SOURCE=.\atoms.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\descriptors.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4array.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4atom.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4common.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4container.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4descriptor.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4file.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4property.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4track.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4util.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ocidescriptors.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\odcommands.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\qosqualifiers.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\rtphint.h
-# End Source File
-# End Group
-# End Target
-# End Project
+# Microsoft Developer Studio Project File - Name="libmp4v2" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=libmp4v2 - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "libmp4v260.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "libmp4v260.mak" CFG="libmp4v2 - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "libmp4v2 - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "libmp4v2 - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "libmp4v2 - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD BASE RSC /l 0x409
+# ADD RSC /l 0x409
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ELSEIF  "$(CFG)" == "libmp4v2 - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /c
+# ADD BASE RSC /l 0x409
+# ADD RSC /l 0x409
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ENDIF 
+
+# Begin Target
+
+# Name "libmp4v2 - Win32 Release"
+# Name "libmp4v2 - Win32 Debug"
+# Begin Group "source"
+
+# PROP Default_Filter ".c, .cpp"
+# Begin Source File
+
+SOURCE=.\atom_co64.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_cprt.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_ctts.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_dimm.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_dinf.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_dmax.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_dmed.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_dref.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_drep.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_edts.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_elst.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_esds.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_free.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_ftyp.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_hdlr.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_hinf.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_hmhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_hnti.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_iods.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_maxr.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mdat.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mdhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mdia.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mfhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_minf.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_moof.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_moov.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mp4a.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mp4s.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mp4v.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mvex.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mvhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_nmhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_nump.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_payt.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_pmax.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_root.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_rtp.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_sdp.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_smhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_snro.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stbl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stco.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stdp.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stsc.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stsd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stsh.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stss.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stsz.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stts.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tfhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tims.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tkhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tmax.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tmin.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tpyl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_traf.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_trak.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tref.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_treftype.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_trex.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_trpy.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_trun.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tsro.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_udta.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_url.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_urn.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_vmhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\descriptors.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\isma.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4atom.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4container.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4descriptor.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4file.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4file_io.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4property.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4track.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4util.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ocidescriptors.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\odcommands.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\qosqualifiers.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\rtphint.cpp
+# End Source File
+# End Group
+# Begin Group "include"
+
+# PROP Default_Filter ".h"
+# Begin Source File
+
+SOURCE=.\atoms.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\descriptors.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4array.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4atom.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4common.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4container.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4descriptor.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4file.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4property.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4track.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4util.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ocidescriptors.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\odcommands.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\qosqualifiers.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\rtphint.h
+# End Source File
+# End Group
+# End Target
+# End Project
--- a/common/mp4v2/libmp4v2_st.dsp
+++ b/common/mp4v2/libmp4v2_st.dsp
@@ -1,484 +1,484 @@
-# Microsoft Developer Studio Project File - Name="libmp4v2_st" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=libmp4v2_st - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "libmp4v2_st.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "libmp4v2_st.mak" CFG="libmp4v2_st - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "libmp4v2_st - Win32 Release" (based on "Win32 (x86) Static Library")
-!MESSAGE "libmp4v2_st - Win32 Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE 
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-
-!IF  "$(CFG)" == "libmp4v2_st - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "ST_Release"
-# PROP Intermediate_Dir "ST_Release"
-# PROP Target_Dir ""
-RSC=rc.exe
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ELSEIF  "$(CFG)" == "libmp4v2_st - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "ST_Debug"
-# PROP Intermediate_Dir "ST_Debug"
-# PROP Target_Dir ""
-RSC=rc.exe
-# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ENDIF 
-
-# Begin Target
-
-# Name "libmp4v2_st - Win32 Release"
-# Name "libmp4v2_st - Win32 Debug"
-# Begin Group "source"
-
-# PROP Default_Filter ".c, .cpp"
-# Begin Source File
-
-SOURCE=.\atom_co64.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_cprt.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_ctts.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_dimm.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_dinf.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_dmax.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_dmed.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_dref.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_drep.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_edts.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_elst.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_esds.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_free.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_ftyp.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_hdlr.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_hinf.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_hmhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_hnti.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_iods.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_maxr.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mdat.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mdhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mdia.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mfhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_minf.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_moof.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_moov.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mp4a.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mp4s.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mp4v.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mvex.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mvhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_nmhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_nump.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_payt.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_pmax.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_root.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_rtp.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_sdp.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_smhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_snro.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stbl.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stco.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stdp.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stsc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stsd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stsh.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stss.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stsz.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stts.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tfhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tims.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tkhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tmax.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tmin.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tpyl.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_traf.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_trak.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tref.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_treftype.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_trex.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_trpy.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_trun.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tsro.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_udta.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_url.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_urn.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_vmhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\descriptors.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\isma.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4atom.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4container.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4descriptor.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4file.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4file_io.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4property.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4track.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4util.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\ocidescriptors.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\odcommands.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\qosqualifiers.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\rtphint.cpp
-# End Source File
-# End Group
-# Begin Group "include"
-
-# PROP Default_Filter ".h"
-# Begin Source File
-
-SOURCE=.\atoms.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\descriptors.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4array.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4atom.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4common.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4container.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4descriptor.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4file.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4property.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4track.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4util.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ocidescriptors.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\odcommands.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\qosqualifiers.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\rtphint.h
-# End Source File
-# End Group
-# End Target
-# End Project
+# Microsoft Developer Studio Project File - Name="libmp4v2_st" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=libmp4v2_st - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "libmp4v2_st.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "libmp4v2_st.mak" CFG="libmp4v2_st - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "libmp4v2_st - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "libmp4v2_st - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE 
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+
+!IF  "$(CFG)" == "libmp4v2_st - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ST_Release"
+# PROP Intermediate_Dir "ST_Release"
+# PROP Target_Dir ""
+RSC=rc.exe
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ELSEIF  "$(CFG)" == "libmp4v2_st - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "ST_Debug"
+# PROP Intermediate_Dir "ST_Debug"
+# PROP Target_Dir ""
+RSC=rc.exe
+# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ENDIF 
+
+# Begin Target
+
+# Name "libmp4v2_st - Win32 Release"
+# Name "libmp4v2_st - Win32 Debug"
+# Begin Group "source"
+
+# PROP Default_Filter ".c, .cpp"
+# Begin Source File
+
+SOURCE=.\atom_co64.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_cprt.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_ctts.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_dimm.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_dinf.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_dmax.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_dmed.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_dref.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_drep.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_edts.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_elst.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_esds.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_free.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_ftyp.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_hdlr.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_hinf.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_hmhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_hnti.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_iods.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_maxr.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mdat.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mdhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mdia.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mfhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_minf.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_moof.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_moov.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mp4a.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mp4s.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mp4v.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mvex.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_mvhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_nmhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_nump.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_payt.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_pmax.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_root.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_rtp.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_sdp.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_smhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_snro.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stbl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stco.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stdp.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stsc.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stsd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stsh.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stss.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stsz.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_stts.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tfhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tims.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tkhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tmax.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tmin.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tpyl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_traf.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_trak.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tref.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_treftype.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_trex.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_trpy.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_trun.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_tsro.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_udta.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_url.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_urn.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\atom_vmhd.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\descriptors.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\isma.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4atom.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4container.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4descriptor.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4file.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4file_io.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4property.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4track.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4util.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ocidescriptors.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\odcommands.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\qosqualifiers.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\rtphint.cpp
+# End Source File
+# End Group
+# Begin Group "include"
+
+# PROP Default_Filter ".h"
+# Begin Source File
+
+SOURCE=.\atoms.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\descriptors.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4array.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4atom.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4common.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4container.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4descriptor.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4file.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4property.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4track.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mp4util.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ocidescriptors.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\odcommands.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\qosqualifiers.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\rtphint.h
+# End Source File
+# End Group
+# End Target
+# End Project
--- a/common/mp4v2/libmp4v2_st60.dsp
+++ b/common/mp4v2/libmp4v2_st60.dsp
@@ -41,7 +41,7 @@
 # PROP Intermediate_Dir "ST_Release"
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "..\..\include" /I ".\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
 # ADD BASE RSC /l 0x409
 # ADD RSC /l 0x409
 BSC32=bscmake.exe
@@ -64,7 +64,7 @@
 # PROP Intermediate_Dir "ST_Debug"
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /Z7 /Od /I "..\..\include" /I ".\\" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
 # ADD BASE RSC /l 0x409
 # ADD RSC /l 0x409
 BSC32=bscmake.exe
--- a/common/mp4v2/mp4.cpp
+++ b/common/mp4v2/mp4.cpp
@@ -492,7 +492,7 @@
 {
 	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
 		try {
-			return ((MP4File*)hFile)->AddTrack(type);
+			return ((MP4File*)hFile)->AddSystemsTrack(type);
 		}
 		catch (MP4Error* e) {
 			PRINT_ERROR(e);
@@ -610,11 +610,13 @@
 }
 
 extern "C" u_int32_t MP4GetNumberOfTracks(
-	MP4FileHandle hFile, const char* type)
+	MP4FileHandle hFile, 
+	const char* type,
+	u_int8_t subType)
 {
 	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
 		try {
-			return ((MP4File*)hFile)->GetNumberOfTracks(type);
+			return ((MP4File*)hFile)->GetNumberOfTracks(type, subType);
 		}
 		catch (MP4Error* e) {
 			PRINT_ERROR(e);
@@ -625,11 +627,14 @@
 }
 
 extern "C" MP4TrackId MP4FindTrackId(
-	MP4FileHandle hFile, u_int16_t index, const char* type)
+	MP4FileHandle hFile, 
+	u_int16_t index, 
+	const char* type,
+	u_int8_t subType)
 {
 	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
 		try {
-			return ((MP4File*)hFile)->FindTrackId(index, type);
+			return ((MP4File*)hFile)->FindTrackId(index, type, subType);
 		}
 		catch (MP4Error* e) {
 			PRINT_ERROR(e);
--- a/common/mp4v2/mp4.h
+++ b/common/mp4v2/mp4.h
@@ -107,6 +107,7 @@
 #define MP4_MPEG2_AAC_AUDIO_TYPE		MP4_MPEG2_AAC_MAIN_AUDIO_TYPE
 #define MP4_MPEG4_AUDIO_TYPE			0x40
 #define MP4_PRIVATE_AUDIO_TYPE			0xC0
+#define MP4_PCM16_AUDIO_TYPE			0xD0	/* a private definition */
 
 /* MP4 Video track types - see MP4AddVideoTrack() */
 #define MP4_INVALID_VIDEO_TYPE			0x00
@@ -121,6 +122,7 @@
 #define MP4_MPEG4_VIDEO_TYPE			0x20
 #define MP4_JPEG_VIDEO_TYPE				0x6C
 #define MP4_PRIVATE_VIDEO_TYPE			0xC1
+#define MP4_YUV12_VIDEO_TYPE			0xD1	/* a private definition */
 
 
 /* MP4 API declarations */
@@ -146,7 +148,7 @@
 bool MP4Close(MP4FileHandle hFile);
 
 bool MP4Optimize(const char* existingFileName, 
-	const char* newFileName, 
+	const char* newFileName DEFAULT(NULL), 
 	u_int32_t verbosity DEFAULT(0));
 
 bool MP4Dump(MP4FileHandle hFile, 
@@ -245,13 +247,19 @@
 	MP4FileHandle hFile, MP4TrackId trackId);
 
 u_int32_t MP4GetNumberOfTracks(
-	MP4FileHandle hFile, const char* type DEFAULT(NULL));
+	MP4FileHandle hFile, 
+	const char* type DEFAULT(NULL),
+	u_int8_t subType DEFAULT(0));
 
 MP4TrackId MP4FindTrackId(
-	MP4FileHandle hFile, u_int16_t index, const char* type DEFAULT(NULL));
+	MP4FileHandle hFile, 
+	u_int16_t index, 
+	const char* type DEFAULT(NULL),
+	u_int8_t subType DEFAULT(0));
 
 u_int16_t MP4FindTrackIndex(
-	MP4FileHandle hFile, MP4TrackId trackId);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId);
 
 /* track properties */
 
--- a/common/mp4v2/mp4file.cpp
+++ b/common/mp4v2/mp4file.cpp
@@ -198,7 +198,14 @@
 
 	// now switch over to writing the new file
 	MP4Free(m_fileName);
-	m_fileName = MP4Stralloc(newFileName);
+
+	// create a temporary file if necessary
+	if (newFileName == NULL) {
+		m_fileName = MP4Stralloc(TempFileName());
+	} else {
+		m_fileName = MP4Stralloc(newFileName);
+	}
+
 	FILE* pReadFile = m_pFile;
 	m_pFile = NULL;
 	m_mode = 'w';
@@ -221,6 +228,11 @@
 	fclose(m_pFile);
 	m_pFile = NULL;
 	fclose(pReadFile);
+
+	// move temporary file into place
+	if (newFileName == NULL) {
+		Rename(m_fileName, orgFileName);
+	}
 }
 
 void MP4File::RewriteMdat(FILE* pReadFile, FILE* pWriteFile)
@@ -305,7 +317,33 @@
 void MP4File::Open(const char* fmode)
 {
 	ASSERT(m_pFile == NULL);
+
+#ifdef O_LARGEFILE
+	// UGH! fopen doesn't open a file in 64-bit mode, period.
+	// So we need to use open() and then fdopen()
+	int fd;
+	int flags = O_LARGEFILE;
+
+	if (strchr(fmode, '+')) {
+		flags |= O_CREAT | O_RDWR;
+		if (fmode[0] == 'w') {
+			flags |= O_TRUNC;
+		}
+	} else {
+		if (fmode[0] == 'w') {
+			flags |= O_CREAT | O_TRUNC | O_WRONLY;
+		} else {
+			flags |= O_RDONLY;
+		}
+	}
+	fd = open(m_fileName, flags, 0666); 
+
+	if (fd >= 0) {
+		m_pFile = fdopen(fd, fmode);
+	}
+#else
 	m_pFile = fopen(m_fileName, fmode);
+#endif
 	if (m_pFile == NULL) {
 		throw new MP4Error(errno, "failed", "MP4Open");
 	}
@@ -481,6 +519,50 @@
 	m_pFile = NULL;
 }
 
+const char* MP4File::TempFileName()
+{
+	// there are so many attempts in libc to get this right
+	// that for portablity reasons, it's best just to roll our own
+#ifndef _WIN32
+	static char tempFileName[64];
+	u_int32_t i;
+	for (i = getpid(); i < 0xFFFFFFFF; i++) {
+		sprintf(tempFileName, "./tmp%u.mp4", i);
+		if (access(tempFileName, F_OK) != 0) {
+			break;
+		}
+	}
+	if (i == 0xFFFFFFFF) {
+		throw new MP4Error("can't create temporary file", "TempFileName");
+	}
+#else
+	static char tempFileName[MAX_PATH + 3];
+	GetTempFileName(".", // dir. for temp. files 
+					"mp4",                // temp. filename prefix 
+					0,                    // create unique name 
+					tempFileName);        // buffer for name 
+#endif
+
+	return tempFileName;
+}
+
+void MP4File::Rename(const char* oldFileName, const char* newFileName)
+{
+	int rc;
+
+#ifdef _WIN32
+	rc = remove(newFileName);
+	if (rc == 0) {
+		rc = rename(oldFileName, newFileName);
+	}
+#else
+	rc = rename(oldFileName, newFileName);
+#endif
+	if (rc != 0) {
+		throw new MP4Error(errno, "can't overwrite existing file", "Rename");
+	}
+}
+
 void MP4File::ProtectWriteOperation(char* where)
 {
 	if (m_mode == 'r') {
@@ -757,6 +839,13 @@
 	// set track type
 	const char* normType = MP4Track::NormalizeTrackType(type);
 
+	// sanity check for user defined types
+	if (strlen(normType) > 4) {
+		VERBOSE_WARNING(m_verbosity, 
+			printf("AddTrack: type truncated to four characters\n"));
+		// StringProperty::SetValue() will do the actual truncation
+	}
+
 	MP4StringProperty* pStringProperty = NULL;
 	pTrakAtom->FindProperty(
 		"trak.mdia.hdlr.handlerType", (MP4Property**)&pStringProperty);
@@ -908,7 +997,7 @@
 	for (u_int32_t i = 0; i < pCountProperty->GetValue(); i++) {
 		if (refTrackId == pTrackIdProperty->GetValue(i)) {
 			pTrackIdProperty->DeleteValue(i);
-			pCountProperty->SetValue(pCountProperty->GetValue() - 1);
+			pCountProperty->IncrementValue(-1);
 		}
 	}
 }
@@ -944,6 +1033,8 @@
 {
 	const char* normType = MP4Track::NormalizeTrackType(type); 
 
+	// TBD if user type, fix name to four chars, and warn
+
 	MP4TrackId trackId = AddTrack(type, MP4_MSECS_TIME_SCALE);
 
 	InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "nmhd", 0);
@@ -1155,21 +1246,33 @@
 	delete pTrakAtom;
 }
 
-u_int32_t MP4File::GetNumberOfTracks(const char* type)
+u_int32_t MP4File::GetNumberOfTracks(const char* type, u_int8_t subType)
 {
 	if (type == NULL) {
 		return m_pTracks.Size();
-	} else {
-		u_int16_t typeSeen = 0;
-		const char* normType = MP4Track::NormalizeTrackType(type);
+	} 
 
-		for (u_int16_t i = 0; i < m_pTracks.Size(); i++) {
-			if (!strcmp(normType, m_pTracks[i]->GetType())) {
-				typeSeen++;
+	u_int16_t typeSeen = 0;
+	const char* normType = MP4Track::NormalizeTrackType(type);
+
+	for (u_int16_t i = 0; i < m_pTracks.Size(); i++) {
+		if (!strcmp(normType, m_pTracks[i]->GetType())) {
+			if (subType) {
+				if (normType == MP4_AUDIO_TRACK_TYPE) {
+					if (subType != GetTrackAudioType(m_pTracks[i]->GetId())) {
+						continue;
+					}
+				} else if (normType == MP4_VIDEO_TRACK_TYPE) {
+					if (subType != GetTrackVideoType(m_pTracks[i]->GetId())) {
+						continue;
+					}
+				} 
+				// else unknown subtype, ignore it
 			}
+			typeSeen++;
 		}
-		return typeSeen;
 	}
+	return typeSeen;
 }
 
 MP4TrackId MP4File::AllocTrackId()
@@ -1198,25 +1301,41 @@
 	return trackId;
 }
 
-MP4TrackId MP4File::FindTrackId(u_int16_t trackIndex, const char* type)
+MP4TrackId MP4File::FindTrackId(
+	u_int16_t trackIndex, const char* type, u_int8_t subType)
 {
 	if (type == NULL) {
 		return m_pTracks[trackIndex]->GetId();
-	} else {
-		u_int16_t typeSeen = 0;
-		const char* normType = MP4Track::NormalizeTrackType(type);
+	} 
 
-		for (u_int16_t i = 0; i < m_pTracks.Size(); i++) {
-			if (!strcmp(normType, m_pTracks[i]->GetType())) {
-				if (trackIndex == typeSeen) {
-					return m_pTracks[i]->GetId();
-				}
-				typeSeen++;
+	u_int16_t typeSeen = 0;
+	const char* normType = MP4Track::NormalizeTrackType(type);
+
+	for (u_int16_t i = 0; i < m_pTracks.Size(); i++) {
+		if (!strcmp(normType, m_pTracks[i]->GetType())) {
+			if (subType) {
+				if (normType == MP4_AUDIO_TRACK_TYPE) {
+					if (subType != GetTrackAudioType(m_pTracks[i]->GetId())) {
+						continue;
+					}
+				} else if (normType == MP4_VIDEO_TRACK_TYPE) {
+					if (subType != GetTrackVideoType(m_pTracks[i]->GetId())) {
+						continue;
+					}
+				} 
+				// else unknown subtype, ignore it
 			}
+
+			if (trackIndex == typeSeen) {
+				return m_pTracks[i]->GetId();
+			}
+
+			typeSeen++;
 		}
-		throw new MP4Error("Track index doesn't exist", "FindTrackId"); 
-		return MP4_INVALID_TRACK_ID; // satisfy MS compiler
 	}
+
+	throw new MP4Error("Track index doesn't exist", "FindTrackId"); 
+	return MP4_INVALID_TRACK_ID; // satisfy MS compiler
 }
 
 u_int16_t MP4File::FindTrackIndex(MP4TrackId trackId)
--- a/common/mp4v2/mp4file.h
+++ b/common/mp4v2/mp4file.h
@@ -40,7 +40,7 @@
 	void Create(const char* fileName, bool use64bits);
 	void Modify(const char* fileName);
 	void Optimize(const char* orgFileName, 
-		const char* newFileName);
+		const char* newFileName = NULL);
 	void MakeIsmaCompliant(bool addIsmaComplianceSdp = true);
 	void Dump(FILE* pDumpFile = NULL, bool dumpImplicits = false);
 	void Close();
@@ -104,10 +104,11 @@
 	MP4TrackId AddTrack(const char* type, u_int32_t timeScale = 1);
 	void DeleteTrack(MP4TrackId trackId);
 
-	u_int32_t GetNumberOfTracks(const char* type = NULL);
+	u_int32_t GetNumberOfTracks(const char* type = NULL, u_int8_t subType = 0);
 
 	MP4TrackId AllocTrackId();
-	MP4TrackId FindTrackId(u_int16_t trackIndex, const char* type = NULL);
+	MP4TrackId FindTrackId(u_int16_t trackIndex, 
+		const char* type = NULL, u_int8_t subType = 0);
 	u_int16_t FindTrackIndex(MP4TrackId trackId);
 	u_int16_t FindTrakAtomIndex(MP4TrackId trackId);
 
@@ -421,6 +422,9 @@
 	void FinishWrite();
 	void CacheProperties();
 	void RewriteMdat(FILE* pReadFile, FILE* pWriteFile);
+
+	const char* TempFileName();
+	void Rename(const char* existingFileName, const char* newFileName);
 
 	void ProtectWriteOperation(char* where);
 
--- a/common/mp4v2/mp4property.h
+++ b/common/mp4v2/mp4property.h
@@ -150,7 +150,7 @@
 		void DeleteValue(u_int32_t index) { \
 			m_values.Delete(index); \
 		} \
-		void IncrementValue(u_int32_t increment = 1, u_int32_t index = 0) { \
+		void IncrementValue(int32_t increment = 1, u_int32_t index = 0) { \
 			m_values[index] += increment; \
 		} \
 		void Read(MP4File* pFile, u_int32_t index = 0) { \
--- a/common/mp4v2/mpeg4ip.h
+++ b/common/mp4v2/mpeg4ip.h
@@ -24,7 +24,7 @@
 
 /* project wide applicable stuff here */
 
-#include "systems.h"
+#include <systems.h>
 
 #ifndef FALSE
 #define FALSE 0
--- a/common/mp4v2/systems.h
+++ b/common/mp4v2/systems.h
@@ -20,18 +20,17 @@
  *		Bill May		[email protected]
  */
 
+#ifndef __SYSTEMS_H__
+#define __SYSTEMS_H__
+
 #ifdef _WIN32
 #define HAVE_IN_PORT_T
 #define HAVE_SOCKLEN_T
-#include "win32_ver.h"
+#include <win32_ver.h>
 #else
-#ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
-#endif
 
-#ifndef __SYSTEMS_H__
-#define __SYSTEMS_H__
 
 
 
@@ -142,6 +141,8 @@
 #include <netinet/in.h>
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
 #include <syslog.h>
 #include <string.h>
 #include <ctype.h>
@@ -215,4 +216,9 @@
 #ifndef MAX
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 #endif
+
+#ifndef INADDR_NONE
+#define INADDR_NONE (-1)
+#endif
+
 #endif /* __SYSTEMS_H__ */
--- a/common/mp4v2/win32_ver.h
+++ b/common/mp4v2/win32_ver.h
@@ -1,2 +1,2 @@
 #define PACKAGE "mpeg4ip"
-#define VERSION "0.9.2.8"
+#define VERSION "0.9.2.16"
--- a/frontend/main.c
+++ b/frontend/main.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: main.c,v 1.13 2002/02/18 10:01:05 menno Exp $
+** $Id: main.c,v 1.14 2002/02/25 19:58:32 menno Exp $
 **/
 
 #ifdef _WIN32
@@ -138,7 +138,11 @@
     fprintf(stderr, "        3:  32 bit PCM data.\n");
     fprintf(stderr, "        4:  32 bit floats.\n");
     fprintf(stderr, " -s X  Force the samplerate to X (for RAW files).\n");
-    fprintf(stderr, " -l    Use Long Term Prediction (for RAW files).\n");
+    fprintf(stderr, " -l X  Set object type. Supported object types:\n");
+    fprintf(stderr, "        0:  Main object type.\n");
+    fprintf(stderr, "        1:  LC (Low Complexity) object type.\n");
+    fprintf(stderr, "        3:  LTP (Long Term Prediction) object type.\n");
+    fprintf(stderr, "        23: LD (Low Delay) object type.\n");
     fprintf(stderr, " -w    Write output to stdio instead of a file.\n");
     fprintf(stderr, "Example:\n");
     fprintf(stderr, "       faad infile.aac\n");
@@ -148,9 +152,8 @@
     return;
 }
 
-
 int decodeAACfile(char *aacfile, char *sndfile, int to_stdout,
-                  int def_srate, int use_ltp, int outputFormat, int fileType)
+                  int def_srate, int object_type, int outputFormat, int fileType)
 {
     int tagsize;
     unsigned long samplerate;
@@ -196,8 +199,7 @@
     config = faacDecGetCurrentConfiguration(hDecoder);
     if (def_srate)
         config->defSampleRate = def_srate;
-    if (use_ltp)
-        config->defObjectType = LTP;
+    config->defObjectType = object_type;
     config->outputFormat = outputFormat;
 
     faacDecSetConfiguration(hDecoder, config);
@@ -277,7 +279,8 @@
 
     fclose(infile);
 
-    close_audio_file(aufile);
+    if (!first_time)
+        close_audio_file(aufile);
 
     END_BUFF
 
@@ -288,11 +291,11 @@
 {
     /* find AAC track */
     int i, rc;
-	int numTracks = MP4GetNumberOfTracks(infile, NULL);
+	int numTracks = MP4GetNumberOfTracks(infile, NULL, /* subType */ 0);
 
 	for (i = 0; i < numTracks; i++)
     {
-        MP4TrackId trackId = MP4FindTrackId(infile, i, NULL);
+        MP4TrackId trackId = MP4FindTrackId(infile, i, NULL, /* subType */ 0);
         const char* trackType = MP4GetTrackType(infile, trackId);
 
         if (!strcmp(trackType, MP4_AUDIO_TRACK_TYPE))
@@ -457,7 +460,8 @@
 
     MP4Close(infile);
 
-    close_audio_file(aufile);
+    if (!first_time)
+        close_audio_file(aufile);
 
     return frameInfo.error;
 }
@@ -481,7 +485,7 @@
 {
     int result;
     int writeToStdio = 0;
-    int use_ltp = 0;
+    int object_type = LC;
     int def_srate = 0;
     int format = 1;
     int outputFormat = FAAD_FMT_16BIT;
@@ -492,8 +496,6 @@
     char aacFileName[255];
     char audioFileName[255];
 
-    FILE *infile;
-
 /* System dependant types */
 #ifdef _WIN32
     long begin, end;
@@ -515,12 +517,12 @@
             { "format",     0, 0, 'f' },
             { "bits",       0, 0, 'b' },
             { "samplerate", 0, 0, 's' },
-            { "ltp",        0, 0, 'l' },
+            { "objecttype", 0, 0, 'l' },
             { "stdio",      0, 0, 'w' },
             { "help",       0, 0, 'h' }
         };
 
-        c = getopt_long(argc, argv, "o:s:f:b:lwh",
+        c = getopt_long(argc, argv, "o:s:f:b:l:wh",
             long_options, &option_index);
 
         if (c == -1)
@@ -568,7 +570,21 @@
             }
             break;
         case 'l':
-            use_ltp = 1;
+            if (optarg) {
+                char dr[10];
+                if (sscanf(optarg, "%s", dr) < 1) {
+                    object_type = LC; /* default */
+                } else {
+                    object_type = atoi(dr);
+                    if ((object_type != LC) &&
+                        (object_type != MAIN) &&
+                        (object_type != LTP) &&
+                        (object_type != LD))
+                    {
+                        showHelp = 1;
+                    }
+                }
+            }
             break;
         case 'w':
             writeToStdio = 1;
@@ -624,7 +640,7 @@
             outputFormat, format);
     } else {
         result = decodeAACfile(aacFileName, audioFileName, writeToStdio,
-            def_srate, use_ltp, outputFormat, format);
+            def_srate, object_type, outputFormat, format);
     }
 
 
--- a/include/faad.h
+++ b/include/faad.h
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: faad.h,v 1.4 2002/02/18 10:01:05 menno Exp $
+** $Id: faad.h,v 1.5 2002/02/25 19:58:33 menno Exp $
 **/
 
 #ifndef __AACDEC_H__
@@ -42,6 +42,7 @@
 #define LC   1
 #define SSR  2
 #define LTP  3
+#define LD   23
 
 #define FAAD_FMT_16BIT 1
 #define FAAD_FMT_24BIT 2
--- a/libfaad/data.c
+++ b/libfaad/data.c
@@ -16,23 +16,28 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: data.c,v 1.2 2002/02/18 10:01:05 menno Exp $
+** $Id: data.c,v 1.3 2002/02/25 19:58:33 menno Exp $
 **/
 
 #include "common.h"
 #include "data.h"
 
-extern uint8_t num_swb_long_window[] =
+extern uint8_t num_swb_512_window[] =
 {
+    0, 0, 0, 35, 35, 36, 30, 30, 0, 0, 0, 0
+};
+
+extern uint8_t num_swb_1024_window[] =
+{
     41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40
 };
 
-extern uint8_t num_swb_short_window[] =
+extern uint8_t num_swb_128_window[] =
 {
     12, 12, 12, 14, 14, 14, 15, 15, 15, 15, 15, 15
 };
 
-static uint16_t swb_offset_long_96[] =
+static uint16_t swb_offset_1024_96[] =
 {
     0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56,
     64, 72, 80, 88, 96, 108, 120, 132, 144, 156, 172, 188, 212, 240,
@@ -39,12 +44,12 @@
     276, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024
 };
 
-static uint16_t swb_offset_short_96[] =
+static uint16_t swb_offset_128_96[] =
 {
     0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128
 };
 
-static uint16_t swb_offset_long_64[] =
+static uint16_t swb_offset_1024_64[] =
 {
     0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56,
     64, 72, 80, 88, 100, 112, 124, 140, 156, 172, 192, 216, 240, 268,
@@ -52,13 +57,13 @@
     864, 904, 944, 984, 1024
 };
 
-static uint16_t swb_offset_short_64[] =
+static uint16_t swb_offset_128_64[] =
 {
     0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128
 };
 
 
-static uint16_t swb_offset_long_48[] =
+static uint16_t swb_offset_1024_48[] =
 {
     0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72,
     80, 88, 96, 108, 120, 132, 144, 160, 176, 196, 216, 240, 264, 292,
@@ -66,21 +71,35 @@
     768, 800, 832, 864, 896, 928, 1024
 };
 
-static uint16_t swb_offset_short_48[] =
+static uint16_t swb_offset_512_48[] =
 {
+    0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 68, 76, 84,
+    92, 100, 112, 124, 136, 148, 164, 184, 208, 236, 268, 300, 332, 364, 396,
+    428, 460, 512
+};
+
+static uint16_t swb_offset_128_48[] =
+{
     0, 4, 8, 12, 16, 20, 28, 36, 44, 56, 68, 80, 96, 112, 128
 };
 
-static uint16_t swb_offset_long_32[] =
+static uint16_t swb_offset_1024_32[] =
 {
-    0, 4,  8,  12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72,
+    0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72,
     80, 88, 96, 108, 120, 132, 144, 160, 176, 196, 216, 240, 264, 292,
     320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 672, 704, 736,
     768, 800, 832, 864, 896, 928, 960, 992, 1024
 };
 
-static uint16_t swb_offset_long_24[] =
+static uint16_t swb_offset_512_32[] =
 {
+    0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 64, 72, 80,
+    88, 96, 108, 120, 132, 144, 160, 176, 192, 212, 236, 260, 288, 320, 352,
+    384, 416, 448, 480, 512
+};
+
+static uint16_t swb_offset_1024_24[] =
+{
     0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 52, 60, 68,
     76, 84, 92, 100, 108, 116, 124, 136, 148, 160, 172, 188, 204, 220,
     240, 260, 284, 308, 336, 364, 396, 432, 468, 508, 552, 600, 652, 704,
@@ -87,12 +106,19 @@
     768, 832, 896, 960, 1024
 };
 
-static uint16_t swb_offset_short_24[] =
+static uint16_t swb_offset_512_24[] =
 {
+    0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 52, 60, 68,
+    80, 92, 104, 120, 140, 164, 192, 224, 256, 288, 320, 352, 384, 416,
+    448, 480, 512
+};
+
+static uint16_t swb_offset_128_24[] =
+{
     0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 64, 76, 92, 108, 128
 };
 
-static uint16_t swb_offset_long_16[] =
+static uint16_t swb_offset_1024_16[] =
 {
     0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 100, 112, 124,
     136, 148, 160, 172, 184, 196, 212, 228, 244, 260, 280, 300, 320, 344,
@@ -99,12 +125,12 @@
     368, 396, 424, 456, 492, 532, 572, 616, 664, 716, 772, 832, 896, 960, 1024
 };
 
-static uint16_t swb_offset_short_16[] =
+static uint16_t swb_offset_128_16[] =
 {
     0, 4, 8, 12, 16, 20, 24, 28, 32, 40, 48, 60, 72, 88, 108, 128
 };
 
-static uint16_t swb_offset_long_8[] =
+static uint16_t swb_offset_1024_8[] =
 {
     0, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 172,
     188, 204, 220, 236, 252, 268, 288, 308, 328, 348, 372, 396, 420, 448,
@@ -111,41 +137,57 @@
     476, 508, 544, 580, 620, 664, 712, 764, 820, 880, 944, 1024
 };
 
-static uint16_t swb_offset_short_8[] =
+static uint16_t swb_offset_128_8[] =
 {
     0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 60, 72, 88, 108, 128
 };
 
-extern uint16_t *swb_offset_long_window[] =
+extern uint16_t *swb_offset_1024_window[] =
 {
-    swb_offset_long_96,      /* 96000 */
-    swb_offset_long_96,      /* 88200 */
-    swb_offset_long_64,      /* 64000 */
-    swb_offset_long_48,      /* 48000 */
-    swb_offset_long_48,      /* 44100 */
-    swb_offset_long_32,      /* 32000 */
-    swb_offset_long_24,      /* 24000 */
-    swb_offset_long_24,      /* 22050 */
-    swb_offset_long_16,      /* 16000 */
-    swb_offset_long_16,      /* 12000 */
-    swb_offset_long_16,      /* 11025 */
-    swb_offset_long_8        /* 8000  */
+    swb_offset_1024_96,      /* 96000 */
+    swb_offset_1024_96,      /* 88200 */
+    swb_offset_1024_64,      /* 64000 */
+    swb_offset_1024_48,      /* 48000 */
+    swb_offset_1024_48,      /* 44100 */
+    swb_offset_1024_32,      /* 32000 */
+    swb_offset_1024_24,      /* 24000 */
+    swb_offset_1024_24,      /* 22050 */
+    swb_offset_1024_16,      /* 16000 */
+    swb_offset_1024_16,      /* 12000 */
+    swb_offset_1024_16,      /* 11025 */
+    swb_offset_1024_8        /* 8000  */
 };
 
-extern uint16_t *swb_offset_short_window[] =
+extern uint16_t *swb_offset_512_window[] =
 {
-    swb_offset_short_96,      /* 96000 */
-    swb_offset_short_96,      /* 88200 */
-    swb_offset_short_64,      /* 64000 */
-    swb_offset_short_48,      /* 48000 */
-    swb_offset_short_48,      /* 44100 */
-    swb_offset_short_48,      /* 32000 */
-    swb_offset_short_24,      /* 24000 */
-    swb_offset_short_24,      /* 22050 */
-    swb_offset_short_16,      /* 16000 */
-    swb_offset_short_16,      /* 12000 */
-    swb_offset_short_16,      /* 11025 */
-    swb_offset_short_8        /* 8000  */
+    0,                       /* 96000 */
+    0,                       /* 88200 */
+    0,                       /* 64000 */
+    swb_offset_512_48,       /* 48000 */
+    swb_offset_512_48,       /* 44100 */
+    swb_offset_512_32,       /* 32000 */
+    swb_offset_512_24,       /* 24000 */
+    swb_offset_512_24,       /* 22050 */
+    0,                       /* 16000 */
+    0,                       /* 12000 */
+    0,                       /* 11025 */
+    0                        /* 8000  */
+};
+
+extern uint16_t *swb_offset_128_window[] =
+{
+    swb_offset_128_96,       /* 96000 */
+    swb_offset_128_96,       /* 88200 */
+    swb_offset_128_64,       /* 64000 */
+    swb_offset_128_48,       /* 48000 */
+    swb_offset_128_48,       /* 44100 */
+    swb_offset_128_48,       /* 32000 */
+    swb_offset_128_24,       /* 24000 */
+    swb_offset_128_24,       /* 22050 */
+    swb_offset_128_16,       /* 16000 */
+    swb_offset_128_16,       /* 12000 */
+    swb_offset_128_16,       /* 11025 */
+    swb_offset_128_8         /* 8000  */
 };
 
 extern uint8_t pred_sfb_max[] =
--- a/libfaad/data.h
+++ b/libfaad/data.h
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: data.h,v 1.2 2002/02/18 10:01:05 menno Exp $
+** $Id: data.h,v 1.3 2002/02/25 19:58:33 menno Exp $
 **/
 
 #ifndef __DATA_H__
@@ -26,10 +26,12 @@
 extern "C" {
 #endif
 
-extern uint8_t num_swb_long_window[];
-extern uint8_t num_swb_short_window[];
-extern uint16_t *swb_offset_long_window[];
-extern uint16_t *swb_offset_short_window[];
+extern uint8_t num_swb_1024_window[];
+extern uint8_t num_swb_512_window[];
+extern uint8_t num_swb_128_window[];
+extern uint16_t *swb_offset_1024_window[];
+extern uint16_t *swb_offset_512_window[];
+extern uint16_t *swb_offset_128_window[];
 extern uint8_t pred_sfb_max[];
 extern uint32_t sample_rates[];
 
--- a/libfaad/decoder.c
+++ b/libfaad/decoder.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: decoder.c,v 1.9 2002/02/20 13:05:57 menno Exp $
+** $Id: decoder.c,v 1.10 2002/02/25 19:58:33 menno Exp $
 **/
 
 #include <stdlib.h>
@@ -55,6 +55,7 @@
         return NULL;
 
     memset(hDecoder, 0, sizeof(faacDecStruct));
+    memset(&hDecoder->fb, 0, sizeof(fb_info));
 
     hDecoder->config.outputFormat  = FAAD_FMT_16BIT;
     hDecoder->config.defObjectType = MAIN;
@@ -68,6 +69,7 @@
     for (i = 0; i < MAX_CHANNELS; i++)
     {
         hDecoder->window_shape_prev[i] = 0;
+        hDecoder->ltp_lag[i] = 0;
         hDecoder->time_state[i] = NULL;
         hDecoder->time_out[i] = NULL;
         hDecoder->pred_stat[i] = NULL;
@@ -126,6 +128,7 @@
 int32_t FAADAPI faacDecInit(faacDecHandle hDecoder, uint8_t *buffer,
                         uint32_t *samplerate, uint8_t *channels)
 {
+    uint32_t bits = 0;
     bitfile ld;
     adif_header adif;
     adts_header adts;
@@ -132,6 +135,8 @@
 
     hDecoder->sf_index = get_sr_index(hDecoder->config.defSampleRate);
     hDecoder->object_type = hDecoder->config.defObjectType;
+    *samplerate = sample_rates[hDecoder->sf_index];
+    *channels = 2;
 
     if (buffer != NULL)
     {
@@ -151,7 +156,7 @@
             *samplerate = sample_rates[hDecoder->sf_index];
             *channels = adif.pce.channels;
 
-            return bit2byte(faad_get_processed_bits(&ld));
+            bits = bit2byte(faad_get_processed_bits(&ld));
 
         /* Check if an ADTS header is present */
         } else if (faad_showbits(&ld, 12) == 0xfff) {
@@ -165,21 +170,16 @@
             *samplerate = sample_rates[hDecoder->sf_index];
             *channels = (adts.channel_configuration > 6) ?
                 2 : adts.channel_configuration;
-
-            return 0;
         }
     }
 
-    *samplerate = sample_rates[hDecoder->sf_index];
-    *channels = 2;
-
-    return 0;
+    return bits;
 }
 
 /* Init the library using a DecoderSpecificInfo */
 int8_t FAADAPI faacDecInit2(faacDecHandle hDecoder, uint8_t *pBuffer,
-                         uint32_t SizeOfDecoderSpecificInfo,
-                         uint32_t *samplerate, uint8_t *channels)
+                            uint32_t SizeOfDecoderSpecificInfo,
+                            uint32_t *samplerate, uint8_t *channels)
 {
     int8_t rc;
 
@@ -197,11 +197,13 @@
 
     rc = AudioSpecificConfig(pBuffer, samplerate, channels,
         &hDecoder->sf_index, &hDecoder->object_type);
-    hDecoder->object_type--; /* For AAC differs from MPEG-4 */
+    if (hDecoder->object_type != LD)
+        hDecoder->object_type--; /* For AAC differs from MPEG-4 */
     if (rc != 0)
     {
         return rc;
     }
+    hDecoder->channelConfiguration = *channels;
 
     return 0;
 }
@@ -225,6 +227,50 @@
     if (hDecoder) free(hDecoder);
 }
 
+#define decode_sce_lfe() \
+    spec_data[channels]   = (int16_t*)malloc(frame_len*sizeof(int16_t)); \
+    spec_coef[channels]   = (real_t*)malloc(frame_len*sizeof(real_t)); \
+ \
+    syntax_elements[ch_ele] = (element*)malloc(sizeof(element)); \
+    memset(syntax_elements[ch_ele], 0, sizeof(element)); \
+    syntax_elements[ch_ele]->ele_id  = id_syn_ele; \
+    syntax_elements[ch_ele]->channel = channels; \
+ \
+    if ((hInfo->error = single_lfe_channel_element(syntax_elements[ch_ele], \
+        ld, spec_data[channels], sf_index, object_type)) > 0) \
+    { \
+        /* to make sure everything gets deallocated */ \
+        channels++; ch_ele++; \
+        goto error; \
+    } \
+ \
+    channels++; \
+    ch_ele++;
+
+#define decode_cpe() \
+    spec_data[channels]   = (int16_t*)malloc(frame_len*sizeof(int16_t)); \
+    spec_data[channels+1] = (int16_t*)malloc(frame_len*sizeof(int16_t)); \
+    spec_coef[channels]   = (real_t*)malloc(frame_len*sizeof(real_t)); \
+    spec_coef[channels+1] = (real_t*)malloc(frame_len*sizeof(real_t)); \
+ \
+    syntax_elements[ch_ele] = (element*)malloc(sizeof(element)); \
+    memset(syntax_elements[ch_ele], 0, sizeof(element)); \
+    syntax_elements[ch_ele]->ele_id         = id_syn_ele; \
+    syntax_elements[ch_ele]->channel        = channels; \
+    syntax_elements[ch_ele]->paired_channel = channels+1; \
+ \
+    if ((hInfo->error = channel_pair_element(syntax_elements[ch_ele], \
+        ld, spec_data[channels], spec_data[channels+1], \
+        sf_index, object_type)) > 0) \
+    { \
+        /* to make sure everything gets deallocated */ \
+        channels+=2; ch_ele++; \
+        goto error; \
+    } \
+ \
+    channels += 2; \
+    ch_ele++;
+
 void* FAADAPI faacDecDecode(faacDecHandle hDecoder,
                             faacDecFrameInfo *hInfo,
                             uint8_t *buffer)
@@ -238,6 +284,7 @@
     /* local copys of globals */
     uint8_t sf_index       =  hDecoder->sf_index;
     uint8_t object_type    =  hDecoder->object_type;
+    uint8_t channelConfiguration = hDecoder->channelConfiguration;
     pred_state **pred_stat =  hDecoder->pred_stat;
     real_t **lt_pred_stat  =  hDecoder->lt_pred_stat;
 #if IQ_TABLE_SIZE
@@ -256,6 +303,7 @@
     fb_info *fb            = &hDecoder->fb;
     drc_info *drc          = &hDecoder->drc;
     uint8_t outputFormat   =  hDecoder->config.outputFormat;
+    uint16_t *ltp_lag      =  hDecoder->ltp_lag;
 
     program_config pce;
     element *syntax_elements[MAX_SYNTAX_ELEMENTS];
@@ -262,6 +310,9 @@
     int16_t *spec_data[MAX_CHANNELS];
     real_t *spec_coef[MAX_CHANNELS];
 
+    /* frame length is different for Low Delay AAC */
+    uint16_t frame_len = (object_type == LD) ? 512 : 1024;
+
     void *sample_buffer;
 
     ele = 0;
@@ -288,73 +339,105 @@
     dbg_count = 0;
 #endif
 
-    /* Table 4.4.3: raw_data_block() */
-    while ((id_syn_ele = (uint8_t)faad_getbits(ld, LEN_SE_ID
-        DEBUGVAR(1,4,"faacDecDecode(): id_syn_ele"))) != ID_END)
+    if (object_type != LD)
     {
-        switch (id_syn_ele) {
-        case ID_SCE:
-        case ID_LFE:
-            spec_data[channels]   = (int16_t*)malloc(1024*sizeof(int16_t));
-            spec_coef[channels]   = (real_t*)malloc(1024*sizeof(real_t));
-
-            syntax_elements[ch_ele] = (element*)malloc(sizeof(element));
-            memset(syntax_elements[ch_ele], 0, sizeof(element));
-            syntax_elements[ch_ele]->ele_id  = id_syn_ele;
-            syntax_elements[ch_ele]->channel = channels;
-
-            if ((hInfo->error = single_lfe_channel_element(syntax_elements[ch_ele],
-                ld, spec_data[channels], sf_index, object_type)) > 0)
-            {
-                /* to make sure everything gets deallocated */
-                channels++; ch_ele++;
+        /* Table 4.4.3: raw_data_block() */
+        while ((id_syn_ele = (uint8_t)faad_getbits(ld, LEN_SE_ID
+            DEBUGVAR(1,4,"faacDecDecode(): id_syn_ele"))) != ID_END)
+        {
+            switch (id_syn_ele) {
+            case ID_SCE:
+            case ID_LFE:
+                decode_sce_lfe();
+                break;
+            case ID_CPE:
+                decode_cpe();
+                break;
+            case ID_CCE: /* not implemented yet */
+                hInfo->error = 6;
                 goto error;
+                break;
+            case ID_DSE:
+                data_stream_element(ld);
+                break;
+            case ID_PCE:
+                if ((hInfo->error = program_config_element(&pce, ld)) > 0)
+                    goto error;
+                break;
+            case ID_FIL:
+                if ((hInfo->error = fill_element(ld, drc)) > 0)
+                    goto error;
+                break;
             }
-
-            channels++;
-            ch_ele++;
+            ele++;
+        }
+    } else {
+        /* Table 262: er_raw_data_block() */
+        switch (channelConfiguration)
+        {
+        case 1:
+            id_syn_ele = ID_SCE;
+            decode_sce_lfe();
             break;
-        case ID_CPE:
-            spec_data[channels]   = (int16_t*)malloc(1024*sizeof(int16_t));
-            spec_data[channels+1] = (int16_t*)malloc(1024*sizeof(int16_t));
-            spec_coef[channels]   = (real_t*)malloc(1024*sizeof(real_t));
-            spec_coef[channels+1] = (real_t*)malloc(1024*sizeof(real_t));
-
-            syntax_elements[ch_ele] = (element*)malloc(sizeof(element));
-            memset(syntax_elements[ch_ele], 0, sizeof(element));
-            syntax_elements[ch_ele]->ele_id         = id_syn_ele;
-            syntax_elements[ch_ele]->channel        = channels;
-            syntax_elements[ch_ele]->paired_channel = channels+1;
-
-            if ((hInfo->error = channel_pair_element(syntax_elements[ch_ele],
-                ld, spec_data[channels], spec_data[channels+1],
-                sf_index, object_type)) > 0)
-            {
-                /* to make sure everything gets deallocated */
-                channels+=2; ch_ele++;
-                goto error;
-            }
-
-            channels += 2;
-            ch_ele++;
+        case 2:
+            id_syn_ele = ID_CPE;
+            decode_cpe();
             break;
-        case ID_CCE: /* not implemented yet */
-            hInfo->error = 6;
-            goto error;
+        case 3:
+            id_syn_ele = ID_SCE;
+            decode_sce_lfe();
+            id_syn_ele = ID_CPE;
+            decode_cpe();
             break;
-        case ID_DSE:
-            data_stream_element(ld);
+        case 4:
+            id_syn_ele = ID_SCE;
+            decode_sce_lfe();
+            id_syn_ele = ID_CPE;
+            decode_cpe();
+            id_syn_ele = ID_SCE;
+            decode_sce_lfe();
             break;
-        case ID_PCE:
-            if ((hInfo->error = program_config_element(&pce, ld)) > 0)
-                goto error;
+        case 5:
+            id_syn_ele = ID_SCE;
+            decode_sce_lfe();
+            id_syn_ele = ID_CPE;
+            decode_cpe();
+            id_syn_ele = ID_CPE;
+            decode_cpe();
             break;
-        case ID_FIL:
-            if ((hInfo->error = fill_element(ld, drc)) > 0)
-                goto error;
+        case 6:
+            id_syn_ele = ID_SCE;
+            decode_sce_lfe();
+            id_syn_ele = ID_CPE;
+            decode_cpe();
+            id_syn_ele = ID_CPE;
+            decode_cpe();
+            id_syn_ele = ID_LFE;
+            decode_sce_lfe();
             break;
+        case 7:
+            id_syn_ele = ID_SCE;
+            decode_sce_lfe();
+            id_syn_ele = ID_CPE;
+            decode_cpe();
+            id_syn_ele = ID_CPE;
+            decode_cpe();
+            id_syn_ele = ID_CPE;
+            decode_cpe();
+            id_syn_ele = ID_LFE;
+            decode_sce_lfe();
+            break;
+        default:
+            hInfo->error = 7;
+            goto error;
         }
-        ele++;
+#if 0
+        cnt = bits_to_decode() / 8;
+        while (cnt >= 1)
+        {
+            cnt -= extension_payload(cnt);
+        }
+#endif
     }
     /* no more bit reading after this */
     faad_byte_align(ld);
@@ -363,12 +446,12 @@
     ld = NULL;
 
     /* number of samples in this frame */
-    hInfo->samples = 1024*channels;
+    hInfo->samples = frame_len*channels;
     /* number of samples in this frame */
     hInfo->channels = channels;
 
     if (hDecoder->sample_buffer == NULL)
-        hDecoder->sample_buffer = malloc(1024*channels*sizeof(float32_t));
+        hDecoder->sample_buffer = malloc(frame_len*channels*sizeof(float32_t));
 
     sample_buffer = hDecoder->sample_buffer;
 
@@ -391,7 +474,8 @@
         }
 
         /* inverse quantization */
-        inverse_quantization(spec_coef[ch], spec_data[ch], iq_table);
+        inverse_quantization(spec_coef[ch], spec_data[ch], iq_table,
+            frame_len);
 
         /* apply scalefactors */
         apply_scalefactors(ics, spec_coef[ch], pow2_table);
@@ -398,7 +482,7 @@
 
         /* deinterleave short block grouping */
         if (ics->window_sequence == EIGHT_SHORT_SEQUENCE)
-            quant_to_spec(ics, spec_coef[ch]);
+            quant_to_spec(ics, spec_coef[ch], frame_len);
     }
 
     /* Because for ms and is both channels spectral coefficients are needed
@@ -445,38 +529,43 @@
         if (object_type == MAIN)
         {
             /* allocate the state only when needed */
-            if ((pred_stat[ch] == NULL) && ics->predictor_data_present)
+            if (pred_stat[ch] == NULL)
             {
-                pred_stat[ch] = malloc(1024 * sizeof(pred_state));
+                pred_stat[ch] = malloc(frame_len * sizeof(pred_state));
                 reset_all_predictors(pred_stat[ch]);
             }
 
             /* intra channel prediction */
-            if (pred_stat[ch] != NULL)
-            {
-                ic_prediction(ics, spec_coef[ch], pred_stat[ch]);
+            ic_prediction(ics, spec_coef[ch], pred_stat[ch]);
 
-                /* In addition, for scalefactor bands coded by perceptual
-                   noise substitution the predictors belonging to the
-                   corresponding spectral coefficients are reset.
-                 */
-                pns_reset_pred_state(ics, pred_stat[ch]);
+            /* In addition, for scalefactor bands coded by perceptual
+               noise substitution the predictors belonging to the
+               corresponding spectral coefficients are reset.
+            */
+            pns_reset_pred_state(ics, pred_stat[ch]);
+        } else if ((object_type == LTP) || (object_type == LD)) {
+            if (object_type == LD)
+            {
+                if (ltp->data_present)
+                {
+                    if (!ltp->lag_update)
+                        ltp->lag = ltp_lag[ch];
+                    else
+                        ltp_lag[ch] = ltp->lag;
+                }
             }
-        } else if (object_type == LTP) {
+
             /* allocate the state only when needed */
-            if ((lt_pred_stat[ch] == NULL) && ics->predictor_data_present)
+            if (lt_pred_stat[ch] == NULL)
             {
-                lt_pred_stat[ch] = malloc(1024*3 * sizeof(real_t));
-                memset(lt_pred_stat[ch], 0, 1024*3 * sizeof(real_t));
+                lt_pred_stat[ch] = malloc(frame_len*4 * sizeof(real_t));
+                memset(lt_pred_stat[ch], 0, frame_len*4 * sizeof(real_t));
             }
 
             /* long term prediction */
-            if (lt_pred_stat[ch] != NULL)
-            {
-                lt_prediction(ics, ltp, spec_coef[ch], lt_pred_stat[ch], fb,
-                    ics->window_shape, window_shape_prev[ch],
-                    sf_index, object_type);
-            }
+            lt_prediction(ics, ltp, spec_coef[ch], lt_pred_stat[ch], fb,
+                ics->window_shape, window_shape_prev[ch],
+                sf_index, object_type, frame_len);
         }
 
         /* tns decoding */
@@ -493,9 +582,9 @@
         {
             real_t *tp;
 
-            time_state[ch] = malloc(1024*sizeof(real_t));
+            time_state[ch] = malloc(frame_len*sizeof(real_t));
             tp = time_state[ch];
-            for (i = 1024/16-1; i >= 0; --i)
+            for (i = frame_len/16-1; i >= 0; --i)
             {
                 *tp++ = 0; *tp++ = 0; *tp++ = 0; *tp++ = 0;
                 *tp++ = 0; *tp++ = 0; *tp++ = 0; *tp++ = 0;
@@ -505,22 +594,25 @@
         }
         if (time_out[ch] == NULL)
         {
-            time_out[ch] = malloc(1024*2*sizeof(real_t));
+            time_out[ch] = malloc(frame_len*2*sizeof(real_t));
         }
 
         /* filter bank */
         ifilter_bank(fb, ics->window_sequence, ics->window_shape,
             window_shape_prev[ch], spec_coef[ch], time_state[ch],
-            time_out[ch]);
+            time_out[ch], object_type);
         /* save window shape for next frame */
         window_shape_prev[ch] = ics->window_shape;
 
-        if ((object_type == LTP) && (lt_pred_stat[ch] != NULL))
-            lt_update_state(lt_pred_stat[ch], time_out[ch], time_state[ch]);
+        if (((object_type == LTP) || (object_type == LD)) && (lt_pred_stat[ch] != NULL))
+        {
+            lt_update_state(lt_pred_stat[ch], time_out[ch], time_state[ch],
+                frame_len, object_type);
+        }
     }
 
     sample_buffer = output_to_PCM(time_out, sample_buffer, channels,
-        outputFormat);
+        frame_len, outputFormat);
 
     hDecoder->frame++;
     if (hDecoder->frame <= 1)
--- a/libfaad/decoder.h
+++ b/libfaad/decoder.h
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: decoder.h,v 1.3 2002/02/18 10:01:05 menno Exp $
+** $Id: decoder.h,v 1.4 2002/02/25 19:58:33 menno Exp $
 **/
 
 #ifndef __DECODER_H__
@@ -70,6 +70,7 @@
     uint8_t adif_header_present;
     uint8_t sf_index;
     uint8_t object_type;
+    uint8_t channelConfiguration;
 
     uint32_t frame;
 
@@ -76,6 +77,7 @@
     void *sample_buffer;
 
     uint8_t window_shape_prev[MAX_CHANNELS];
+    uint16_t ltp_lag[MAX_CHANNELS];
     fb_info fb;
     drc_info drc;
 
--- a/libfaad/error.c
+++ b/libfaad/error.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: error.c,v 1.2 2002/02/18 10:01:05 menno Exp $
+** $Id: error.c,v 1.3 2002/02/25 19:58:33 menno Exp $
 **/
 
 #include "common.h"
@@ -30,4 +30,5 @@
     "Negative scalefactor found, should be impossible",
     "Unable to find ADTS syncword",
     "Channel coupling not yet implemented",
+    "Channel configuration not allowed in error resilient frame"
 };
\ No newline at end of file
--- a/libfaad/filtbank.c
+++ b/libfaad/filtbank.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: filtbank.c,v 1.3 2002/02/20 13:05:57 menno Exp $
+** $Id: filtbank.c,v 1.4 2002/02/25 19:58:33 menno Exp $
 **/
 
 #include "common.h"
@@ -29,38 +29,54 @@
 #include "mdct.h"
 
 
-real_t *long_window[2];
-real_t *short_window[2];
-
 void filter_bank_init(fb_info *fb)
 {
     uint16_t i;
 
+    /* LD */
+    mdct_init(&(fb->mdct1024), 1024);
+
+    fb->ld_window[0] = malloc(BLOCK_LEN_LD*sizeof(real_t));
+    fb->ld_window[1] = malloc(BLOCK_LEN_LD*sizeof(real_t));
+
+    /* calculate the sine windows */
+    for (i = 0; i < BLOCK_LEN_LD; i++)
+        fb->ld_window[0][i] = (real_t)sin(M_PI / (2.0 * BLOCK_LEN_LD) * (i + 0.5));
+
+    /* low overlap window */
+    for (i = 0; i < 3*(BLOCK_LEN_LD>>3); i++)
+        fb->ld_window[1][i] = 0.0;
+    for (; i < 5*(BLOCK_LEN_LD>>3); i++)
+        fb->ld_window[1][i] = (real_t)sin((i-3*(BLOCK_LEN_LD>>3)+0.5) * M_PI / (BLOCK_LEN_LD>>1));
+    for (; i < BLOCK_LEN_LD; i++)
+        fb->ld_window[1][i] = 1.0;
+
+    /* normal */
     mdct_init(&(fb->mdct256), 256);
     mdct_init(&(fb->mdct2048), 2048);
 
-    fb->sin_long  = malloc(BLOCK_LEN_LONG*sizeof(real_t));
-    fb->sin_short = malloc(BLOCK_LEN_SHORT*sizeof(real_t));
+    fb->long_window[0]  = malloc(BLOCK_LEN_LONG*sizeof(real_t));
+    fb->short_window[0] = malloc(BLOCK_LEN_SHORT*sizeof(real_t));
+    fb->long_window[1]  = kbd_long;
+    fb->short_window[1] = kbd_short;
 
-    long_window[0]  = fb->sin_long;
-    long_window[1]  = kbd_long;
-    short_window[0] = fb->sin_short;
-    short_window[1] = kbd_short;
-
     /* calculate the sine windows */
     for (i = 0; i < BLOCK_LEN_LONG; i++)
-        fb->sin_long[i] = (real_t)sin(M_PI / (2.0 * BLOCK_LEN_LONG) * (i + 0.5));
+        fb->long_window[0][i] = (real_t)sin(M_PI / (2.0 * BLOCK_LEN_LONG) * (i + 0.5));
     for (i = 0; i < BLOCK_LEN_SHORT; i++)
-        fb->sin_short[i] = (real_t)sin(M_PI / (2.0 * BLOCK_LEN_SHORT) * (i + 0.5));
+        fb->short_window[0][i] = (real_t)sin(M_PI / (2.0 * BLOCK_LEN_SHORT) * (i + 0.5));
 }
 
 void filter_bank_end(fb_info *fb)
 {
     mdct_end(&(fb->mdct256));
+    mdct_end(&(fb->mdct1024));
     mdct_end(&(fb->mdct2048));
 
-    if (fb->sin_long) free(fb->sin_long);
-    if (fb->sin_short) free(fb->sin_short);
+    if (fb->long_window[0]) free(fb->long_window[0]);
+    if (fb->short_window[0]) free(fb->short_window[0]);
+    if (fb->ld_window[0]) free(fb->ld_window[0]);
+    if (fb->ld_window[1]) free(fb->ld_window[1]);
 }
 
 static INLINE void vcopy(real_t *src, real_t *dest, uint16_t vlen)
@@ -157,6 +173,9 @@
     case 2048:
         IMDCT_long(&(fb->mdct2048), in_data, out_data);
         return;
+    case 1024:
+        IMDCT_LD(&(fb->mdct1024), in_data, out_data);
+        return;
     case 256:
         IMDCT_short(&(fb->mdct256), in_data, out_data);
         return;
@@ -170,6 +189,9 @@
     case 2048:
         MDCT_long(&(fb->mdct2048), in_data, out_data);
         return;
+    case 1024:
+        MDCT_LD(&(fb->mdct1024), in_data, out_data);
+        return;
     case 256:
         MDCT_short(&(fb->mdct256), in_data, out_data);
         return;
@@ -178,9 +200,9 @@
 
 void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
                   uint8_t window_shape_prev, real_t *freq_in, real_t *time_buff,
-                  real_t *time_out)
+                  real_t *time_out, uint8_t object_type)
 {
-    real_t *o_buf, transf_buf[2*BLOCK_LEN_LONG];
+    real_t *o_buf, *transf_buf;
 
     real_t *window_long;
     real_t *window_long_prev;
@@ -190,16 +212,24 @@
 
     real_t *fp;
     int8_t win;
-    uint16_t nlong = 1024;
+    uint16_t nlong = (object_type == LD) ? 512 : 1024;
     uint16_t nshort = 128;
 
     uint16_t nflat_ls = (nlong-nshort)/2;
 
-    window_long       =  long_window[window_shape];
-    window_long_prev  =  long_window[window_shape_prev];
-    window_short      = short_window[window_shape];
-    window_short_prev = short_window[window_shape_prev];
+    transf_buf = malloc(2*nlong*sizeof(real_t));
 
+    if (object_type == LD)
+    {
+        window_long       = fb->ld_window[window_shape];
+        window_long_prev  = fb->ld_window[window_shape_prev];
+    } else {
+        window_long       = fb->long_window[window_shape];
+        window_long_prev  = fb->long_window[window_shape_prev];
+        window_short      = fb->short_window[window_shape];
+        window_short_prev = fb->short_window[window_shape_prev];
+    }
+
     /* pointer to previous window function */
     window_short_prev_ptr = window_short_prev;
 
@@ -299,14 +329,17 @@
 
     /* save second half of data */
     vcopy(o_buf+nlong, time_buff, nlong);
+
+    free(transf_buf);
 }
 
 /* only works for LTP -> no overlapping */
 void filter_bank_ltp(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
-                     uint8_t window_shape_prev, real_t *in_data, real_t *out_mdct)
+                     uint8_t window_shape_prev, real_t *in_data, real_t *out_mdct,
+                     uint8_t object_type)
 {
     int8_t win;
-    real_t windowed_buf[2*1024];
+    real_t *windowed_buf;
     real_t *p_o_buf;
 
     real_t *window_long;
@@ -315,15 +348,23 @@
     real_t *window_short_prev;
     real_t *window_short_prev_ptr;
 
-    uint16_t nlong = 1024;
+    uint16_t nlong = (object_type == LD) ? 512 : 1024;
     uint16_t nshort = 128;
     uint16_t nflat_ls = (nlong-nshort)/2;
 
+    windowed_buf = malloc(nlong*2*sizeof(real_t));
 
-    window_long       =  long_window[window_shape];
-    window_long_prev  =  long_window[window_shape_prev];
-    window_short      = short_window[window_shape];
-    window_short_prev = short_window[window_shape_prev];
+    if (object_type == LD)
+    {
+        window_long       = fb->ld_window[window_shape];
+        window_long_prev  = fb->ld_window[window_shape_prev];
+    } else {
+        window_long       = fb->long_window[window_shape];
+        window_long_prev  = fb->long_window[window_shape_prev];
+        window_short      = fb->short_window[window_shape];
+        window_short_prev = fb->short_window[window_shape_prev];
+    }
+
     window_short_prev_ptr = window_short_prev;
   
     p_o_buf = in_data;
@@ -365,4 +406,6 @@
         mdct(fb, windowed_buf, out_mdct, 2*nlong);
         break;
     }
+
+    free(windowed_buf);
 }
--- a/libfaad/filtbank.h
+++ b/libfaad/filtbank.h
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: filtbank.h,v 1.3 2002/02/20 13:05:57 menno Exp $
+** $Id: filtbank.h,v 1.4 2002/02/25 19:58:33 menno Exp $
 **/
 
 #ifndef __FILTBANK_H__
@@ -29,15 +29,18 @@
 #include "mdct.h"
 
 #define BLOCK_LEN_LONG  1024
+#define BLOCK_LEN_LD     512
 #define BLOCK_LEN_SHORT  128
 
 
 typedef struct
 {
-    real_t *sin_long;
-    real_t *sin_short;
+    real_t *long_window[2];
+    real_t *short_window[2];
+    real_t *ld_window[2];
 
     mdct_info mdct256;
+    mdct_info mdct1024;
     mdct_info mdct2048;
 } fb_info;
 
@@ -49,7 +52,8 @@
                      uint8_t window_shape,
                      uint8_t window_shape_prev,
                      real_t *in_data,
-                     real_t *out_mdct);
+                     real_t *out_mdct,
+                     uint8_t object_type);
 
 void ifilter_bank(fb_info *fb,
                   uint8_t window_sequence,
@@ -57,7 +61,8 @@
                   uint8_t window_shape_prev,
                   real_t *freq_in,
                   real_t *time_buff,
-                  real_t *time_out);
+                  real_t *time_out,
+                  uint8_t object_type);
 
 #ifdef __cplusplus
 }
--- a/libfaad/lt_predict.c
+++ b/libfaad/lt_predict.c
@@ -16,10 +16,11 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: lt_predict.c,v 1.2 2002/02/18 10:01:05 menno Exp $
+** $Id: lt_predict.c,v 1.3 2002/02/25 19:58:33 menno Exp $
 **/
 
 #include "common.h"
+#include <stdlib.h>
 #include "syntax.h"
 #include "lt_predict.h"
 #include "filtbank.h"
@@ -33,29 +34,33 @@
 
 void lt_prediction(ic_stream *ics, ltp_info *ltp, real_t *spec,
                    real_t *lt_pred_stat, fb_info *fb, uint8_t win_shape,
-                   uint8_t win_shape_prev, uint8_t sr_index, uint8_t object_type)
+                   uint8_t win_shape_prev, uint8_t sr_index,
+                   uint8_t object_type, uint16_t frame_len)
 {
     uint8_t sfb;
     uint16_t bin, i, num_samples;
-    real_t x_est[2*1024];
-    real_t X_est[2*1024];
+    real_t *x_est;
+    real_t *X_est;
 
     if (ics->window_sequence != EIGHT_SHORT_SEQUENCE)
     {
         if (ltp->data_present)
         {
-            if (ltp->lag < 1024)
-                num_samples = 1024 + ltp->lag;
-            else
-                num_samples = 2*1024;
+            num_samples = frame_len << 1;
 
+            x_est = malloc(num_samples*sizeof(real_t));
+            X_est = malloc(num_samples*sizeof(real_t));
+
             for(i = 0; i < num_samples; i++)
-                x_est[i] = codebook[ltp->coef] * lt_pred_stat[i - ltp->lag + 2*1024];
-            for( ; i < 2*1024; i++)
-                x_est[i] = 0.0f;
+            {
+                /* The extra lookback M (N/2 for LD, 0 for LTP) is handled
+                   in the buffer updating */
+                x_est[i] = codebook[ltp->coef] *
+                    lt_pred_stat[num_samples + i - ltp->lag];
+            }
 
             filter_bank_ltp(fb, ics->window_sequence, win_shape, win_shape_prev,
-                x_est, X_est);
+                x_est, X_est, object_type);
 
             tns_encode_frame(ics, &(ics->tns), sr_index, object_type, X_est);
 
@@ -72,18 +77,47 @@
                     }
                 }
             }
+
+            free(x_est);
+            free(X_est);
         }
     }
 }
 
-void lt_update_state(real_t *lt_pred_stat, real_t *time, real_t *overlap)
+void lt_update_state(real_t *lt_pred_stat, real_t *time, real_t *overlap,
+                     uint16_t frame_len, uint8_t object_type)
 {
     uint16_t i;
 
-    for (i = 0; i < 1024; i++)
+    /*
+     * The reference point for index i and the content of the buffer
+     * lt_pred_stat are arranged so that lt_pred_stat(0 ... N/2 - 1) contains the
+     * last aliased half window from the IMDCT, and lt_pred_stat(N/2 ... N-1)
+     * is always all zeros. The rest of lt_pred_stat (i<0) contains the previous
+     * fully reconstructed time domain samples, i.e., output of the decoder.
+     *
+     * These values are shifted up by N*2 to avoid (i<0)
+     *
+     * For the LD object type an extra 512 samples lookback is accomodated here.
+     */
+    if (object_type == LD)
     {
-        lt_pred_stat[i]          = lt_pred_stat[i + 1024];
-        lt_pred_stat[1024 + i]   = time[i];
-        lt_pred_stat[2*1024 + i] = overlap[i];
+        for (i = 0; i < frame_len; i++)
+        {
+            lt_pred_stat[i]  /* extra 512 */  = lt_pred_stat[i + frame_len];
+            lt_pred_stat[frame_len + i]       = lt_pred_stat[i + (frame_len * 2)];
+            lt_pred_stat[(frame_len * 2) + i] = time[i];
+            lt_pred_stat[(frame_len * 3) + i] = overlap[i];
+        }
+    } else {
+        for (i = 0; i < frame_len; i++)
+        {
+            lt_pred_stat[i]                   = lt_pred_stat[i + frame_len];
+            lt_pred_stat[frame_len + i]       = time[i];
+            lt_pred_stat[(frame_len * 2) + i] = overlap[i];
+#if 0 /* set to zero once upon initialisation */
+            lt_pred_stat[(frame_len * 3) + i] = 0;
+#endif
+        }
     }
 }
\ No newline at end of file
--- a/libfaad/lt_predict.h
+++ b/libfaad/lt_predict.h
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: lt_predict.h,v 1.2 2002/02/18 10:01:05 menno Exp $
+** $Id: lt_predict.h,v 1.3 2002/02/25 19:58:33 menno Exp $
 **/
 
 #ifndef __LT_PREDICT_H__
@@ -36,11 +36,14 @@
                    uint8_t win_shape,
                    uint8_t win_shape_prev,
                    uint8_t sr_index,
-                   uint8_t object_type);
+                   uint8_t object_type,
+                   uint16_t frame_len);
 
 void lt_update_state(real_t *lt_pred_stat,
                      real_t *time,
-                     real_t *overlap);
+                     real_t *overlap,
+                     uint16_t frame_len,
+                     uint8_t object_type);
 
 #ifdef __cplusplus
 }
--- a/libfaad/mdct.c
+++ b/libfaad/mdct.c
@@ -16,9 +16,30 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: mdct.c,v 1.3 2002/02/20 13:05:57 menno Exp $
+** $Id: mdct.c,v 1.4 2002/02/25 19:58:33 menno Exp $
 **/
 
+/*
+ * Fast MDCT Implementation using pre-twiddling and FFT using fftw
+ *
+ *
+ * Optionally uses recurrence relation to find sine and cosine values without
+ * lookup table or calling the actual sine or cosine function.
+ * Works like this:
+ *  cos(2*Pi*(i+1)/N) = cos(2*Pi*i/N)*cos(2*Pi/N) - sin(2*Pi*i/N)*sin(2*Pi/N)
+ *  sin(2*Pi*(i+1)/N) = sin(2*Pi*i/N)*cos(2*Pi/N) + cos(2*Pi*i/N)*sin(2*Pi/N)
+ *
+ * In which cos(2*Pi/N) and sin(2*Pi/N) are constants and cos(2*Pi*i/N) and
+ * sin(2*Pi*i/N) are the previous values.
+ * (in the method used in this MDCT there is an extra factor 8, but I left that
+ * out here to show more clearly the relation)
+ *
+ * Nice method for low memory usage, but lookup table is faster on most
+ * machines.
+ *
+ */
+
+
 #include "common.h"
 
 #include <stdlib.h>
@@ -26,7 +47,9 @@
 
 void mdct_init(mdct_info *mdct, uint16_t len)
 {
+#ifdef USE_TWIDDLE_TABLE
     uint16_t i;
+#endif
 
     mdct->len = len;
 
@@ -38,8 +61,8 @@
     for (i = 0; i < len/4; i++)
     {
         real_t angle = 2.0f * M_PI * (i + 1.0f/8.0f) / (real_t)len;
-        mdct->twiddlers[2*i]     = cos(angle);
-        mdct->twiddlers[2*i + 1] = sin(angle);
+        mdct->twiddlers[i*2]     = (real_t)cos(angle);
+        mdct->twiddlers[i*2 + 1] = (real_t)sin(angle);
     }
 #endif
 }
@@ -55,7 +78,7 @@
 void MDCT_long(mdct_info *mdct, fftw_real *in_data, fftw_real *out_data)
 {
     fftw_complex FFTarray[512];
-    fftw_real tempr, tempi, fac;
+    real_t tempr, tempi, fac;
 
 #ifdef USE_TWIDDLE_TABLE
     /* use twiddle factor tables */
@@ -67,7 +90,7 @@
     uint16_t i;
 
 
-    fac = 2.; /* 2 from MDCT inverse  to forward */
+    fac = 2.; /* 2 from MDCT inverse to forward */
 
 #ifndef USE_TWIDDLE_TABLE
     /* prepare for recurrence relation in pre-twiddle */
@@ -149,10 +172,107 @@
     }
 }
 
+void MDCT_LD(mdct_info *mdct, fftw_real *in_data, fftw_real *out_data)
+{
+    fftw_complex FFTarray[256];
+    real_t tempr, tempi, fac;
+
+#ifdef USE_TWIDDLE_TABLE
+    /* use twiddle factor tables */
+    real_t *twiddlers = mdct->twiddlers;
+#else
+    /* temps for pre and post twiddle */
+    real_t cosfreq8, sinfreq8, c, s, cold, cfreq, sfreq;
+#endif
+    uint16_t i;
+
+
+    fac = 2.; /* 2 from MDCT inverse to forward */
+
+#ifndef USE_TWIDDLE_TABLE
+    /* prepare for recurrence relation in pre-twiddle */
+    cfreq = 0.9999811752826011426f;
+    sfreq = 0.0061358846491544753f;
+    cosfreq8 = 0.99999970586288221916f;
+    sinfreq8 = 0.00076699031874270453f;
+
+    c = cosfreq8;
+    s = sinfreq8;
+#endif
+
+    for (i = 0; i < 256; i++)
+    {
+        uint16_t n = 511 - (i << 1);
+        if (i < 128)
+            tempr = in_data[256 + n] + in_data[1279 - n];
+        else
+            tempr = in_data[256 + n] - in_data[255 - n];
+
+        n = (i << 1);
+        if (i < 128)
+            tempi = in_data[256 + n] - in_data[255 - n];
+        else
+            tempi = in_data[256 + n] + in_data[1279 - n];
+
+        /* calculate pre-twiddled FFT input */
+#ifdef USE_TWIDDLE_TABLE
+        FFTarray[i].re = tempr * twiddlers[n] + tempi * twiddlers[n + 1];
+        FFTarray[i].im = tempi * twiddlers[n] - tempr * twiddlers[n + 1];
+#else
+        FFTarray[i].re = tempr * c + tempi * s;
+        FFTarray[i].im = tempi * c - tempr * s;
+
+        /* use recurrence to prepare cosine and sine for next value of i */
+        cold = c;
+        c = c * cfreq - s * sfreq;
+        s = s * cfreq + cold * sfreq;
+#endif
+    }
+
+    /* Perform in-place complex FFT of length N/4 */
+    pfftw_256(FFTarray);
+
+
+#ifndef USE_TWIDDLE_TABLE
+    /* prepare for recurrence relations in post-twiddle */
+    c = cosfreq8;
+    s = sinfreq8;
+#endif
+
+    /* post-twiddle FFT output and then get output data */
+    for (i = 0; i < 256; i++)
+    {
+        uint16_t n = i << 1;
+        uint16_t unscr = mdct->unscrambled[i];
+
+        /* get post-twiddled FFT output  */
+#ifdef USE_TWIDDLE_TABLE
+        tempr = fac * (FFTarray[unscr].re * twiddlers[n] + FFTarray[unscr].im * twiddlers[n + 1]);
+        tempi = fac * (FFTarray[unscr].im * twiddlers[n] - FFTarray[unscr].re * twiddlers[n + 1]);
+#else
+        tempr = fac * (FFTarray[unscr].re * c + FFTarray[unscr].im * s);
+        tempi = fac * (FFTarray[unscr].im * c - FFTarray[unscr].re * s);
+#endif
+
+        /* fill in output values */
+        out_data[n]        = -tempr;  /* first half even */
+        out_data[511 - n]  =  tempi;  /* first half odd */
+        out_data[512 + n]  = -tempi;  /* second half even */
+        out_data[1023 - n] =  tempr;  /* second half odd */
+
+#ifndef USE_TWIDDLE_TABLE
+        /* use recurrence to prepare cosine and sine for next value of i */
+        cold = c;
+        c = c * cfreq - s * sfreq;
+        s = s * cfreq + cold * sfreq;
+#endif
+    }
+}
+
 void MDCT_short(mdct_info *mdct, fftw_real *in_data, fftw_real *out_data)
 {
     fftw_complex FFTarray[64];    /* the array for in-place FFT */
-    fftw_real tempr, tempi, fac;
+    real_t tempr, tempi, fac;
 
 #ifdef USE_TWIDDLE_TABLE
     /* use twiddle factor tables */
@@ -248,7 +368,7 @@
 void IMDCT_long(mdct_info *mdct, fftw_real *in_data, fftw_real *out_data)
 {
     fftw_complex FFTarray[512];    /* the array for in-place FFT */
-    fftw_real tempr, tempi, fac;
+    real_t tempr, tempi, fac;
 
 #ifdef USE_TWIDDLE_TABLE
     /* use twiddle factor tables */
@@ -340,11 +460,105 @@
     }
 }
 
+void IMDCT_LD(mdct_info *mdct, fftw_real *in_data, fftw_real *out_data)
+{
+    fftw_complex FFTarray[256];    /* the array for in-place FFT */
+    real_t tempr, tempi, fac;
+
+#ifdef USE_TWIDDLE_TABLE
+    /* use twiddle factor tables */
+    real_t *twiddlers = mdct->twiddlers;
+#else
+    /* temps for pre and post twiddle */
+    real_t cosfreq8, sinfreq8, c, s, cold, cfreq, sfreq;
+#endif
+    uint16_t i;
+
+    /* Choosing to allocate 2/N factor to Inverse Xform! */
+    fac = 0.001953125f;
+
+#ifndef USE_TWIDDLE_TABLE
+    /* prepare for recurrence relation in pre-twiddle */
+    cfreq = 0.9999811752826011426f;
+    sfreq = 0.0061358846491544753f;
+    cosfreq8 = 0.99999970586288221916f;
+    sinfreq8 = 0.00076699031874270453f;
+
+    c = cosfreq8;
+    s = sinfreq8;
+#endif
+
+    for (i = 0; i < 256; i++)
+    {
+        uint16_t n = i << 1;
+        uint16_t unscr = mdct->unscrambled[i];
+
+        tempr = -in_data[n];
+        tempi =  in_data[511 - n];
+
+        /* calculate pre-twiddled FFT input */
+#ifdef USE_TWIDDLE_TABLE
+        FFTarray[unscr].re = tempr * twiddlers[n] - tempi * twiddlers[n + 1];
+        FFTarray[unscr].im = tempi * twiddlers[n] + tempr * twiddlers[n + 1];
+#else
+        FFTarray[unscr].re = tempr * c - tempi * s;
+        FFTarray[unscr].im = tempi * c + tempr * s;
+
+        /* use recurrence to prepare cosine and sine for next value of i */
+        cold = c;
+        c = c * cfreq - s * sfreq;
+        s = s * cfreq + cold * sfreq;
+#endif
+    }
+
+    /* Perform in-place complex IFFT of length N/4 */
+    pfftwi_256(FFTarray);
+
+#ifndef USE_TWIDDLE_TABLE
+    /* prepare for recurrence relations in post-twiddle */
+    c = cosfreq8;
+    s = sinfreq8;
+#endif
+
+    /* post-twiddle FFT output and then get output data */
+    for (i = 0; i < 256; i++)
+    {
+        uint16_t n = i << 1;
+        /* get post-twiddled FFT output  */
+#ifdef USE_TWIDDLE_TABLE
+        tempr = fac * (FFTarray[i].re * twiddlers[n] - FFTarray[i].im * twiddlers[n + 1]);
+        tempi = fac * (FFTarray[i].im * twiddlers[n] + FFTarray[i].re * twiddlers[n + 1]);
+#else
+        tempr = fac * (FFTarray[i].re * c - FFTarray[i].im * s);
+        tempi = fac * (FFTarray[i].im * c + FFTarray[i].re * s);
+#endif
+
+        /* fill in output values */
+        out_data [767 - n] = tempr;
+        if (i < 128)
+            out_data[768 + n] = tempr;
+        else
+            out_data[n - 256] = -tempr;
+
+        out_data [256 + n] = tempi;
+        if (i < 128)
+            out_data[255 - n] = -tempi;
+        else
+            out_data[1279 - n] = tempi;
+
+#ifndef USE_TWIDDLE_TABLE
+        /* use recurrence to prepare cosine and sine for next value of i */
+        cold = c;
+        c = c * cfreq - s * sfreq;
+        s = s * cfreq + cold * sfreq;
+#endif
+    }
+}
+
 void IMDCT_short(mdct_info *mdct, fftw_real *in_data, fftw_real *out_data)
 {
     fftw_complex FFTarray[64];    /* the array for in-place FFT */
-    fftw_real tempr, tempi;
-    fftw_real fac;
+    real_t tempr, tempi, fac;
 
 #ifdef USE_TWIDDLE_TABLE
     /* use twiddle factor tables */
@@ -443,21 +657,20 @@
 #pragma warning(disable:4305)
 #endif
 
-
-static fftw_real K980785280[1] =
-{FFTW_KONST(+0.980785280403230449126182236134239036973933731)};
-static fftw_real K195090322[1] =
-{FFTW_KONST(+0.195090322016128267848284868477022240927691618)};
-static fftw_real K555570233[1] =
-{FFTW_KONST(+0.555570233019602224742830813948532874374937191)};
-static fftw_real K831469612[1] =
-{FFTW_KONST(+0.831469612302545237078788377617905756738560812)};
-static fftw_real K923879532[1] =
-{FFTW_KONST(+0.923879532511286756128183189396788286822416626)};
 static fftw_real K382683432[1] =
 {FFTW_KONST(+0.382683432365089771728459984030398866761344562)};
+static fftw_real K923879532[1] =
+{FFTW_KONST(+0.923879532511286756128183189396788286822416626)};
 static fftw_real K707106781[1] =
 {FFTW_KONST(+0.707106781186547524400844362104849039284835938)};
+static fftw_real K831469612[1] =
+{FFTW_KONST(+0.831469612302545237078788377617905756738560812)};
+static fftw_real K555570233[1] =
+{FFTW_KONST(+0.555570233019602224742830813948532874374937191)};
+static fftw_real K195090322[1] =
+{FFTW_KONST(+0.195090322016128267848284868477022240927691618)};
+static fftw_real K980785280[1] =
+{FFTW_KONST(+0.980785280403230449126182236134239036973933731)};
 
 static fftw_complex PFFTW(W_64)[30] = {
 { 0.995184726672197, 0.0980171403295606 },
@@ -557,6 +770,135 @@
 { -0.995184726672197, 0.0980171403295608 },
 };
 
+static fftw_complex PFFTW(W_256)[126] = {
+{ 0.999698818696204, 0.0245412285229123 },
+{ 0.998795456205172, 0.049067674327418 },
+{ 0.998795456205172, 0.049067674327418 },
+{ 0.995184726672197, 0.0980171403295606 },
+{ 0.99729045667869, 0.0735645635996674 },
+{ 0.989176509964781, 0.146730474455362 },
+{ 0.995184726672197, 0.0980171403295606 },
+{ 0.98078528040323, 0.195090322016128 },
+{ 0.99247953459871, 0.122410675199216 },
+{ 0.970031253194544, 0.242980179903264 },
+{ 0.989176509964781, 0.146730474455362 },
+{ 0.956940335732209, 0.290284677254462 },
+{ 0.985277642388941, 0.170961888760301 },
+{ 0.941544065183021, 0.33688985339222 },
+{ 0.98078528040323, 0.195090322016128 },
+{ 0.923879532511287, 0.38268343236509 },
+{ 0.975702130038529, 0.21910124015687 },
+{ 0.903989293123443, 0.427555093430282 },
+{ 0.970031253194544, 0.242980179903264 },
+{ 0.881921264348355, 0.471396736825998 },
+{ 0.96377606579544, 0.266712757474898 },
+{ 0.857728610000272, 0.514102744193222 },
+{ 0.956940335732209, 0.290284677254462 },
+{ 0.831469612302545, 0.555570233019602 },
+{ 0.949528180593037, 0.313681740398892 },
+{ 0.803207531480645, 0.595699304492433 },
+{ 0.941544065183021, 0.33688985339222 },
+{ 0.773010453362737, 0.634393284163645 },
+{ 0.932992798834739, 0.359895036534988 },
+{ 0.740951125354959, 0.671558954847018 },
+{ 0.923879532511287, 0.38268343236509 },
+{ 0.707106781186548, 0.707106781186547 },
+{ 0.914209755703531, 0.40524131400499 },
+{ 0.671558954847018, 0.740951125354959 },
+{ 0.903989293123443, 0.427555093430282 },
+{ 0.634393284163645, 0.773010453362737 },
+{ 0.893224301195515, 0.449611329654607 },
+{ 0.595699304492433, 0.803207531480645 },
+{ 0.881921264348355, 0.471396736825998 },
+{ 0.555570233019602, 0.831469612302545 },
+{ 0.870086991108711, 0.492898192229784 },
+{ 0.514102744193222, 0.857728610000272 },
+{ 0.857728610000272, 0.514102744193222 },
+{ 0.471396736825998, 0.881921264348355 },
+{ 0.844853565249707, 0.534997619887097 },
+{ 0.427555093430282, 0.903989293123443 },
+{ 0.831469612302545, 0.555570233019602 },
+{ 0.38268343236509, 0.923879532511287 },
+{ 0.817584813151584, 0.575808191417845 },
+{ 0.33688985339222, 0.941544065183021 },
+{ 0.803207531480645, 0.595699304492433 },
+{ 0.290284677254462, 0.956940335732209 },
+{ 0.788346427626606, 0.615231590580627 },
+{ 0.242980179903264, 0.970031253194544 },
+{ 0.773010453362737, 0.634393284163645 },
+{ 0.195090322016128, 0.98078528040323 },
+{ 0.757208846506485, 0.653172842953777 },
+{ 0.146730474455362, 0.989176509964781 },
+{ 0.740951125354959, 0.671558954847018 },
+{ 0.0980171403295608, 0.995184726672197 },
+{ 0.724247082951467, 0.689540544737067 },
+{ 0.0490676743274181, 0.998795456205172 },
+{ 0.707106781186548, 0.707106781186547 },
+{ 6.12303176911189e-17, 1 },
+{ 0.689540544737067, 0.724247082951467 },
+{ -0.049067674327418, 0.998795456205172 },
+{ 0.671558954847018, 0.740951125354959 },
+{ -0.0980171403295606, 0.995184726672197 },
+{ 0.653172842953777, 0.757208846506484 },
+{ -0.146730474455362, 0.989176509964781 },
+{ 0.634393284163645, 0.773010453362737 },
+{ -0.195090322016128, 0.98078528040323 },
+{ 0.615231590580627, 0.788346427626606 },
+{ -0.242980179903264, 0.970031253194544 },
+{ 0.595699304492433, 0.803207531480645 },
+{ -0.290284677254462, 0.956940335732209 },
+{ 0.575808191417845, 0.817584813151584 },
+{ -0.33688985339222, 0.941544065183021 },
+{ 0.555570233019602, 0.831469612302545 },
+{ -0.38268343236509, 0.923879532511287 },
+{ 0.534997619887097, 0.844853565249707 },
+{ -0.427555093430282, 0.903989293123443 },
+{ 0.514102744193222, 0.857728610000272 },
+{ -0.471396736825998, 0.881921264348355 },
+{ 0.492898192229784, 0.870086991108711 },
+{ -0.514102744193222, 0.857728610000272 },
+{ 0.471396736825998, 0.881921264348355 },
+{ -0.555570233019602, 0.831469612302545 },
+{ 0.449611329654607, 0.893224301195515 },
+{ -0.595699304492433, 0.803207531480645 },
+{ 0.427555093430282, 0.903989293123443 },
+{ -0.634393284163645, 0.773010453362737 },
+{ 0.40524131400499, 0.914209755703531 },
+{ -0.671558954847018, 0.740951125354959 },
+{ 0.38268343236509, 0.923879532511287 },
+{ -0.707106781186547, 0.707106781186548 },
+{ 0.359895036534988, 0.932992798834739 },
+{ -0.740951125354959, 0.671558954847019 },
+{ 0.33688985339222, 0.941544065183021 },
+{ -0.773010453362737, 0.634393284163645 },
+{ 0.313681740398892, 0.949528180593037 },
+{ -0.803207531480645, 0.595699304492433 },
+{ 0.290284677254462, 0.956940335732209 },
+{ -0.831469612302545, 0.555570233019602 },
+{ 0.266712757474898, 0.96377606579544 },
+{ -0.857728610000272, 0.514102744193222 },
+{ 0.242980179903264, 0.970031253194544 },
+{ -0.881921264348355, 0.471396736825998 },
+{ 0.21910124015687, 0.975702130038529 },
+{ -0.903989293123443, 0.427555093430282 },
+{ 0.195090322016128, 0.98078528040323 },
+{ -0.923879532511287, 0.38268343236509 },
+{ 0.170961888760301, 0.985277642388941 },
+{ -0.941544065183021, 0.33688985339222 },
+{ 0.146730474455362, 0.989176509964781 },
+{ -0.956940335732209, 0.290284677254462 },
+{ 0.122410675199216, 0.99247953459871 },
+{ -0.970031253194544, 0.242980179903264 },
+{ 0.0980171403295608, 0.995184726672197 },
+{ -0.98078528040323, 0.195090322016129 },
+{ 0.0735645635996675, 0.99729045667869 },
+{ -0.989176509964781, 0.146730474455362 },
+{ 0.0490676743274181, 0.998795456205172 },
+{ -0.995184726672197, 0.0980171403295608 },
+{ 0.0245412285229123, 0.999698818696204 },
+{ -0.998795456205172, 0.049067674327418 },
+};
+
 static fftw_complex PFFTW(W_512)[254] = {
 { 0.999924701839145, 0.0122715382857199 },
 { 0.999698818696204, 0.0245412285229123 },
@@ -1904,31 +2246,40 @@
      c_im(input[1]) = st1;
 }
 
-static void  PFFTW(64)(fftw_complex *input)
-{
+static void PFFTW(64)(fftw_complex *input) 
+{ 
      PFFTW(twiddle_4)(input, PFFTW(W_64), 16);
-     PFFTW(16)(input );
-     PFFTW(16)(input + 16);
-     PFFTW(16)(input + 32);
-     PFFTW(16)(input + 48);
+     PFFTW(16)(input + 16 * 0);
+     PFFTW(16)(input + 16 * 1);
+     PFFTW(16)(input + 16 * 2);
+     PFFTW(16)(input + 16 * 3);
 }
 
-static void PFFTW(128)(fftw_complex *input)
-{
+static void PFFTW(128)(fftw_complex *input) 
+{ 
      PFFTW(twiddle_4)(input, PFFTW(W_128), 32);
-     PFFTW(32)(input );
-     PFFTW(32)(input + 32);
-     PFFTW(32)(input + 64);
-     PFFTW(32)(input + 96);
+     PFFTW(32)(input + 32 * 0);
+     PFFTW(32)(input + 32 * 1);
+     PFFTW(32)(input + 32 * 2);
+     PFFTW(32)(input + 32 * 3);
 }
 
-static void PFFTW(512)(fftw_complex *input)
-{
+static void PFFTW(256)(fftw_complex *input) 
+{ 
+     PFFTW(twiddle_4)(input, PFFTW(W_256), 64);
+     PFFTW(64)(input + 64 * 0);
+     PFFTW(64)(input + 64 * 1);
+     PFFTW(64)(input + 64 * 2);
+     PFFTW(64)(input + 64 * 3);
+}
+
+static void PFFTW(512)(fftw_complex *input) 
+{ 
      PFFTW(twiddle_4)(input, PFFTW(W_512), 128);
-     PFFTW(128)(input );
-     PFFTW(128)(input + 128);
-     PFFTW(128)(input + 256);
-     PFFTW(128)(input + 384);
+     PFFTW(128)(input + 128 * 0);
+     PFFTW(128)(input + 128 * 1);
+     PFFTW(128)(input + 128 * 2);
+     PFFTW(128)(input + 128 * 3);
 }
 
 static void PFFTWI(16) (fftw_complex * input) {
@@ -3023,143 +3374,152 @@
      c_re(input[3]) = st1;
 }
 
-static void PFFTWI(64)(fftw_complex *input)
+static void PFFTWI(64)(fftw_complex *input) 
 {
-     PFFTWI(16)(input );
-     PFFTWI(16)(input + 16);
-     PFFTWI(16)(input + 32);
-     PFFTWI(16)(input + 48);
+     PFFTWI(16)(input + 16 * 0);
+     PFFTWI(16)(input + 16 * 1);
+     PFFTWI(16)(input + 16 * 2);
+     PFFTWI(16)(input + 16 * 3);
      PFFTWI(twiddle_4)(input, PFFTW(W_64), 16);
 }
 
-static void PFFTWI(128)(fftw_complex *input)
+static void PFFTWI(128)(fftw_complex *input) 
 {
-     PFFTWI(32)(input );
-     PFFTWI(32)(input + 32);
-     PFFTWI(32)(input + 64);
-     PFFTWI(32)(input + 96);
+     PFFTWI(32)(input + 32 * 0);
+     PFFTWI(32)(input + 32 * 1);
+     PFFTWI(32)(input + 32 * 2);
+     PFFTWI(32)(input + 32 * 3);
      PFFTWI(twiddle_4)(input, PFFTW(W_128), 32);
 }
 
-static void PFFTWI(512)(fftw_complex *input)
+static void PFFTWI(256)(fftw_complex *input) 
 {
-     PFFTWI(128)(input );
-     PFFTWI(128)(input + 128);
-     PFFTWI(128)(input + 256);
-     PFFTWI(128)(input + 384);
+     PFFTWI(64)(input + 64 * 0);
+     PFFTWI(64)(input + 64 * 1);
+     PFFTWI(64)(input + 64 * 2);
+     PFFTWI(64)(input + 64 * 3);
+     PFFTWI(twiddle_4)(input, PFFTW(W_256), 64);
+}
+
+static void PFFTWI(512)(fftw_complex *input) 
+{
+     PFFTWI(128)(input + 128 * 0);
+     PFFTWI(128)(input + 128 * 1);
+     PFFTWI(128)(input + 128 * 2);
+     PFFTWI(128)(input + 128 * 3);
      PFFTWI(twiddle_4)(input, PFFTW(W_512), 128);
 }
 
-static void  PFFTW(twiddle_4) (fftw_complex * A, const fftw_complex * W, uint16_t iostride) {
+static void PFFTW(twiddle_4) (fftw_complex * A, const fftw_complex * W, uint16_t iostride) {
      uint16_t i;
      fftw_complex *inout;
      inout = A;
      {
-      fftw_real st1;
-      fftw_real st2;
-      fftw_real st3;
-      fftw_real st4;
-      fftw_real st5;
-      fftw_real st6;
-      fftw_real st7;
-      fftw_real st8;
-      st8 = c_re(inout[0]);
-      st8 = st8 + c_re(inout[2 * iostride]);
-      st7 = c_re(inout[iostride]);
-      st7 = st7 + c_re(inout[3 * iostride]);
-      st6 = st8 - st7;
-      st8 = st8 + st7;
-      st5 = c_im(inout[0]);
-      st5 = st5 + c_im(inout[2 * iostride]);
-      st4 = c_im(inout[iostride]);
-      st4 = st4 + c_im(inout[3 * iostride]);
-      st3 = st5 - st4;
-      st5 = st5 + st4;
-      st2 = c_im(inout[0]);
-      st2 = st2 - c_im(inout[2 * iostride]);
-      st1 = c_re(inout[iostride]);
-      st1 = st1 - c_re(inout[3 * iostride]);
-      st7 = st2 - st1;
-      st1 = st1 + st2;
-      st4 = c_re(inout[0]);
-      st4 = st4 - c_re(inout[2 * iostride]);
-      c_re(inout[2 * iostride]) = st6;
-      st6 = c_im(inout[iostride]);
-      st6 = st6 - c_im(inout[3 * iostride]);
-      c_re(inout[0]) = st8;
-      st8 = st4 - st6;
-      st4 = st4 + st6;
-      c_im(inout[0]) = st5;
-      c_im(inout[2 * iostride]) = st3;
-      c_im(inout[iostride]) = st7;
-      c_im(inout[3 * iostride]) = st1;
-      c_re(inout[3 * iostride]) = st8;
-      c_re(inout[iostride]) = st4;
+	  fftw_real st1;
+	  fftw_real st2;
+	  fftw_real st3;
+	  fftw_real st4;
+	  fftw_real st5;
+	  fftw_real st6;
+	  fftw_real st7;
+	  fftw_real st8;
+	  st8 = c_re(inout[0]);
+	  st8 = st8 + c_re(inout[2 * iostride]);
+	  st7 = c_re(inout[iostride]);
+	  st7 = st7 + c_re(inout[3 * iostride]);
+	  st6 = st8 - st7;
+	  st8 = st8 + st7;
+	  st5 = c_im(inout[0]);
+	  st5 = st5 + c_im(inout[2 * iostride]);
+	  st4 = c_im(inout[iostride]);
+	  st4 = st4 + c_im(inout[3 * iostride]);
+	  st3 = st5 - st4;
+	  st5 = st5 + st4;
+	  st2 = c_im(inout[0]);
+	  st2 = st2 - c_im(inout[2 * iostride]);
+	  st1 = c_re(inout[iostride]);
+	  st1 = st1 - c_re(inout[3 * iostride]);
+	  st7 = st2 - st1;
+	  st1 = st1 + st2;
+	  st4 = c_re(inout[0]);
+	  st4 = st4 - c_re(inout[2 * iostride]);
+	  c_re(inout[2 * iostride]) = st6;
+	  st6 = c_im(inout[iostride]);
+	  st6 = st6 - c_im(inout[3 * iostride]);
+	  c_re(inout[0]) = st8;
+	  st8 = st4 - st6;
+	  st4 = st4 + st6;
+	  c_im(inout[0]) = st5;
+	  c_im(inout[2 * iostride]) = st3;
+	  c_im(inout[iostride]) = st7;
+	  c_im(inout[3 * iostride]) = st1;
+	  c_re(inout[3 * iostride]) = st8;
+	  c_re(inout[iostride]) = st4;
      }
      inout = inout + 1;
      i = iostride - 1;
      do {
-      {
-           fftw_real st1;
-           fftw_real st2;
-           fftw_real st3;
-           fftw_real st4;
-           fftw_real st5;
-           fftw_real st6;
-           fftw_real st7;
-           fftw_real st8;
-           st8 = c_re(inout[0]);
-           st8 = st8 + c_re(inout[2 * iostride]);
-           st7 = c_re(inout[iostride]);
-           st7 = st7 + c_re(inout[3 * iostride]);
-           st6 = st8 - st7;
-           st5 = st6 * c_im(W[1]);
-           st8 = st8 + st7;
-           st6 = st6 * c_re(W[1]);
-           st4 = c_im(inout[0]);
-           st4 = st4 + c_im(inout[2 * iostride]);
-           st3 = c_im(inout[iostride]);
-           st3 = st3 + c_im(inout[3 * iostride]);
-           st2 = st4 - st3;
-           st1 = st2 * c_im(W[1]);
-           st4 = st4 + st3;
-           st2 = st2 * c_re(W[1]);
-           st2 = st2 - st5;
-           st6 = st6 + st1;
-           st7 = c_re(inout[0]);
-           st7 = st7 - c_re(inout[2 * iostride]);
-           st5 = c_im(inout[iostride]);
-           st5 = st5 - c_im(inout[3 * iostride]);
-           c_re(inout[0]) = st8;
-           st8 = st7 - st5;
-           st3 = st8 * c_re(W[0]);
-           st7 = st7 + st5;
-           st8 = st8 * c_im(W[0]);
-           st1 = c_re(inout[iostride]);
-           c_re(inout[2 * iostride]) = st6;
-           st6 = st7 * c_im(W[0]);
-           st1 = st1 - c_re(inout[3 * iostride]);
-           st7 = st7 * c_re(W[0]);
-           st5 = c_im(inout[0]);
-           st5 = st5 - c_im(inout[2 * iostride]);
-           c_im(inout[0]) = st4;
-           st4 = st1 + st5;
-           c_im(inout[2 * iostride]) = st2;
-           st2 = st4 * c_im(W[0]);
-           st5 = st5 - st1;
-           st4 = st4 * c_re(W[0]);
-           st3 = st3 - st2;
-           st1 = st5 * c_re(W[0]);
-           st5 = st5 * c_im(W[0]);
-           st4 = st4 + st8;
-           st5 = st5 + st7;
-           st1 = st1 - st6;
-           c_re(inout[3 * iostride]) = st3;
-           c_im(inout[3 * iostride]) = st4;
-           c_re(inout[iostride]) = st5;
-           c_im(inout[iostride]) = st1;
-      }
-      i = i - 1, inout = inout + 1, W = W + 2;
+	  {
+	       fftw_real st1;
+	       fftw_real st2;
+	       fftw_real st3;
+	       fftw_real st4;
+	       fftw_real st5;
+	       fftw_real st6;
+	       fftw_real st7;
+	       fftw_real st8;
+	       st8 = c_re(inout[0]);
+	       st8 = st8 + c_re(inout[2 * iostride]);
+	       st7 = c_re(inout[iostride]);
+	       st7 = st7 + c_re(inout[3 * iostride]);
+	       st6 = st8 - st7;
+	       st5 = st6 * c_im(W[1]);
+	       st8 = st8 + st7;
+	       st6 = st6 * c_re(W[1]);
+	       st4 = c_im(inout[0]);
+	       st4 = st4 + c_im(inout[2 * iostride]);
+	       st3 = c_im(inout[iostride]);
+	       st3 = st3 + c_im(inout[3 * iostride]);
+	       st2 = st4 - st3;
+	       st1 = st2 * c_im(W[1]);
+	       st4 = st4 + st3;
+	       st2 = st2 * c_re(W[1]);
+	       st2 = st2 - st5;
+	       st6 = st6 + st1;
+	       st7 = c_re(inout[0]);
+	       st7 = st7 - c_re(inout[2 * iostride]);
+	       st5 = c_im(inout[iostride]);
+	       st5 = st5 - c_im(inout[3 * iostride]);
+	       c_re(inout[0]) = st8;
+	       st8 = st7 - st5;
+	       st3 = st8 * c_re(W[0]);
+	       st7 = st7 + st5;
+	       st8 = st8 * c_im(W[0]);
+	       st1 = c_re(inout[iostride]);
+	       c_re(inout[2 * iostride]) = st6;
+	       st6 = st7 * c_im(W[0]);
+	       st1 = st1 - c_re(inout[3 * iostride]);
+	       st7 = st7 * c_re(W[0]);
+	       st5 = c_im(inout[0]);
+	       st5 = st5 - c_im(inout[2 * iostride]);
+	       c_im(inout[0]) = st4;
+	       st4 = st1 + st5;
+	       c_im(inout[2 * iostride]) = st2;
+	       st2 = st4 * c_im(W[0]);
+	       st5 = st5 - st1;
+	       st4 = st4 * c_re(W[0]);
+	       st3 = st3 - st2;
+	       st1 = st5 * c_re(W[0]);
+	       st5 = st5 * c_im(W[0]);
+	       st4 = st4 + st8;
+	       st5 = st5 + st7;
+	       st1 = st1 - st6;
+	       c_re(inout[3 * iostride]) = st3;
+	       c_im(inout[3 * iostride]) = st4;
+	       c_re(inout[iostride]) = st5;
+	       c_im(inout[iostride]) = st1;
+	  }
+	  i = i - 1, inout = inout + 1, W = W + 2;
      } while (i > 0);
 }
 
@@ -3168,126 +3528,136 @@
      fftw_complex *inout;
      inout = A;
      {
-      fftw_real st1;
-      fftw_real st2;
-      fftw_real st3;
-      fftw_real st4;
-      fftw_real st5;
-      fftw_real st6;
-      fftw_real st7;
-      fftw_real st8;
-      st8 = c_re(inout[0]);
-      st8 = st8 + c_re(inout[2 * iostride]);
-      st7 = c_re(inout[iostride]);
-      st7 = st7 + c_re(inout[3 * iostride]);
-      st6 = st8 - st7;
-      st8 = st8 + st7;
-      st5 = c_im(inout[0]);
-      st5 = st5 + c_im(inout[2 * iostride]);
-      st4 = c_im(inout[iostride]);
-      st4 = st4 + c_im(inout[3 * iostride]);
-      st3 = st5 - st4;
-      st5 = st5 + st4;
-      st2 = c_re(inout[iostride]);
-      st2 = st2 - c_re(inout[3 * iostride]);
-      st1 = c_im(inout[0]);
-      st1 = st1 - c_im(inout[2 * iostride]);
-      st7 = st2 + st1;
-      st1 = st1 - st2;
-      st4 = c_re(inout[0]);
-      st4 = st4 - c_re(inout[2 * iostride]);
-      c_re(inout[2 * iostride]) = st6;
-      st6 = c_im(inout[iostride]);
-      st6 = st6 - c_im(inout[3 * iostride]);
-      c_re(inout[0]) = st8;
-      st8 = st4 - st6;
-      st4 = st4 + st6;
-      c_im(inout[0]) = st5;
-      c_im(inout[2 * iostride]) = st3;
-      c_im(inout[iostride]) = st7;
-      c_im(inout[3 * iostride]) = st1;
-      c_re(inout[iostride]) = st8;
-      c_re(inout[3 * iostride]) = st4;
+	  fftw_real st1;
+	  fftw_real st2;
+	  fftw_real st3;
+	  fftw_real st4;
+	  fftw_real st5;
+	  fftw_real st6;
+	  fftw_real st7;
+	  fftw_real st8;
+	  st8 = c_re(inout[0]);
+	  st8 = st8 + c_re(inout[2 * iostride]);
+	  st7 = c_re(inout[iostride]);
+	  st7 = st7 + c_re(inout[3 * iostride]);
+	  st6 = st8 - st7;
+	  st8 = st8 + st7;
+	  st5 = c_im(inout[0]);
+	  st5 = st5 + c_im(inout[2 * iostride]);
+	  st4 = c_im(inout[iostride]);
+	  st4 = st4 + c_im(inout[3 * iostride]);
+	  st3 = st5 - st4;
+	  st5 = st5 + st4;
+	  st2 = c_re(inout[iostride]);
+	  st2 = st2 - c_re(inout[3 * iostride]);
+	  st1 = c_im(inout[0]);
+	  st1 = st1 - c_im(inout[2 * iostride]);
+	  st7 = st2 + st1;
+	  st1 = st1 - st2;
+	  st4 = c_re(inout[0]);
+	  st4 = st4 - c_re(inout[2 * iostride]);
+	  c_re(inout[2 * iostride]) = st6;
+	  st6 = c_im(inout[iostride]);
+	  st6 = st6 - c_im(inout[3 * iostride]);
+	  c_re(inout[0]) = st8;
+	  st8 = st4 - st6;
+	  st4 = st4 + st6;
+	  c_im(inout[0]) = st5;
+	  c_im(inout[2 * iostride]) = st3;
+	  c_im(inout[iostride]) = st7;
+	  c_im(inout[3 * iostride]) = st1;
+	  c_re(inout[iostride]) = st8;
+	  c_re(inout[3 * iostride]) = st4;
      }
      inout = inout + 1;
      i = iostride - 1;
      do {
-      {
-           fftw_real st1;
-           fftw_real st2;
-           fftw_real st3;
-           fftw_real st4;
-           fftw_real st5;
-           fftw_real st6;
-           fftw_real st7;
-           fftw_real st8;
-           st8 = c_re(inout[2 * iostride]);
-           st8 = st8 * c_re(W[1]);
-           st7 = c_im(inout[2 * iostride]);
-           st7 = st7 * c_im(W[1]);
-           st8 = st8 - st7;
-           st6 = st8 + c_re(inout[0]);
-           st8 = c_re(inout[0]) - st8;
-           st5 = c_re(inout[2 * iostride]);
-           st5 = st5 * c_im(W[1]);
-           st4 = c_im(inout[2 * iostride]);
-           st4 = st4 * c_re(W[1]);
-           st5 = st5 + st4;
-           st3 = st5 + c_im(inout[0]);
-           st5 = c_im(inout[0]) - st5;
-           st2 = c_re(inout[iostride]);
-           st2 = st2 * c_re(W[0]);
-           st1 = c_im(inout[iostride]);
-           st1 = st1 * c_im(W[0]);
-           st2 = st2 - st1;
-           st7 = c_re(inout[3 * iostride]);
-           st7 = st7 * c_re(W[0]);
-           st4 = c_im(inout[3 * iostride]);
-           st4 = st4 * c_im(W[0]);
-           st7 = st7 + st4;
-           st1 = st2 + st7;
-           st2 = st2 - st7;
-           st4 = st6 - st1;
-           st6 = st6 + st1;
-           st7 = st2 + st5;
-           st5 = st5 - st2;
-           st1 = c_re(inout[iostride]);
-           st1 = st1 * c_im(W[0]);
-           st2 = c_im(inout[iostride]);
-           st2 = st2 * c_re(W[0]);
-           st1 = st1 + st2;
-           c_re(inout[2 * iostride]) = st4;
-           st4 = c_im(inout[3 * iostride]);
-           st4 = st4 * c_re(W[0]);
-           c_re(inout[0]) = st6;
-           st6 = c_re(inout[3 * iostride]);
-           st6 = st6 * c_im(W[0]);
-           st4 = st4 - st6;
-           c_im(inout[iostride]) = st7;
-           st7 = st1 - st4;
-           st1 = st1 + st4;
-           c_im(inout[3 * iostride]) = st5;
-           st5 = st8 - st7;
-           st8 = st8 + st7;
-           st2 = st1 + st3;
-           st3 = st3 - st1;
-           c_re(inout[iostride]) = st5;
-           c_re(inout[3 * iostride]) = st8;
-           c_im(inout[0]) = st2;
-           c_im(inout[2 * iostride]) = st3;
-      }
-      i = i - 1, inout = inout + 1, W = W + 2;
+	  {
+	       fftw_real st1;
+	       fftw_real st2;
+	       fftw_real st3;
+	       fftw_real st4;
+	       fftw_real st5;
+	       fftw_real st6;
+	       fftw_real st7;
+	       fftw_real st8;
+	       st8 = c_re(inout[2 * iostride]);
+	       st8 = st8 * c_re(W[1]);
+	       st7 = c_im(inout[2 * iostride]);
+	       st7 = st7 * c_im(W[1]);
+	       st8 = st8 - st7;
+	       st6 = st8 + c_re(inout[0]);
+	       st8 = c_re(inout[0]) - st8;
+	       st5 = c_re(inout[2 * iostride]);
+	       st5 = st5 * c_im(W[1]);
+	       st4 = c_im(inout[2 * iostride]);
+	       st4 = st4 * c_re(W[1]);
+	       st5 = st5 + st4;
+	       st3 = st5 + c_im(inout[0]);
+	       st5 = c_im(inout[0]) - st5;
+	       st2 = c_re(inout[iostride]);
+	       st2 = st2 * c_re(W[0]);
+	       st1 = c_im(inout[iostride]);
+	       st1 = st1 * c_im(W[0]);
+	       st2 = st2 - st1;
+	       st7 = c_re(inout[3 * iostride]);
+	       st7 = st7 * c_re(W[0]);
+	       st4 = c_im(inout[3 * iostride]);
+	       st4 = st4 * c_im(W[0]);
+	       st7 = st7 + st4;
+	       st1 = st2 + st7;
+	       st2 = st2 - st7;
+	       st4 = st6 - st1;
+	       st6 = st6 + st1;
+	       st7 = st2 + st5;
+	       st5 = st5 - st2;
+	       st1 = c_re(inout[iostride]);
+	       st1 = st1 * c_im(W[0]);
+	       st2 = c_im(inout[iostride]);
+	       st2 = st2 * c_re(W[0]);
+	       st1 = st1 + st2;
+	       c_re(inout[2 * iostride]) = st4;
+	       st4 = c_im(inout[3 * iostride]);
+	       st4 = st4 * c_re(W[0]);
+	       c_re(inout[0]) = st6;
+	       st6 = c_re(inout[3 * iostride]);
+	       st6 = st6 * c_im(W[0]);
+	       st4 = st4 - st6;
+	       c_im(inout[iostride]) = st7;
+	       st7 = st1 - st4;
+	       st1 = st1 + st4;
+	       c_im(inout[3 * iostride]) = st5;
+	       st5 = st8 - st7;
+	       st8 = st8 + st7;
+	       st2 = st1 + st3;
+	       st3 = st3 - st1;
+	       c_re(inout[iostride]) = st5;
+	       c_re(inout[3 * iostride]) = st8;
+	       c_im(inout[0]) = st2;
+	       c_im(inout[2 * iostride]) = st3;
+	  }
+	  i = i - 1, inout = inout + 1, W = W + 2;
      } while (i > 0);
 }
 
+uint16_t PFFTW(permutation_16) (uint16_t i)
+{
+    return i;
+}
+
+uint16_t PFFTW(permutation_32) (uint16_t i)
+{
+     return i;
+}
+
 static uint16_t PFFTW(permutation_64)(uint16_t i)
 {
     uint16_t i1 = i % 4;
     uint16_t i2 = i / 4;
-    if (i1 <= 2)
-       return (i1 * 16 + i2);
+    if (i1 <= (4 / 2))
+       return (i1 * 16 + PFFTW(permutation_16)(i2));
     else
-       return (i1 * 16 + ((i2 + 1) % 16));
+       return (i1 * 16 + PFFTW(permutation_16)((i2 + 1) % 16));
 }
 
 static uint16_t PFFTW(permutation_128)(uint16_t i)
@@ -3294,17 +3664,27 @@
 {
     uint16_t i1 = i % 4;
     uint16_t i2 = i / 4;
-    if (i1 <= 2)
-       return (i1 * 32 + i2);
+    if (i1 <= (4 / 2))
+       return (i1 * 32 + PFFTW(permutation_32)(i2));
     else
-       return (i1 * 32 + ((i2 + 1) % 32));
+       return (i1 * 32 + PFFTW(permutation_32)((i2 + 1) % 32));
 }
 
+static uint16_t PFFTW(permutation_256)(uint16_t i)
+{
+    uint16_t i1 = i % 4;
+    uint16_t i2 = i / 4;
+    if (i1 <= (4 / 2))
+       return (i1 * 64 + PFFTW(permutation_64)(i2));
+    else
+       return (i1 * 64 + PFFTW(permutation_64)((i2 + 1) % 64));
+}
+
 static uint16_t PFFTW(permutation_512)(uint16_t i)
 {
     uint16_t i1 = i % 4;
     uint16_t i2 = i / 4;
-    if (i1 <= 2)
+    if (i1 <= (4 / 2))
        return (i1 * 128 + PFFTW(permutation_128)(i2));
     else
        return (i1 * 128 + PFFTW(permutation_128)((i2 + 1) % 128));
@@ -3319,6 +3699,10 @@
     case 64:
         for (i = 0; i < len; i++)
             unscrambled[i] = PFFTW(permutation_64)(i);
+        break;
+    case 256:
+        for (i = 0; i < len; i++)
+            unscrambled[i] = PFFTW(permutation_256)(i);
         break;
     case 512:
         for (i = 0; i < len; i++)
--- a/libfaad/mdct.h
+++ b/libfaad/mdct.h
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: mdct.h,v 1.3 2002/02/20 13:05:57 menno Exp $
+** $Id: mdct.h,v 1.4 2002/02/25 19:58:33 menno Exp $
 **/
 
 #ifndef __MDCT_H__
@@ -50,6 +50,7 @@
 DEFINE_PFFTW(32)
 DEFINE_PFFTW(64)
 DEFINE_PFFTW(128)
+DEFINE_PFFTW(256)
 DEFINE_PFFTW(512)
 
 void mdct_init(mdct_info *mdct, uint16_t len);
@@ -56,9 +57,11 @@
 void mdct_end(mdct_info *mdct);
 
 void IMDCT_long(mdct_info *mdct, fftw_real *in_data, fftw_real *out_data);
+void IMDCT_LD(mdct_info *mdct, fftw_real *in_data, fftw_real *out_data);
 void IMDCT_short(mdct_info *mdct, fftw_real *in_data, fftw_real *out_data);
 
 void MDCT_long(mdct_info *mdct, fftw_real *in_data, fftw_real *out_data);
+void MDCT_LD(mdct_info *mdct, fftw_real *in_data, fftw_real *out_data);
 void MDCT_short(mdct_info *mdct, fftw_real *in_data, fftw_real *out_data);
 
 static void make_fft_order(uint16_t *unscrambled, uint16_t len);
--- a/libfaad/mp4.c
+++ b/libfaad/mp4.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: mp4.c,v 1.2 2002/02/18 10:01:05 menno Exp $
+** $Id: mp4.c,v 1.3 2002/02/25 19:58:33 menno Exp $
 **/
 
 #include "common.h"
@@ -43,15 +43,32 @@
     0, /* Main synthetic */
     0, /* Wavetable synthesis */
     0, /* General MIDI */
-    0  /* Algorithmic Synthesis and Audio FX */
+    0, /* Algorithmic Synthesis and Audio FX */
+
+    /* MPEG-4 Version 2 */
+    0, /* ER AAC LC */
+    0, /* (Reserved) */
+    0, /* ER AAC LTP */
+    0, /* ER AAC scalable */
+    0, /* ER TwinVQ */
+    0, /* ER BSAC */
+    1, /* ER AAC LD */     /* !!! Supported, but only with ER turned off !!! */
+    0, /* ER CELP */
+    0, /* ER HVXC */
+    0, /* ER HILN */
+    0, /* ER Parametric */
+    0, /* (Reserved) */
+    0, /* (Reserved) */
+    0, /* (Reserved) */
+    0  /* (Reserved) */
 };
 
 /* Table 1.6.1 */
 int8_t FAADAPI AudioSpecificConfig(uint8_t *pBuffer,
-                                uint32_t *samplerate,
-                                uint8_t *channels,
-                                uint8_t *sf_index,
-                                uint8_t *object_type)
+                                   uint32_t *samplerate,
+                                   uint8_t *channels,
+                                   uint8_t *sf_index,
+                                   uint8_t *object_type)
 {
     bitfile ld;
     uint8_t ObjectTypeIndex, SamplingFrequencyIndex, ChannelsConfiguration;
@@ -94,9 +111,17 @@
     /* get GASpecificConfig */
     if (ObjectTypeIndex == 1 || ObjectTypeIndex == 2 ||
         ObjectTypeIndex == 3 || ObjectTypeIndex == 4 ||
-        ObjectTypeIndex == 6 || ObjectTypeIndex == 7 )
+        ObjectTypeIndex == 6 || ObjectTypeIndex == 7)
     {
-        return GASpecificConfig(&ld, channels);
+        return GASpecificConfig(&ld, channels, ObjectTypeIndex);
+    } else if (ObjectTypeIndex == 23) { /* ER AAC LD */
+        uint8_t result = GASpecificConfig(&ld, channels, ObjectTypeIndex);
+        uint8_t ep_config = (uint8_t)faad_getbits(&ld, 2
+            DEBUGVAR(1,143,"parse_audio_decoder_specific_info(): epConfig"));
+        if (ep_config != 0)
+            return -5;
+
+        return result;
     } else {
         return -4;
     }
--- a/libfaad/mp4.h
+++ b/libfaad/mp4.h
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: mp4.h,v 1.2 2002/02/18 10:01:05 menno Exp $
+** $Id: mp4.h,v 1.3 2002/02/25 19:58:33 menno Exp $
 **/
 
 #ifndef __MP4_H__
@@ -29,10 +29,10 @@
 #include "decoder.h"
 
 int8_t FAADAPI AudioSpecificConfig(uint8_t *pBuffer,
-                                uint32_t *samplerate,
-                                uint8_t *channels,
-                                uint8_t *sf_index,
-                                uint8_t *object_type);
+                                   uint32_t *samplerate,
+                                   uint8_t *channels,
+                                   uint8_t *sf_index,
+                                   uint8_t *object_type);
 
 #ifdef __cplusplus
 }
--- a/libfaad/output.c
+++ b/libfaad/output.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: output.c,v 1.4 2002/02/20 13:05:57 menno Exp $
+** $Id: output.c,v 1.5 2002/02/25 19:58:33 menno Exp $
 **/
 
 #include "common.h"
@@ -40,7 +40,7 @@
 
 
 void* output_to_PCM(real_t **input, void *sample_buffer, uint8_t channels,
-                    uint8_t format)
+                    uint16_t frame_len, uint8_t format)
 {
     uint8_t ch;
     uint16_t i;
@@ -55,7 +55,7 @@
     case FAAD_FMT_16BIT:
         for (ch = 0; ch < channels; ch++)
         {
-            for(i = 0; i < 1024; i++)
+            for(i = 0; i < frame_len; i++)
             {
                 int32_t tmp;
                 real_t ftemp;
@@ -68,7 +68,7 @@
     case FAAD_FMT_24BIT:
         for (ch = 0; ch < channels; ch++)
         {
-            for(i = 0; i < 1024; i++)
+            for(i = 0; i < frame_len; i++)
             {
                 int_sample_buffer[(i*channels)+ch] = ROUND(input[ch][i]*(1<<8));
             }
@@ -79,7 +79,7 @@
         {
             real_t floattmp;
 
-            for(i = 0; i < 1024; i++)
+            for(i = 0; i < frame_len; i++)
             {
                 int_sample_buffer[(i*channels)+ch] = ROUND32(input[ch][i]*(1<<16));
             }
@@ -88,7 +88,7 @@
     case FAAD_FMT_FLOAT:
         for (ch = 0; ch < channels; ch++)
         {
-            for(i = 0; i < 1024; i++)
+            for(i = 0; i < frame_len; i++)
             {
                 float_sample_buffer[(i*channels)+ch] = input[ch][i]*FLOAT_SCALE;
             }
--- a/libfaad/output.h
+++ b/libfaad/output.h
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: output.h,v 1.2 2002/02/18 10:01:05 menno Exp $
+** $Id: output.h,v 1.3 2002/02/25 19:58:33 menno Exp $
 **/
 
 #ifndef __OUTPUT_H__
@@ -29,6 +29,7 @@
 void* output_to_PCM(real_t **input,
                     void *samplebuffer,
                     uint8_t channels,
+                    uint16_t frame_len,
                     uint8_t format);
 
 
--- a/libfaad/specrec.c
+++ b/libfaad/specrec.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: specrec.c,v 1.4 2002/02/20 13:05:57 menno Exp $
+** $Id: specrec.c,v 1.5 2002/02/25 19:58:33 menno Exp $
 **/
 
 /*
@@ -48,7 +48,8 @@
     in section named section. This offset depends on window_sequence and
     scale_factor_grouping and is needed to decode the spectral_data().
 */
-uint8_t window_grouping_info(ic_stream *ics, uint8_t fs_index)
+uint8_t window_grouping_info(ic_stream *ics, uint8_t fs_index,
+                             uint8_t object_type)
 {
     uint8_t i, g;
 
@@ -59,14 +60,28 @@
         ics->num_windows = 1;
         ics->num_window_groups = 1;
         ics->window_group_length[ics->num_window_groups-1] = 1;
-        ics->num_swb = num_swb_long_window[fs_index];
+        if (object_type == LD)
+        {
+            ics->num_swb = num_swb_512_window[fs_index];
+        } else {
+            ics->num_swb = num_swb_1024_window[fs_index];
+        }
 
         /* preparation of sect_sfb_offset for long blocks */
         /* also copy the last value! */
-        for (i = 0; i < ics->num_swb + 1; i++)
+        if (object_type == LD)
         {
-            ics->sect_sfb_offset[0][i] = swb_offset_long_window[fs_index][i];
-            ics->swb_offset[i] = swb_offset_long_window[fs_index][i];
+            for (i = 0; i < ics->num_swb + 1; i++)
+            {
+                ics->sect_sfb_offset[0][i] = swb_offset_512_window[fs_index][i];
+                ics->swb_offset[i] = swb_offset_512_window[fs_index][i];
+            }
+        } else {
+            for (i = 0; i < ics->num_swb + 1; i++)
+            {
+                ics->sect_sfb_offset[0][i] = swb_offset_1024_window[fs_index][i];
+                ics->swb_offset[i] = swb_offset_1024_window[fs_index][i];
+            }
         }
         return 0;
     case EIGHT_SHORT_SEQUENCE:
@@ -73,10 +88,10 @@
         ics->num_windows = 8;
         ics->num_window_groups = 1;
         ics->window_group_length[ics->num_window_groups-1] = 1;
-        ics->num_swb = num_swb_short_window[fs_index];
+        ics->num_swb = num_swb_128_window[fs_index];
 
         for (i = 0; i < ics->num_swb + 1; i++)
-            ics->swb_offset[i] = swb_offset_short_window[fs_index][i];
+            ics->swb_offset[i] = swb_offset_128_window[fs_index][i];
 
         for (i = 0; i < ics->num_windows-1; i++) {
             if (bit_set(ics->scale_factor_grouping, 6-i) == 0)
@@ -97,8 +112,8 @@
 
             for (i = 0; i < ics->num_swb; i++)
             {
-                width = swb_offset_short_window[fs_index][i+1] -
-                    swb_offset_short_window[fs_index][i];
+                width = swb_offset_128_window[fs_index][i+1] -
+                    swb_offset_128_window[fs_index][i];
                 width *= ics->window_group_length[g];
                 ics->sect_sfb_offset[g][sect_sfb++] = offset;
                 offset += width;
@@ -131,7 +146,7 @@
   - Within a scalefactor window band, the coefficients are in ascending
     spectral order.
 */
-void quant_to_spec(ic_stream *ics, real_t *spec_data)
+void quant_to_spec(ic_stream *ics, real_t *spec_data, uint16_t frame_len)
 {
     int8_t i;
     uint8_t g, sfb, win;
@@ -142,7 +157,7 @@
     real_t *tmp_spec_ptr, *spec_ptr;
 
     tmp_spec_ptr = tmp_spec;
-    for (i = 1024/16-1; i >= 0; --i)
+    for (i = frame_len/16-1; i >= 0; --i)
     {
         *tmp_spec_ptr++ = 0; *tmp_spec_ptr++ = 0;
         *tmp_spec_ptr++ = 0; *tmp_spec_ptr++ = 0;
@@ -195,7 +210,7 @@
     spec_ptr = spec_data;
     tmp_spec_ptr = tmp_spec;
 
-    for (i = 1024/16 - 1; i >= 0; --i)
+    for (i = frame_len/16 - 1; i >= 0; --i)
     {
         *spec_ptr++ = *tmp_spec_ptr++; *spec_ptr++ = *tmp_spec_ptr++;
         *spec_ptr++ = *tmp_spec_ptr++; *spec_ptr++ = *tmp_spec_ptr++;
@@ -244,13 +259,14 @@
     }
 }
 
-void inverse_quantization(real_t *x_invquant, int16_t *x_quant, real_t *iq_table)
+void inverse_quantization(real_t *x_invquant, int16_t *x_quant, real_t *iq_table,
+                          uint16_t frame_len)
 {
     int8_t i;
     int16_t *in_ptr = x_quant;
     real_t *out_ptr = x_invquant;
 
-    for(i = 1024/8-1; i >= 0; --i)
+    for(i = frame_len/8-1; i >= 0; --i)
     {
         *out_ptr++ = iquant(*in_ptr++, iq_table);
         *out_ptr++ = iquant(*in_ptr++, iq_table);
--- a/libfaad/specrec.h
+++ b/libfaad/specrec.h
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: specrec.h,v 1.2 2002/02/18 10:01:05 menno Exp $
+** $Id: specrec.h,v 1.3 2002/02/25 19:58:33 menno Exp $
 **/
 
 #ifndef __SPECREC_H__
@@ -32,10 +32,11 @@
 #define POW_TABLE_SIZE  200
 
 
-uint8_t window_grouping_info(ic_stream *ics, uint8_t fs_index);
-void quant_to_spec(ic_stream *ics, real_t *spec_data);
+uint8_t window_grouping_info(ic_stream *ics, uint8_t fs_index, uint8_t object_type);
+void quant_to_spec(ic_stream *ics, real_t *spec_data, uint16_t frame_len);
 void build_tables(real_t *iq_table, real_t *pow2_table);
-void inverse_quantization(real_t *x_invquant, int16_t *x_quant, real_t *iq_table);
+void inverse_quantization(real_t *x_invquant, int16_t *x_quant, real_t *iq_table,
+                          uint16_t frame_len);
 void apply_scalefactors(ic_stream *ics, real_t *x_invquant, real_t *pow2_table);
 
 
--- a/libfaad/syntax.c
+++ b/libfaad/syntax.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: syntax.c,v 1.7 2002/02/18 10:01:05 menno Exp $
+** $Id: syntax.c,v 1.8 2002/02/25 19:58:33 menno Exp $
 **/
 
 /*
@@ -40,7 +40,8 @@
 
 
 /* Table 4.4.1 */
-uint8_t GASpecificConfig(bitfile *ld, uint8_t *channelConfiguration)
+uint8_t GASpecificConfig(bitfile *ld, uint8_t *channelConfiguration,
+                         uint8_t object_type)
 {
     uint8_t frameLengthFlag, dependsOnCoreCoder, extensionFlag;
     uint16_t coreCoderDelay;
@@ -70,7 +71,25 @@
 
     if (extensionFlag == 1)
     {
-        /* defined in mpeg4 phase 2 */
+        /* Error resilience not supported yet */
+        if (object_type == 23)
+        {
+            uint8_t tmp;
+            tmp = faad_get1bit(ld
+                DEBUGVAR(1,144,"GASpecificConfig(): aacSectionDataResilienceFlag"));
+            if (tmp)
+                return -6;
+            tmp = faad_get1bit(ld
+                DEBUGVAR(1,145,"GASpecificConfig(): aacScalefactorDataResilienceFlag"));
+            if (tmp)
+                return -6;
+            tmp = faad_get1bit(ld
+                DEBUGVAR(1,146,"GASpecificConfig(): aacSpectralDataResilienceFlag"));
+            if (tmp)
+                return -6;
+
+            /* 1 bit: extensionFlag3 */
+        }
     }
 
     return 0;
@@ -295,29 +314,11 @@
         ics->max_sfb = (uint8_t)faad_getbits(ld, 6
             DEBUGVAR(1,48,"ics_info(): max_sfb (long)"));
 
-        if (object_type == LTP)
+        if ((ics->predictor_data_present = faad_get1bit(ld
+            DEBUGVAR(1,49,"ics_info(): predictor_data_present"))) & 1)
         {
-            if ((ics->predictor_data_present = faad_get1bit(ld
-                DEBUGVAR(1,49,"ics_info(): predictor_data_present"))) & 1)
+            if (object_type == MAIN) /* MPEG2 style AAC predictor */
             {
-                if ((ics->ltp.data_present = faad_get1bit(ld
-                    DEBUGVAR(1,50,"ics_info(): ltp.data_present"))) & 1)
-                {
-                    ltp_data(ics, &(ics->ltp), ld);
-                }
-                if (common_window)
-                {
-                    if ((ics->ltp2.data_present = faad_get1bit(ld
-                        DEBUGVAR(1,51,"ics_info(): ltp2.data_present"))) & 1)
-                    {
-                        ltp_data(ics, &(ics->ltp2), ld);
-                    }
-                }
-            }
-        } else { /* MPEG2 style AAC predictor */
-            if ((ics->predictor_data_present = faad_get1bit(ld
-                DEBUGVAR(1,52,"ics_info(): predictor_data_present"))) & 1)
-            {
                 uint8_t sfb;
 
                 ics->pred.limit = min(ics->max_sfb, pred_sfb_max[sf_index]);
@@ -334,12 +335,26 @@
                     ics->pred.prediction_used[sfb] = faad_get1bit(ld
                         DEBUGVAR(1,55,"ics_info(): pred.prediction_used"));
                 }
+            } else { /* Long Term Prediction */
+                if ((ics->ltp.data_present = faad_get1bit(ld
+                    DEBUGVAR(1,50,"ics_info(): ltp.data_present"))) & 1)
+                {
+                    ltp_data(ics, &(ics->ltp), ld, object_type);
+                }
+                if (common_window)
+                {
+                    if ((ics->ltp2.data_present = faad_get1bit(ld
+                        DEBUGVAR(1,51,"ics_info(): ltp2.data_present"))) & 1)
+                    {
+                        ltp_data(ics, &(ics->ltp2), ld, object_type);
+                    }
+                }
             }
         }
     }
 
     /* get the grouping information */
-    return window_grouping_info(ics, sf_index);
+    return window_grouping_info(ics, sf_index, object_type);
 }
 
 /* Table 4.4.7 */
@@ -417,6 +432,7 @@
                                      uint8_t object_type)
 {
     uint8_t result;
+    uint16_t frame_len = (object_type == LD) ? 512 : 1024;
 
     ics->global_gain = (uint8_t)faad_getbits(ld, 8
         DEBUGVAR(1,67,"individual_channel_stream(): global_gain"));
@@ -433,6 +449,11 @@
 
     if (!scal_flag)
     {
+        /**
+         **  NOTE: It could be that pulse data is available in scalable AAC too,
+         **        as said in Amendment 1, this could be only the case for ER AAC,
+         **        though. (have to check this out later)
+         **/
         /* get pulse data */
         if ((ics->pulse_data_present = faad_get1bit(ld
             DEBUGVAR(1,68,"individual_channel_stream(): pulse_data_present"))) & 1)
@@ -456,7 +477,7 @@
     }
 
     /* decode the spectral data */
-    if ((result = spectral_data(ics, ld, spec_data)) > 0)
+    if ((result = spectral_data(ics, ld, spec_data, frame_len)) > 0)
         return result;
 
     /* pulse coding reconstruction */
@@ -646,12 +667,25 @@
    The limit MAX_LTP_SFB is not defined in 14496-3, this is a bug in the document
    and will be corrected in one of the corrigenda.
 */
-static void ltp_data(ic_stream *ics, ltp_info *ltp, bitfile *ld)
+static void ltp_data(ic_stream *ics, ltp_info *ltp, bitfile *ld,
+                     uint8_t object_type)
 {
     uint8_t sfb, w;
 
-    ltp->lag = (uint16_t)faad_getbits(ld, 11
-        DEBUGVAR(1,81,"ltp_data(): lag"));
+    if (object_type == LD)
+    {
+        ltp->lag_update = (uint8_t)faad_getbits(ld, 1
+            DEBUGVAR(1,142,"ltp_data(): lag_update"));
+
+        if (ltp->lag_update)
+        {
+            ltp->lag = (uint16_t)faad_getbits(ld, 10
+                DEBUGVAR(1,81,"ltp_data(): lag"));
+        }
+    } else {
+        ltp->lag = (uint16_t)faad_getbits(ld, 11
+            DEBUGVAR(1,81,"ltp_data(): lag"));
+    }
     ltp->coef = (uint8_t)faad_getbits(ld, 3
         DEBUGVAR(1,82,"ltp_data(): coef"));
 
@@ -669,7 +703,7 @@
                     ltp->short_lag[w] = (uint8_t)faad_getbits(ld, 4
                         DEBUGVAR(1,85,"ltp_data(): short_lag"));
                 }
-			}
+            }
         }
     } else {
         ltp->last_band = (ics->max_sfb < MAX_LTP_SFB ? ics->max_sfb : MAX_LTP_SFB);
@@ -687,7 +721,8 @@
 static uint8_t unsigned_cb[] = { 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 };
 
 /* Table 4.4.29 */
-static uint8_t spectral_data(ic_stream *ics, bitfile *ld, int16_t *spectral_data)
+static uint8_t spectral_data(ic_stream *ics, bitfile *ld, int16_t *spectral_data,
+                             uint16_t frame_len)
 {
     int8_t i;
     uint8_t g, inc;
@@ -697,7 +732,7 @@
     uint8_t sect_cb;
 
     sp = spectral_data;
-    for (i = 1024/16-1; i >= 0; --i)
+    for (i = frame_len/16-1; i >= 0; --i)
     {
         *sp++ = 0; *sp++ = 0; *sp++ = 0; *sp++ = 0;
         *sp++ = 0; *sp++ = 0; *sp++ = 0; *sp++ = 0;
--- a/libfaad/syntax.h
+++ b/libfaad/syntax.h
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: syntax.h,v 1.5 2002/02/18 10:01:05 menno Exp $
+** $Id: syntax.h,v 1.6 2002/02/25 19:58:33 menno Exp $
 **/
 
 #ifndef __SYNTAX_H__
@@ -32,6 +32,7 @@
 #define LC   1
 #define SSR  2
 #define LTP  3
+#define LD   23
 
 
 /* Bitstream */
@@ -152,6 +153,7 @@
     uint8_t last_band;
     uint8_t data_present;
     uint16_t lag;
+    uint8_t lag_update;
     uint8_t coef;
     uint8_t long_used[51];
     uint8_t short_used[8];
@@ -257,7 +259,13 @@
 } element; /* syntax element (SCE, CPE, LFE) */
 
 
-uint8_t GASpecificConfig(bitfile *ld, uint8_t *channelConfiguration);
+uint8_t GASpecificConfig(bitfile *ld, uint8_t *channelConfiguration,
+                         uint8_t object_type);
+uint8_t raw_data_block(bitfile *ld, int16_t ***spec_data, real_t ***spec_coef,
+                       element ***syntax_elements,
+                       uint8_t *channels, uint8_t *ele, uint8_t *ch_ele,
+                       uint16_t frame_len, uint8_t sf_index, uint8_t object_type,
+                       drc_info *drc);
 uint8_t single_lfe_channel_element(element *sce, bitfile *ld, int16_t *spec_data,
                                uint8_t sf_index, uint8_t object_type);
 uint8_t channel_pair_element(element *cpe, bitfile *ld, int16_t *spec_data1,
@@ -278,11 +286,13 @@
                     uint8_t common_window, uint8_t fs_index, uint8_t object_type);
 static void section_data(ic_stream *ics, bitfile *ld);
 static uint8_t scale_factor_data(ic_stream *ics, bitfile *ld);
-static uint8_t spectral_data(ic_stream *ics, bitfile *ld, int16_t *spectral_data);
+static uint8_t spectral_data(ic_stream *ics, bitfile *ld, int16_t *spectral_data,
+                             uint16_t frame_len);
 static uint16_t extension_payload(bitfile *ld, drc_info *drc, uint16_t count);
 static void pulse_data(pulse_info *pul, bitfile *ld);
 static void tns_data(ic_stream *ics, tns_info *tns, bitfile *ld);
-static void ltp_data(ic_stream *ics, ltp_info *ltp, bitfile *ld);
+static void ltp_data(ic_stream *ics, ltp_info *ltp, bitfile *ld,
+                     uint8_t object_type);
 static uint8_t adts_fixed_header(adts_header *adts, bitfile *ld);
 static void adts_variable_header(adts_header *adts, bitfile *ld);
 static void adts_error_check(adts_header *adts, bitfile *ld);
--- a/libfaad/tns.c
+++ b/libfaad/tns.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: tns.c,v 1.3 2002/02/20 13:05:57 menno Exp $
+** $Id: tns.c,v 1.4 2002/02/25 19:58:33 menno Exp $
 **/
 
 #include "common.h"
@@ -54,9 +54,9 @@
                 tns->coef_compress[w][f], tns->coef[w][f], lpc);
 
             start = ics->swb_offset[min(bottom,
-                min(tns_max_bands(ics, sr_index), ics->max_sfb))];
+                min(tns_max_bands(ics, sr_index, object_type), ics->max_sfb))];
             end = ics->swb_offset[min(top,
-                min(tns_max_bands(ics, sr_index), ics->max_sfb))];
+                min(tns_max_bands(ics, sr_index, object_type), ics->max_sfb))];
 
             if ((size = end - start) <= 0)
                 continue;
@@ -102,9 +102,9 @@
                 tns->coef_compress[w][f], tns->coef[w][f], lpc);
 
             start = ics->swb_offset[min(bottom,
-                min(tns_max_bands(ics, sr_index), ics->max_sfb))];
+                min(tns_max_bands(ics, sr_index, object_type), ics->max_sfb))];
             end = ics->swb_offset[min(top,
-                min(tns_max_bands(ics, sr_index), ics->max_sfb))];
+                min(tns_max_bands(ics, sr_index, object_type), ics->max_sfb))];
 
             if ((size = end - start) <= 0)
                 continue;
@@ -235,7 +235,7 @@
     }
 }
 
-static uint8_t tns_max_bands_table[12][4] =
+static uint8_t tns_max_bands_table[12][5] =
 {
     /* entry for each sampling rate
      * 1    Main/LC long window
@@ -242,26 +242,29 @@
      * 2    Main/LC short window
      * 3    SSR long window
      * 4    SSR short window
+     * 5    LD 512 window
      */
-    { 31,  9, 28, 7 },       /* 96000 */
-    { 31,  9, 28, 7 },       /* 88200 */
-    { 34, 10, 27, 7 },       /* 64000 */
-    { 40, 14, 26, 6 },       /* 48000 */
-    { 42, 14, 26, 6 },       /* 44100 */
-    { 51, 14, 26, 6 },       /* 32000 */
-    { 46, 14, 29, 7 },       /* 24000 */
-    { 46, 14, 29, 7 },       /* 22050 */
-    { 42, 14, 23, 8 },       /* 16000 */
-    { 42, 14, 23, 8 },       /* 12000 */
-    { 42, 14, 23, 8 },       /* 11025 */
-    { 39, 14, 19, 7 },       /* 8000  */
+    { 31,  9, 28, 7, 0  },       /* 96000 */
+    { 31,  9, 28, 7, 0  },       /* 88200 */
+    { 34, 10, 27, 7, 0  },       /* 64000 */
+    { 40, 14, 26, 6, 31 },       /* 48000 */
+    { 42, 14, 26, 6, 32 },       /* 44100 */
+    { 51, 14, 26, 6, 37 },       /* 32000 */
+    { 46, 14, 29, 7, 31 },       /* 24000 */
+    { 46, 14, 29, 7, 31 },       /* 22050 */
+    { 42, 14, 23, 8, 0  },       /* 16000 */
+    { 42, 14, 23, 8, 0  },       /* 12000 */
+    { 42, 14, 23, 8, 0  },       /* 11025 */
+    { 39, 14, 19, 7, 0  },       /* 8000  */
 };
 
-static uint8_t tns_max_bands(ic_stream *ics, uint8_t sr_index)
+static uint8_t tns_max_bands(ic_stream *ics, uint8_t sr_index,
+                             uint8_t object_type)
 {
     uint8_t i;
 
     i = (ics->window_sequence == EIGHT_SHORT_SEQUENCE) ? 1 : 0;
+    i = (object_type == LD) ? 5 : i;
 
     return tns_max_bands_table[sr_index][i];
 }
@@ -285,6 +288,7 @@
         {
         case MAIN:
         case LTP:
+        case LD:
             return 20;
         case LC:
         case SSR:
--- a/libfaad/tns.h
+++ b/libfaad/tns.h
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: tns.h,v 1.2 2002/02/18 10:01:05 menno Exp $
+** $Id: tns.h,v 1.3 2002/02/25 19:58:33 menno Exp $
 **/
 
 #ifndef __TNS_H__
@@ -41,7 +41,7 @@
                           uint8_t order);
 static void tns_ma_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *lpc,
                           uint8_t order);
-static uint8_t tns_max_bands(ic_stream *ics, uint8_t sr_index);
+static uint8_t tns_max_bands(ic_stream *ics, uint8_t sr_index, uint8_t object_type);
 static uint8_t tns_max_order(ic_stream *ics, uint8_t sr_index,
                          uint8_t object_type);
 
--- a/plugins/in_mp4/in_mp4.c
+++ b/plugins/in_mp4/in_mp4.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: in_mp4.c,v 1.8 2002/02/18 10:01:05 menno Exp $
+** $Id: in_mp4.c,v 1.9 2002/02/25 19:58:33 menno Exp $
 **/
 
 #define WIN32_LEAN_AND_MEAN
@@ -110,11 +110,11 @@
 {
     /* find AAC track */
     int i, rc;
-	int numTracks = MP4GetNumberOfTracks(infile, NULL);
+	int numTracks = MP4GetNumberOfTracks(infile, NULL, 0);
 
 	for (i = 0; i < numTracks; i++)
     {
-        MP4TrackId trackId = MP4FindTrackId(infile, i, NULL);
+        MP4TrackId trackId = MP4FindTrackId(infile, i, NULL, 0);
         const char* trackType = MP4GetTrackType(infile, trackId);
 
         if (!strcmp(trackType, MP4_AUDIO_TRACK_TYPE))
@@ -145,11 +145,11 @@
 {
     /* find AAC track */
     int i;
-	int numTracks = MP4GetNumberOfTracks(infile, NULL);
+	int numTracks = MP4GetNumberOfTracks(infile, NULL, 0);
 
 	for (i = 0; i < numTracks; i++)
     {
-        MP4TrackId trackId = MP4FindTrackId(infile, i, NULL);
+        MP4TrackId trackId = MP4FindTrackId(infile, i, NULL, 0);
         const char* trackType = MP4GetTrackType(infile, trackId);
 
         if (!strcmp(trackType, MP4_AUDIO_TRACK_TYPE))
@@ -166,11 +166,11 @@
 {
     /* find AAC track */
     int i;
-	int numTracks = MP4GetNumberOfTracks(infile, NULL);
+	int numTracks = MP4GetNumberOfTracks(infile, NULL, 0);
 
 	for (i = 0; i < numTracks; i++)
     {
-        MP4TrackId trackId = MP4FindTrackId(infile, i, NULL);
+        MP4TrackId trackId = MP4FindTrackId(infile, i, NULL, 0);
         const char* trackType = MP4GetTrackType(infile, trackId);
 
         if (!strcmp(trackType, MP4_VIDEO_TRACK_TYPE))
@@ -272,9 +272,25 @@
         "Reserved",
         "Reserved",
         "MPEG-4 TTSI",
+        "MPEG-4 Main synthetic",
         "MPEG-4 Wavetable synthesis",
         "MPEG-4 General MIDI",
         "MPEG-4 Algorithmic Synthesis and Audio FX",
+        /* defined in MPEG-4 version 2 */
+        "MPEG-4 ER AAC LC",
+        "Reserved",
+        "MPEG-4 ER AAC LTP",
+        "MPEG-4 ER AAC Scalable",
+        "MPEG-4 ER TwinVQ",
+        "MPEG-4 ER BSAC",
+        "MPEG-4 ER AAC LD",
+        "MPEG-4 ER CELP",
+        "MPEG-4 ER HVXC",
+        "MPEG-4 ER HILN",
+        "MPEG-4 ER Parametric",
+        "Reserved",
+        "Reserved",
+        "Reserved",
         "Reserved"
     };
     static int numMpeg4AudioTypes =