shithub: aacdec

Download patch

ref: b00a2415ffe2895620baf6bae968d547cc723f21
parent: c44c0332357abb38513127baeb4303c2c4663e44
author: menno <menno>
date: Sun Feb 16 13:17:11 EST 2003

Better bitstream error handling, it's not possible to read more bits than in the input buffer
Some small speedups

--- a/aacDECdrop/audio.c
+++ b/aacDECdrop/audio.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: audio.c,v 1.7 2002/08/26 19:08:39 menno Exp $
+** $Id: audio.c,v 1.8 2003/02/16 18:17:09 menno Exp $
 **/
 
 #ifdef _WIN32
@@ -132,7 +132,7 @@
 
     *p++ = 'R'; *p++ = 'I'; *p++ = 'F'; *p++ = 'F';
 
-    word32 = data_size + (44 - 8) < (float)MAXWAVESIZE ?
+    word32 = (data_size + (44 - 8) < (float)MAXWAVESIZE) ?
         (unsigned long)data_size + (44 - 8)  :  (unsigned long)MAXWAVESIZE;
     *p++ = (unsigned char)(word32 >>  0);
     *p++ = (unsigned char)(word32 >>  8);
@@ -160,7 +160,7 @@
     *p++ = (unsigned char)(aufile->samplerate >> 16);
     *p++ = (unsigned char)(aufile->samplerate >> 24);
 
-    word32 *= bytes * aufile->channels;
+    word32 = aufile->samplerate * bytes * aufile->channels;
     *p++ = (unsigned char)(word32 >>  0);
     *p++ = (unsigned char)(word32 >>  8);
     *p++ = (unsigned char)(word32 >> 16);
--- a/aacDECdrop/audio.h
+++ b/aacDECdrop/audio.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: audio.h,v 1.6 2002/08/26 19:08:39 menno Exp $
+** $Id: audio.h,v 1.7 2003/02/16 18:17:09 menno Exp $
 **/
 
 #ifndef AUDIO_H_INCLUDED
@@ -28,10 +28,8 @@
 
 #define MAXWAVESIZE     4294967040LU
 
-enum {
-    OUTPUT_WAV = 1,
-    OUTPUT_RAW
-} output_format;
+#define OUTPUT_WAV 1
+#define OUTPUT_RAW 2
 
 typedef struct
 {
--- a/common/mp4v2/libmp4v2_st60.vcproj
+++ b/common/mp4v2/libmp4v2_st60.vcproj
@@ -71,7 +71,7 @@
 			<Tool
 				Name="VCWebServiceProxyGeneratorTool"/>
 			<IntelOptions
-				CompilerName="0"/>
+				CompilerName="1"/>
 		</Configuration>
 		<Configuration
 			Name="Debug|Win32"
--- a/frontend/faad.vcproj
+++ b/frontend/faad.vcproj
@@ -33,15 +33,13 @@
 				WarningLevel="3"
 				SuppressStartupBanner="TRUE"
 				DebugInformationFormat="4"
-				CompileAs="0"
-				AdditionalOptions="">
+				CompileAs="0">
 				<IntelOptions
 					Optimization="0"
 					MinimalRebuild="1"
 					BasicRuntimeChecks="3"
 					RuntimeLibrary="1"
-					AllOptions="/c  /I &quot;../include&quot; /I &quot;../common/mp4v2&quot; /I &quot;../common/faad&quot; /ZI /nologo /W3 /Od /D &quot;WIN32&quot; /D &quot;_DEBUG&quot; /D &quot;_CONSOLE&quot; /D &quot;_MBCS&quot; /Gm /EHsc /RTC1 /MTd /YX&quot;StdAfx.h&quot; /Fp&quot;.\Debug/faad.pch&quot; /Fo&quot;.\Debug/&quot; /Fd&quot;.\Debug/&quot; /Gd"
-					MSOriginalAdditionalOptions=""/>
+					AllOptions="/c  /I &quot;../include&quot; /I &quot;../common/mp4v2&quot; /I &quot;../common/faad&quot; /ZI /nologo /W3 /Od /D &quot;WIN32&quot; /D &quot;_DEBUG&quot; /D &quot;_CONSOLE&quot; /D &quot;_MBCS&quot; /Gm /EHsc /RTC1 /MTd /YX&quot;StdAfx.h&quot; /Fp&quot;.\Debug/faad.pch&quot; /Fo&quot;.\Debug/&quot; /Fd&quot;.\Debug/&quot; /Gd"/>
 			</Tool>
 			<Tool
 				Name="VCCustomBuildTool"/>
@@ -56,8 +54,7 @@
 				ProgramDatabaseFile=".\Debug/faad.pdb"
 				SubSystem="1">
 				<IntelOptions
-					AllOptions="/NOLOGO /OUT:&quot;.\Debug/faad.exe&quot; /INCREMENTAL ws2_32.lib odbc32.lib odbccp32.lib /DEBUG /PDB:&quot;.\Debug/faad.pdb&quot; /SUBSYSTEM:CONSOLE /TLBID:1 /MACHINE:I386 &quot;e:\aac\cvsroot\faad2\libfaad\Debug\libfaad.lib&quot; &quot;e:\aac\cvsroot\faad2\common\mp4v2\ST_Debug\libmp4v2_st60.lib&quot; &quot;e:\aac\cvsroot\faad2\libfaad\Debug\libfaad.lib&quot; &quot;e:\aac\cvsroot\faad2\common\mp4v2\ST_Debug\libmp4v2_st60.lib&quot; &quot;e:\aac\cvsroot\faad2\libfaad\Debug\libfaad.lib&quot; &quot;e:\aac\cvsroot\faad2\common\mp4v2\ST_Debug\libmp4v2_st60.lib&quot; kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib"
-					MSOriginalAdditionalOptions="/MACHINE:I386 &quot;e:\aac\cvsroot\faad2\libfaad\Debug\libfaad.lib&quot; &quot;e:\aac\cvsroot\faad2\common\mp4v2\ST_Debug\libmp4v2_st60.lib&quot; &quot;e:\aac\cvsroot\faad2\libfaad\Debug\libfaad.lib&quot; &quot;e:\aac\cvsroot\faad2\common\mp4v2\ST_Debug\libmp4v2_st60.lib&quot; &quot;e:\aac\cvsroot\faad2\libfaad\Debug\libfaad.lib&quot; &quot;e:\aac\cvsroot\faad2\common\mp4v2\ST_Debug\libmp4v2_st60.lib&quot;"/>
+					AllOptions="/NOLOGO /OUT:&quot;.\Debug/faad.exe&quot; /INCREMENTAL ws2_32.lib odbc32.lib odbccp32.lib /DEBUG /PDB:&quot;.\Debug/faad.pdb&quot; /SUBSYSTEM:CONSOLE /TLBID:1 /MACHINE:I386 &quot;e:\aac\cvsroot\faad2\libfaad\Debug\libfaad.lib&quot; &quot;e:\aac\cvsroot\faad2\common\mp4v2\ST_Debug\libmp4v2_st60.lib&quot; &quot;e:\aac\cvsroot\faad2\libfaad\Debug\libfaad.lib&quot; &quot;e:\aac\cvsroot\faad2\common\mp4v2\ST_Debug\libmp4v2_st60.lib&quot; &quot;e:\aac\cvsroot\faad2\libfaad\Debug\libfaad.lib&quot; &quot;e:\aac\cvsroot\faad2\common\mp4v2\ST_Debug\libmp4v2_st60.lib&quot; kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib"/>
 			</Tool>
 			<Tool
 				Name="VCMIDLTool"
@@ -106,8 +103,7 @@
 				ProgramDataBaseFileName=".\Release/"
 				WarningLevel="3"
 				SuppressStartupBanner="TRUE"
-				CompileAs="0"
-				AdditionalOptions="">
+				CompileAs="0">
 				<IntelOptions
 					Optimization="2"
 					GlobalOptimizations="1"
@@ -117,14 +113,13 @@
 					RuntimeLibrary="0"
 					BufferSecurityCheck="1"
 					FunctionLevelLinking="1"
-					AllOptions="/c  /I &quot;../include&quot; /I &quot;../common/mp4v2&quot; /I &quot;../common/faad&quot; /nologo /W3 /O2 /Og /Ob1 /Oy /D &quot;WIN32&quot; /D &quot;NDEBUG&quot; /D &quot;_CONSOLE&quot; /D &quot;_MBCS&quot; /GF /FD /EHsc /MT /GS /Gy /YX&quot;StdAfx.h&quot; /Fp&quot;.\Release/faad.pch&quot; /Fo&quot;.\Release/&quot; /Fd&quot;.\Release/&quot; /Gd"
-					MSOriginalAdditionalOptions=""/>
+					AllOptions="/c  /I &quot;../include&quot; /I &quot;../common/mp4v2&quot; /I &quot;../common/faad&quot; /nologo /W3 /O2 /Og /Ob1 /Oy /D &quot;WIN32&quot; /D &quot;NDEBUG&quot; /D &quot;_CONSOLE&quot; /D &quot;_MBCS&quot; /GF /FD /EHsc /MT /GS /Gy /YX&quot;StdAfx.h&quot; /Fp&quot;.\Release/faad.pch&quot; /Fo&quot;.\Release/&quot; /Fd&quot;.\Release/&quot; /Gd"/>
 			</Tool>
 			<Tool
 				Name="VCCustomBuildTool"/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalOptions="/MACHINE:I386 &quot;..\libfaad\Release\libfaad.lib&quot; &quot;..\common\mp4v2\ST_Release\libmp4v2_st60.lib&quot;"
+				AdditionalOptions="/MACHINE:I386 &quot;..\libfaad\Release\libfaad.lib&quot; &quot;..\common\mp4v2\ST_Release\libmp4v2_st60.lib&quot; &quot;e:\cvs\audiocoding\faad2\libfaad\Release\libfaad.lib&quot; &quot;e:\cvs\audiocoding\faad2\common\mp4v2\ST_Release\libmp4v2_st60.lib&quot;"
 				AdditionalDependencies="ws2_32.lib"
 				OutputFile=".\Release/faad.exe"
 				LinkIncremental="1"
@@ -131,8 +126,7 @@
 				SuppressStartupBanner="TRUE"
 				SubSystem="1">
 				<IntelOptions
-					AllOptions="/NOLOGO /OUT:&quot;.\Release/faad.exe&quot; /INCREMENTAL:NO ws2_32.lib /SUBSYSTEM:CONSOLE /TLBID:1 /MACHINE:I386 &quot;..\libfaad\Release\libfaad.lib&quot; &quot;..\common\mp4v2\ST_Release\libmp4v2_st60.lib&quot; kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib"
-					MSOriginalAdditionalOptions="/MACHINE:I386 &quot;..\libfaad\Release\libfaad.lib&quot; &quot;..\common\mp4v2\ST_Release\libmp4v2_st60.lib&quot;"/>
+					AllOptions="/NOLOGO /OUT:&quot;.\Release/faad.exe&quot; /INCREMENTAL:NO ws2_32.lib /SUBSYSTEM:CONSOLE /TLBID:1 /MACHINE:I386 &quot;..\libfaad\Release\libfaad.lib&quot; &quot;..\common\mp4v2\ST_Release\libmp4v2_st60.lib&quot; kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib"/>
 			</Tool>
 			<Tool
 				Name="VCMIDLTool"
--- a/libfaad/bits.c
+++ b/libfaad/bits.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: bits.c,v 1.18 2002/12/10 19:45:35 menno Exp $
+** $Id: bits.c,v 1.19 2003/02/16 18:17:10 menno Exp $
 **/
 
 #include "common.h"
@@ -53,17 +53,22 @@
     ld->tail = ((uint32_t*)ld->buffer + 2);
 
     ld->bits_left = 32;
+
+    ld->bytes_used = 0;
+    ld->no_more_reading = 0;
+    ld->error = 0;
 }
 
 void faad_endbits(bitfile *ld)
 {
-    if (ld->buffer) free(ld->buffer);
+    if (ld)
+        if (ld->buffer) free(ld->buffer);
 }
 
 
 uint32_t faad_get_processed_bits(bitfile *ld)
 {
-    return 8 * (4*(ld->tail - ld->start) - 4) - (ld->bits_left);
+    return 8*(ld->bytes_used + (32 - ld->bits_left));
 }
 
 uint8_t faad_byte_align(bitfile *ld)
@@ -153,4 +158,8 @@
     ld->bits_left = bits_in_buffer % 32;
     if (ld->bits_left == 0)
         ld->bits_left = 32;
+
+    ld->bytes_used = 0;
+    ld->no_more_reading = 0;
+    ld->error = 0;
 }
--- a/libfaad/bits.h
+++ b/libfaad/bits.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: bits.h,v 1.15 2002/12/10 19:45:35 menno Exp $
+** $Id: bits.h,v 1.16 2003/02/16 18:17:10 menno Exp $
 **/
 
 #ifndef __BITS_H__
@@ -41,6 +41,9 @@
     uint32_t bufb;
     uint32_t bits_left;
     uint32_t buffer_size; /* size of the buffer in bytes */
+    uint32_t bytes_used;
+    uint8_t no_more_reading;
+    uint8_t error;
     uint32_t *tail;
     uint32_t *start;
     void *buffer;
@@ -117,6 +120,11 @@
 #endif
         ld->bufb = tmp;
         ld->bits_left += (32 - bits);
+        ld->bytes_used += 4;
+        if (ld->bytes_used == ld->buffer_size)
+            ld->no_more_reading = 1;
+        if (ld->bytes_used > ld->buffer_size)
+            ld->error = 1;
     }
 }
 
@@ -125,6 +133,9 @@
 {
     uint32_t ret;
 
+    if (ld->no_more_reading)
+        return 0;
+
     if (n == 0)
         return 0;
 
@@ -141,7 +152,15 @@
 
 static INLINE uint8_t faad_get1bit(bitfile *ld DEBUGDEC)
 {
-    return (uint8_t)faad_getbits(ld, 1 DEBUGVAR(print,var,dbg));
+    uint8_t r;
+
+    if (ld->bits_left == 0)
+        return (uint8_t)faad_getbits(ld, 1 DEBUGVAR(print,var,dbg));
+
+    ld->bits_left--;
+    r = (ld->bufa >> ld->bits_left) & 1;
+
+    return r;
 }
 
 /* reversed bitreading routines */
@@ -189,6 +208,12 @@
         ld->bufb = tmp;
         ld->start--;
         ld->bits_left += (32 - bits);
+
+        ld->bytes_used += 4;
+        if (ld->bytes_used == ld->buffer_size)
+            ld->no_more_reading = 1;
+        if (ld->bytes_used > ld->buffer_size)
+            ld->error = 1;
     }
 }
 
@@ -196,6 +221,9 @@
                                         DEBUGDEC)
 {
     uint32_t ret;
+
+    if (ld->no_more_reading)
+        return 0;
 
     if (n == 0)
         return 0;
--- 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.50 2003/02/09 20:42:49 menno Exp $
+** $Id: decoder.c,v 1.51 2003/02/16 18:17:11 menno Exp $
 **/
 
 #include "common.h"
@@ -173,6 +173,8 @@
                 2 : adts.channel_configuration;
         }
 
+        if (ld.error)
+            return -1;
         faad_endbits(&ld);
     }
     hDecoder->channelConfiguration = *channels;
@@ -426,6 +428,11 @@
 
     /* no more bit reading after this */
     hInfo->bytesconsumed = bit2byte(faad_get_processed_bits(ld));
+    if (ld->error)
+    {
+        hInfo->error = 14;
+        goto error;
+    }
     faad_endbits(ld);
     if (ld) free(ld);
     ld = NULL;
--- 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.7 2002/12/05 18:01:55 menno Exp $
+** $Id: error.c,v 1.8 2003/02/16 18:17:11 menno Exp $
 **/
 
 #include "common.h"
@@ -36,5 +36,6 @@
     "Error decoding huffman codeword (bitstream error)",
     "Non existent huffman codebook number found",
     "Maximum number of channels exceeded",
-    "Maximum number of bitstream elements exceeded"
+    "Maximum number of bitstream elements exceeded",
+    "Input data buffer too small"
 };
\ No newline at end of file
--- a/libfaad/libfaad.dsp
+++ b/libfaad/libfaad.dsp
@@ -42,7 +42,7 @@
 # PROP Target_Dir ""
 MTL=midl.exe
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /G6 /MD /W3 /GX /O2 /I "fftw" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "FFTW_ENABLE_FLOAT" /YX /FD /c
+# ADD CPP /nologo /G6 /MD /W3 /GX /O2 /Ob1 /I "fftw" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "FFTW_ENABLE_FLOAT" /YX /FD /c
 # ADD BASE RSC /l 0x413 /d "NDEBUG"
 # ADD RSC /l 0x413 /d "NDEBUG"
 BSC32=bscmake.exe
--- a/libfaad/libfaad.vcproj
+++ b/libfaad/libfaad.vcproj
@@ -21,8 +21,8 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="fftw"
-				PreprocessorDefinitions="_DEBUG,WIN32,_LIB,FFTW_ENABLE_FLOAT"
+				AdditionalIncludeDirectories=""
+				PreprocessorDefinitions="_DEBUG,WIN32,_LIB"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
 				UsePrecompiledHeader="2"
@@ -33,13 +33,15 @@
 				WarningLevel="3"
 				SuppressStartupBanner="TRUE"
 				DebugInformationFormat="4"
-				CompileAs="0">
+				CompileAs="0"
+				AdditionalOptions="">
 				<IntelOptions
 					Optimization="0"
 					MinimalRebuild="1"
 					BasicRuntimeChecks="3"
 					RuntimeLibrary="3"
-					AllOptions="/c  /I &quot;fftw&quot; /ZI /nologo /W3 /Od /D &quot;_DEBUG&quot; /D &quot;WIN32&quot; /D &quot;_LIB&quot; /D &quot;FFTW_ENABLE_FLOAT&quot; /D &quot;_MBCS&quot; /Gm /EHsc /RTC1 /MDd /YX&quot;StdAfx.h&quot; /Fp&quot;.\Debug/libfaad.pch&quot; /Fo&quot;.\Debug/&quot; /Fd&quot;.\Debug/&quot; /Gd"/>
+					AllOptions="/c  /ZI /nologo /W3 /Od /D &quot;_DEBUG&quot; /D &quot;WIN32&quot; /D &quot;_LIB&quot; /D &quot;_MBCS&quot; /Gm /EHsc /RTC1 /MDd /YX&quot;StdAfx.h&quot; /Fp&quot;.\Debug/libfaad.pch&quot; /Fo&quot;.\Debug/&quot; /Fd&quot;.\Debug/&quot; /Gd"
+					MSOriginalAdditionalOptions=""/>
 			</Tool>
 			<Tool
 				Name="VCCustomBuildTool"/>
@@ -46,9 +48,11 @@
 			<Tool
 				Name="VCLibrarianTool"
 				OutputFile=".\Debug\libfaad.lib"
-				SuppressStartupBanner="TRUE">
+				SuppressStartupBanner="TRUE"
+				AdditionalOptions="">
 				<IntelOptions
-					AllOptions="/OUT:&quot;.\Debug\libfaad.lib&quot; /NOLOGO"/>
+					AllOptions="/OUT:&quot;.\Debug\libfaad.lib&quot; /NOLOGO"
+					MSOriginalAdditionalOptions=""/>
 			</Tool>
 			<Tool
 				Name="VCMIDLTool"/>
@@ -75,24 +79,34 @@
 			CharacterSet="2">
 			<Tool
 				Name="VCCLCompilerTool"
+				GlobalOptimizations="FALSE"
 				InlineFunctionExpansion="1"
+				EnableIntrinsicFunctions="FALSE"
+				FavorSizeOrSpeed="0"
 				OptimizeForProcessor="0"
-				AdditionalIncludeDirectories="fftw"
-				PreprocessorDefinitions="NDEBUG,WIN32,_LIB,FFTW_ENABLE_FLOAT"
+				AdditionalIncludeDirectories=""
+				PreprocessorDefinitions="NDEBUG,WIN32,_LIB"
 				StringPooling="TRUE"
 				RuntimeLibrary="0"
 				EnableFunctionLevelLinking="TRUE"
 				UsePrecompiledHeader="2"
 				PrecompiledHeaderFile=".\Release/libfaad.pch"
+				AssemblerOutput="0"
 				AssemblerListingLocation=".\Release/"
 				ObjectFile=".\Release/"
 				ProgramDataBaseFileName=".\Release/"
 				WarningLevel="3"
 				SuppressStartupBanner="TRUE"
-				CompileAs="0">
+				CompileAs="0"
+				AdditionalOptions="">
 				<IntelOptions
+					AssemblyOutput="0"
+					PGOPhase="0"
 					Optimization="2"
+					GlobalOptimizations="0"
 					InlineFuncExpansion="1"
+					IntrinsicFuncs="0"
+					FavorSizeSpeed="0"
 					OmitFramePtrs="1"
 					OptimProc="0"
 					UseProcExt="0"
@@ -101,7 +115,8 @@
 					RuntimeLibrary="0"
 					BufferSecurityCheck="1"
 					FunctionLevelLinking="1"
-					AllOptions="/c  /I &quot;fftw&quot; /nologo /W3 /O2 /Ob1 /Oy /D &quot;NDEBUG&quot; /D &quot;WIN32&quot; /D &quot;_LIB&quot; /D &quot;FFTW_ENABLE_FLOAT&quot; /D &quot;_MBCS&quot; /GF /FD /EHsc /MT /GS /Gy /YX&quot;StdAfx.h&quot; /Fp&quot;.\Release/libfaad.pch&quot; /Fo&quot;.\Release/&quot; /Fd&quot;.\Release/&quot; /Gd"/>
+					AllOptions="/c  /nologo /W3 /O2 /Ob1 /Oy /D &quot;NDEBUG&quot; /D &quot;WIN32&quot; /D &quot;_LIB&quot; /D &quot;_MBCS&quot; /GF /FD /EHsc /MT /GS /Gy /YX&quot;StdAfx.h&quot; /Fp&quot;.\Release/libfaad.pch&quot; /Fo&quot;.\Release/&quot; /Fd&quot;.\Release/&quot; /Gd"
+					MSOriginalAdditionalOptions=""/>
 			</Tool>
 			<Tool
 				Name="VCCustomBuildTool"/>
@@ -108,9 +123,11 @@
 			<Tool
 				Name="VCLibrarianTool"
 				OutputFile=".\Release\libfaad.lib"
-				SuppressStartupBanner="TRUE">
+				SuppressStartupBanner="TRUE"
+				AdditionalOptions="">
 				<IntelOptions
-					AllOptions="/OUT:&quot;.\Release\libfaad.lib&quot; /NOLOGO"/>
+					AllOptions="/OUT:&quot;.\Release\libfaad.lib&quot; /NOLOGO"
+					MSOriginalAdditionalOptions=""/>
 			</Tool>
 			<Tool
 				Name="VCMIDLTool"/>
@@ -126,6 +143,9 @@
 				Culture="1043"/>
 			<Tool
 				Name="VCWebServiceProxyGeneratorTool"/>
+			<IntelOptions
+				AssemblyOutput="0"
+				PGOPhase="0"/>
 		</Configuration>
 	</Configurations>
 	<Files>
--- 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.18 2002/12/22 19:58:31 menno Exp $
+** $Id: specrec.c,v 1.19 2003/02/16 18:17:11 menno Exp $
 **/
 
 /*
@@ -256,39 +256,36 @@
 
 static INLINE real_t iquant(int16_t q)
 {
-    if (q > 0)
+    int16_t sgn = 1;
+
+    if (q == 0) return 0;
+
+    if (q < 0)
     {
-        if (q < IQ_TABLE_SIZE)
-            return iq_table[q];
-        else
-            return iq_table[q>>3] * 16;
-    } else if (q < 0) {
         q = -q;
-        if (q < IQ_TABLE_SIZE)
-            return -iq_table[q];
-        else
-          return -iq_table[q>>3] * 16;
-    } else {
-        return 0;
+        sgn = -1;
     }
+
+    if (q >= IQ_TABLE_SIZE)
+        return sgn * iq_table[q>>3] * 16;
+
+    return sgn * iq_table[q];
 }
 
 void inverse_quantization(real_t *x_invquant, int16_t *x_quant, uint16_t frame_len)
 {
-    int8_t i;
+    int16_t i;
     int16_t *in_ptr = x_quant;
     real_t *out_ptr = x_invquant;
 
-    for(i = frame_len/8-1; i >= 0; --i)
+    for(i = frame_len/4-1; i >= 0; --i)
     {
-        *out_ptr++ = iquant(*in_ptr++);
-        *out_ptr++ = iquant(*in_ptr++);
-        *out_ptr++ = iquant(*in_ptr++);
-        *out_ptr++ = iquant(*in_ptr++);
-        *out_ptr++ = iquant(*in_ptr++);
-        *out_ptr++ = iquant(*in_ptr++);
-        *out_ptr++ = iquant(*in_ptr++);
-        *out_ptr++ = iquant(*in_ptr++);
+        out_ptr[0] = iquant(in_ptr[0]);
+        out_ptr[1] = iquant(in_ptr[1]);
+        out_ptr[2] = iquant(in_ptr[2]);
+        out_ptr[3] = iquant(in_ptr[3]);
+        out_ptr += 4;
+        in_ptr += 4;
     }
 }