shithub: aacdec

Download patch

ref: 189f5ac4c6ba5d0f872bbdd6429ef1ae40514e72
parent: 7c895402b9b3f9798c78f78a0036983839a1372e
author: menno <menno>
date: Mon Jan 5 09:05:12 EST 2004

Xine cleanup patch
Temporarily disabled SSE optimisations
MPEG4IP cleanup patch
other small changes

--- a/common/mp4ff/mp4atom.c
+++ b/common/mp4ff/mp4atom.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: mp4atom.c,v 1.12 2003/12/23 18:53:24 menno Exp $
+** $Id: mp4atom.c,v 1.13 2004/01/05 14:05:11 menno Exp $
 **/
 
 #include <stdlib.h>
--- a/common/mp4ff/mp4ff.c
+++ b/common/mp4ff/mp4ff.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: mp4ff.c,v 1.12 2003/12/23 18:53:24 menno Exp $
+** $Id: mp4ff.c,v 1.13 2004/01/05 14:05:11 menno Exp $
 **/
 
 #include <stdlib.h>
--- a/common/mp4ff/mp4ff.h
+++ b/common/mp4ff/mp4ff.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: mp4ff.h,v 1.15 2003/12/23 18:53:24 menno Exp $
+** $Id: mp4ff.h,v 1.16 2004/01/05 14:05:11 menno Exp $
 **/
 
 #ifndef MP4FF_H
--- a/common/mp4ff/mp4ffint.h
+++ b/common/mp4ff/mp4ffint.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: mp4ffint.h,v 1.9 2003/12/23 18:53:24 menno Exp $
+** $Id: mp4ffint.h,v 1.10 2004/01/05 14:05:11 menno Exp $
 **/
 
 #ifndef MP4FF_INTERNAL_H
--- a/common/mp4ff/mp4meta.c
+++ b/common/mp4ff/mp4meta.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: mp4meta.c,v 1.9 2003/12/23 18:53:24 menno Exp $
+** $Id: mp4meta.c,v 1.10 2004/01/05 14:05:11 menno Exp $
 **/
 
 #ifdef USE_TAGGING
--- a/common/mp4ff/mp4sample.c
+++ b/common/mp4ff/mp4sample.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: mp4sample.c,v 1.11 2003/12/29 18:36:01 menno Exp $
+** $Id: mp4sample.c,v 1.15 2004/01/11 15:52:19 menno Exp $
 **/
 
 #include <stdlib.h>
--- a/common/mp4ff/mp4util.c
+++ b/common/mp4ff/mp4util.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: mp4util.c,v 1.11 2003/12/23 18:53:24 menno Exp $
+** $Id: mp4util.c,v 1.15 2004/01/11 15:52:19 menno Exp $
 **/
 
 #include "mp4ffint.h"
--- a/configure.in
+++ b/configure.in
@@ -68,7 +68,7 @@
 
 external_mp4v2=yes
 AC_CHECK_LIB(mp4v2, MP4Create, , external_mp4v2=no, -lstdc++)
-AC_CHECK_LIB(mp4v2, MP4MetadataDelete, external_mp4v2=no, , -lstdc++)
+AC_CHECK_LIB(mp4v2, MP4MetadataDelete, , external_mp4v2=no, -lstdc++)
 AC_CHECK_HEADER(mp4.h, , external_mp4v2=no)
 
 AM_CONDITIONAL(WITH_MP4V2, false)
@@ -79,6 +79,7 @@
   AC_SUBST(MPEG4IP_PLAYER_PLUGIN_DIR)
   AC_MSG_NOTICE([*** Building with external mp4v2 ***])
 else
+  AC_MSG_NOTICE([*** Building with internal mp4v2 ***])
   AM_CONDITIONAL(HAVE_MPEG4IP, false)
   if test x$WITHMP4V2 = xyes; then
      AM_CONDITIONAL(WITH_MP4V2, true)
--- a/frontend/audio.c
+++ b/frontend/audio.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: audio.c,v 1.20 2003/11/02 20:24:03 menno Exp $
+** $Id: audio.c,v 1.21 2004/01/05 14:05:11 menno Exp $
 **/
 
 #ifdef _WIN32
--- a/frontend/audio.h
+++ b/frontend/audio.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: audio.h,v 1.11 2003/11/02 20:24:03 menno Exp $
+** $Id: audio.h,v 1.12 2004/01/05 14:05:11 menno Exp $
 **/
 
 #ifndef AUDIO_H_INCLUDED
--- a/frontend/main.c
+++ b/frontend/main.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: main.c,v 1.68 2003/12/17 14:43:15 menno Exp $
+** $Id: main.c,v 1.69 2004/01/05 14:05:11 menno Exp $
 **/
 
 #ifdef _WIN32
@@ -373,7 +373,8 @@
 
 int decodeAACfile(char *aacfile, char *sndfile, char *adts_fn, int to_stdout,
                   int def_srate, int object_type, int outputFormat, int fileType,
-                  int downMatrix, int infoOnly, int adts_out, int old_format)
+                  int downMatrix, int infoOnly, int adts_out, int old_format,
+                  float *song_length)
 {
     int tagsize;
     unsigned long samplerate;
@@ -500,6 +501,8 @@
         header_type = 2;
     }
 
+    *song_length = length;
+
     fill_buffer(&b);
     if ((bread = faacDecInit(hDecoder, b.buffer,
         b.bytes_into_buffer, &samplerate, &channels)) < 0)
@@ -680,7 +683,7 @@
 
 int decodeMP4file(char *mp4file, char *sndfile, char *adts_fn, int to_stdout,
                   int outputFormat, int fileType, int downMatrix, int noGapless,
-                  int infoOnly, int adts_out)
+                  int infoOnly, int adts_out, float *song_length)
 {
     int track;
     unsigned long samplerate;
@@ -807,6 +810,8 @@
         }
         seconds = (float)samples*(float)(f-1.0)/(float)mp4ASC.samplingFrequency;
 
+        *song_length = seconds;
+
         fprintf(stderr, "%s\t%.3f secs, %d ch, %d Hz\n\n", ot[(mp4ASC.objectTypeIndex > 5)?0:mp4ASC.objectTypeIndex],
             seconds, mp4ASC.channelsConfiguration, mp4ASC.samplingFrequency);
 
@@ -996,11 +1001,12 @@
     char audioFileName[255];
     char adtsFileName[255];
     unsigned char header[8];
+    float length = 0;
     FILE *hMP4File;
 
 /* System dependant types */
 #ifdef _WIN32
-    long begin, end;
+    long begin;
 #else
     clock_t begin;
 #endif
@@ -1007,16 +1013,25 @@
 
     unsigned long cap = faacDecGetCapabilities();
 
-    fprintf(stderr, " ****** Ahead Software MPEG-4 AAC Decoder V%s ******\n\n", FAAD2_VERSION);
-    fprintf(stderr, "        Build: %s\n", __DATE__);
-    fprintf(stderr, "        Copyright 2002-2003: Ahead Software AG\n");
-    fprintf(stderr, "        http://www.audiocoding.com\n");
+    fprintf(stderr, " *********** Ahead Software MPEG-4 AAC Decoder V%s ******************\n\n", FAAD2_VERSION);
+    fprintf(stderr, " Build: %s\n", __DATE__);
+    fprintf(stderr, " Copyright 2002-2004: Ahead Software AG\n");
+    fprintf(stderr, " http://www.audiocoding.com\n");
     if (cap & FIXED_POINT_CAP)
-        fprintf(stderr, "        Fixed point version\n");
+        fprintf(stderr, " Fixed point version\n");
     else
-        fprintf(stderr, "        Floating point version\n");
+        fprintf(stderr, " Floating point version\n");
     fprintf(stderr, "\n");
-    fprintf(stderr, " ****************************************************\n\n");
+    fprintf(stderr, " This program is free software; you can redistribute it and/or modify\n");
+    fprintf(stderr, " it under the terms of the GNU General Public License as published by\n");
+    fprintf(stderr, " the Free Software Foundation; either version 2 of the License, or\n");
+    fprintf(stderr, " (at your option) any later version.\n");
+    fprintf(stderr, "\n");
+    fprintf(stderr, " You should have received a copy of the GNU General Public License\n");
+    fprintf(stderr, " along with this program; if not, write to the Free Software\n");
+    fprintf(stderr, " Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n");
+    fprintf(stderr, "\n");
+    fprintf(stderr, " **************************************************************************\n\n");
 
     /* begin process command line */
     progName = argv[0];
@@ -1175,6 +1190,11 @@
     /* check for mp4 file */
     mp4file = 0;
     hMP4File = fopen(aacFileName, "rb");
+    if (!hMP4File)
+    {
+        fprintf(stderr, "Error opening file: %s\n", aacFileName);
+        return 1;
+    }
     fread(header, 1, 8, hMP4File);
     fclose(hMP4File);
     if (header[4] == 'f' && header[5] == 't' && header[6] == 'y' && header[7] == 'p')
@@ -1183,27 +1203,26 @@
     if (mp4file)
     {
         result = decodeMP4file(aacFileName, audioFileName, adtsFileName, writeToStdio,
-            outputFormat, format, downMatrix, noGapless, infoOnly, adts_out);
+            outputFormat, format, downMatrix, noGapless, infoOnly, adts_out, &length);
     } else {
         result = decodeAACfile(aacFileName, audioFileName, adtsFileName, writeToStdio,
             def_srate, object_type, outputFormat, format, downMatrix, infoOnly, adts_out,
-            old_format);
+            old_format, &length);
     }
 
     if (!result && !infoOnly)
     {
 #ifdef _WIN32
-        end = GetTickCount();
-        fprintf(stderr, "Decoding %s took: %5.2f sec.\n", aacFileName,
-            (float)(end-begin)/1000.0);
+        float dec_length = (float)(GetTickCount()-begin)/1000.0;
         SetConsoleTitle("FAAD");
 #else
         /* clock() grabs time since the start of the app but when we decode
            multiple files, each file has its own starttime (begin).
          */
-        fprintf(stderr, "Decoding %s took: %5.2f sec.\n", aacFileName,
-            (float)(clock() - begin)/(float)CLOCKS_PER_SEC);
+        float dec_length = (float)(clock() - begin)/(float)CLOCKS_PER_SEC;
 #endif
+        fprintf(stderr, "Decoding %s took: %5.2f sec. %5.2fx real-time.\n", aacFileName,
+            dec_length, length/dec_length);
     }
 
     return 0;
--- a/include/faad.h
+++ b/include/faad.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: faad.h,v 1.36 2003/11/14 15:16:43 menno Exp $
+** $Id: faad.h,v 1.37 2004/01/05 14:05:11 menno Exp $
 **/
 
 #ifndef __AACDEC_H__
@@ -167,9 +167,9 @@
 
 char* FAADAPI faacDecGetErrorMessage(unsigned char errcode);
 
-unsigned long FAADAPI faacDecGetCapabilities();
+unsigned long FAADAPI faacDecGetCapabilities(void);
 
-faacDecHandle FAADAPI faacDecOpen();
+faacDecHandle FAADAPI faacDecOpen(void);
 
 faacDecConfigurationPtr FAADAPI faacDecGetCurrentConfiguration(faacDecHandle hDecoder);
 
--- a/libfaad/analysis.h
+++ b/libfaad/analysis.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: analysis.h,v 1.10 2003/12/17 14:43:16 menno Exp $
+** $Id: analysis.h,v 1.11 2004/01/05 14:05:11 menno Exp $
 **/
 
 #ifndef __ANALYSIS_H__
--- a/libfaad/bits.c
+++ b/libfaad/bits.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: bits.c,v 1.29 2003/12/17 14:43:16 menno Exp $
+** $Id: bits.c,v 1.30 2004/01/05 14:05:11 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/bits.h
+++ b/libfaad/bits.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: bits.h,v 1.28 2003/12/17 14:43:16 menno Exp $
+** $Id: bits.h,v 1.29 2004/01/05 14:05:11 menno Exp $
 **/
 
 #ifndef __BITS_H__
--- a/libfaad/cfft.c
+++ b/libfaad/cfft.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: cfft.c,v 1.22 2003/12/23 18:41:42 menno Exp $
+** $Id: cfft.c,v 1.23 2004/01/05 14:05:11 menno Exp $
 **/
 
 /*
@@ -43,84 +43,115 @@
 #include "cfft_tab.h"
 
 
+/* static function declarations */
+#ifdef USE_SSE
+static void passf2pos_sse(const uint16_t l1, const complex_t *cc,
+                          complex_t *ch, const complex_t *wa);
+static void passf2pos_sse_ido(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+                              complex_t *ch, const complex_t *wa);
+static void passf4pos_sse_ido(const uint16_t ido, const uint16_t l1, const complex_t *cc, complex_t *ch,
+                              const complex_t *wa1, const complex_t *wa2, const complex_t *wa3);
+#endif
+static void passf2pos(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+                      complex_t *ch, const complex_t *wa);
+static void passf2neg(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+                      complex_t *ch, const complex_t *wa);
+static void passf3(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+                   complex_t *ch, const complex_t *wa1, const complex_t *wa2, const int8_t isign);
+static void passf4pos(const uint16_t ido, const uint16_t l1, const complex_t *cc, complex_t *ch,
+                      const complex_t *wa1, const complex_t *wa2, const complex_t *wa3);
+static void passf4neg(const uint16_t ido, const uint16_t l1, const complex_t *cc, complex_t *ch,
+                      const complex_t *wa1, const complex_t *wa2, const complex_t *wa3);
+static void passf5(const uint16_t ido, const uint16_t l1, const complex_t *cc, complex_t *ch,
+                   const complex_t *wa1, const complex_t *wa2, const complex_t *wa3,
+                   const complex_t *wa4, const int8_t isign);
+INLINE void cfftf1(uint16_t n, complex_t *c, complex_t *ch,
+                   const uint16_t *ifac, const complex_t *wa, const int8_t isign);
+static void cffti1(uint16_t n, complex_t *wa, uint16_t *ifac);
+
+
 /*----------------------------------------------------------------------
    passf2, passf3, passf4, passf5. Complex FFT passes fwd and bwd.
   ----------------------------------------------------------------------*/
 
-#ifdef USE_SSE
-static void passf2pos_sse(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+#if 0 //def USE_SSE
+static void passf2pos_sse(const uint16_t l1, const complex_t *cc,
                           complex_t *ch, const complex_t *wa)
 {
-    uint16_t i, k, ah, ac;
+    uint16_t k, ah, ac;
 
-    if (ido == 1)
+    for (k = 0; k < l1; k++)
     {
-        for (k = 0; k < l1; k++)
-        {
-            ah = 2*k;
-            ac = 4*k;
+        ah = 2*k;
+        ac = 4*k;
 
-            RE(ch[ah])    = RE(cc[ac]) + RE(cc[ac+1]);
-            IM(ch[ah])    = IM(cc[ac]) + IM(cc[ac+1]);
+        RE(ch[ah])    = RE(cc[ac]) + RE(cc[ac+1]);
+        IM(ch[ah])    = IM(cc[ac]) + IM(cc[ac+1]);
 
-            RE(ch[ah+l1]) = RE(cc[ac]) - RE(cc[ac+1]);
-            IM(ch[ah+l1]) = IM(cc[ac]) - IM(cc[ac+1]);
-        }
-    } else {
-        for (k = 0; k < l1; k++)
+        RE(ch[ah+l1]) = RE(cc[ac]) - RE(cc[ac+1]);
+        IM(ch[ah+l1]) = IM(cc[ac]) - IM(cc[ac+1]);
+    }
+}
+
+static void passf2pos_sse_ido(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+                              complex_t *ch, const complex_t *wa)
+{
+    uint16_t i, k, ah, ac;
+
+    for (k = 0; k < l1; k++)
+    {
+        ah = k*ido;
+        ac = 2*k*ido;
+
+        for (i = 0; i < ido; i+=4)
         {
-            ah = k*ido;
-            ac = 2*k*ido;
+            __m128 m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14;
+            __m128 m15, m16, m17, m18, m19, m20, m21, m22, m23, m24;
+            __m128 w1, w2, w3, w4;
 
-            for (i = 0; i < ido; i+=4)
-            {
-                __m128 m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14;
-                __m128 m15, m16, m17, m18, m19, m20, m21, m22, m23, m24;
-                __m128 w1, w2, w3, w4;
+            m1 = _mm_load_ps(&RE(cc[ac+i]));
+            m2 = _mm_load_ps(&RE(cc[ac+ido+i]));
+            m5 = _mm_load_ps(&RE(cc[ac+i+2]));
+            m6 = _mm_load_ps(&RE(cc[ac+ido+i+2]));
+            w1 = _mm_load_ps(&RE(wa[i]));
+            w3 = _mm_load_ps(&RE(wa[i+2]));
 
-                m1 = _mm_load_ps(&RE(cc[ac+i]));
-                m2 = _mm_load_ps(&RE(cc[ac+ido+i]));
-                m5 = _mm_load_ps(&RE(cc[ac+i+2]));
-                m6 = _mm_load_ps(&RE(cc[ac+ido+i+2]));
-                w1 = _mm_load_ps(&RE(wa[i]));
-                w3 = _mm_load_ps(&RE(wa[i+2]));
+            m3 = _mm_add_ps(m1, m2);
+            m15 = _mm_add_ps(m5, m6);
 
-                m3 = _mm_add_ps(m1, m2);
-                m15 = _mm_add_ps(m5, m6);
+            m4 = _mm_sub_ps(m1, m2);
+            m16 = _mm_sub_ps(m5, m6);
 
-                m4 = _mm_sub_ps(m1, m2);
-                m16 = _mm_sub_ps(m5, m6);
+            _mm_store_ps(&RE(ch[ah+i]), m3);
+            _mm_store_ps(&RE(ch[ah+i+2]), m15);
 
-                _mm_store_ps(&RE(ch[ah+i]), m3);
-                _mm_store_ps(&RE(ch[ah+i+2]), m15);
 
-                w2 = _mm_shuffle_ps(w1, w1, _MM_SHUFFLE(2, 3, 0, 1));
-                w4 = _mm_shuffle_ps(w3, w3, _MM_SHUFFLE(2, 3, 0, 1));
+            w2 = _mm_shuffle_ps(w1, w1, _MM_SHUFFLE(2, 3, 0, 1));
+            w4 = _mm_shuffle_ps(w3, w3, _MM_SHUFFLE(2, 3, 0, 1));
 
-                m7 = _mm_mul_ps(m4, w1);
-                m17 = _mm_mul_ps(m16, w3);
-                m8 = _mm_mul_ps(m4, w2);
-                m18 = _mm_mul_ps(m16, w4);
+            m7 = _mm_mul_ps(m4, w1);
+            m17 = _mm_mul_ps(m16, w3);
+            m8 = _mm_mul_ps(m4, w2);
+            m18 = _mm_mul_ps(m16, w4);
 
-                m9  = _mm_shuffle_ps(m7, m8, _MM_SHUFFLE(2, 0, 2, 0));
-                m19 = _mm_shuffle_ps(m17, m18, _MM_SHUFFLE(2, 0, 2, 0));
-                m10 = _mm_shuffle_ps(m7, m8, _MM_SHUFFLE(3, 1, 3, 1));
-                m20 = _mm_shuffle_ps(m17, m18, _MM_SHUFFLE(3, 1, 3, 1));
+            m9  = _mm_shuffle_ps(m7, m8, _MM_SHUFFLE(2, 0, 2, 0));
+            m19 = _mm_shuffle_ps(m17, m18, _MM_SHUFFLE(2, 0, 2, 0));
+            m10 = _mm_shuffle_ps(m7, m8, _MM_SHUFFLE(3, 1, 3, 1));
+            m20 = _mm_shuffle_ps(m17, m18, _MM_SHUFFLE(3, 1, 3, 1));
 
-                m11 = _mm_add_ps(m9, m10);
-                m21 = _mm_add_ps(m19, m20);
-                m12 = _mm_sub_ps(m9, m10);
-                m22 = _mm_sub_ps(m19, m20);
+            m11 = _mm_add_ps(m9, m10);
+            m21 = _mm_add_ps(m19, m20);
+            m12 = _mm_sub_ps(m9, m10);
+            m22 = _mm_sub_ps(m19, m20);
 
-                m13 = _mm_shuffle_ps(m11, m11, _MM_SHUFFLE(0, 0, 3, 2));
-                m23 = _mm_shuffle_ps(m21, m21, _MM_SHUFFLE(0, 0, 3, 2));
+            m13 = _mm_shuffle_ps(m11, m11, _MM_SHUFFLE(0, 0, 3, 2));
+            m23 = _mm_shuffle_ps(m21, m21, _MM_SHUFFLE(0, 0, 3, 2));
 
-                m14 = _mm_unpacklo_ps(m12, m13);
-                m24 = _mm_unpacklo_ps(m22, m23);
+            m14 = _mm_unpacklo_ps(m12, m13);
+            m24 = _mm_unpacklo_ps(m22, m23);
 
-                _mm_store_ps(&RE(ch[ah+i+l1*ido]), m14);
-                _mm_store_ps(&RE(ch[ah+i+2+l1*ido]), m24);
-            }
+            _mm_store_ps(&RE(ch[ah+i+l1*ido]), m14);
+            _mm_store_ps(&RE(ch[ah+i+2+l1*ido]), m24);
         }
     }
 }
@@ -159,8 +190,13 @@
                 IM(ch[ah+i]) = IM(cc[ac+i]) + IM(cc[ac+i+ido]);
                 IM(t2)       = IM(cc[ac+i]) - IM(cc[ac+i+ido]);
 
+#if 0
                 ComplexMult(&IM(ch[ah+i+l1*ido]), &RE(ch[ah+i+l1*ido]),
                     IM(t2), RE(t2), RE(wa[i]), IM(wa[i]));
+#else
+                ComplexMult(&RE(ch[ah+i+l1*ido]), &IM(ch[ah+i+l1*ido]),
+                    RE(t2), IM(t2), RE(wa[i]), IM(wa[i]));
+#endif
             }
         }
     }
@@ -199,8 +235,13 @@
                 IM(ch[ah+i]) = IM(cc[ac+i]) + IM(cc[ac+i+ido]);
                 IM(t2)       = IM(cc[ac+i]) - IM(cc[ac+i+ido]);
 
+#if 0
                 ComplexMult(&RE(ch[ah+i+l1*ido]), &IM(ch[ah+i+l1*ido]),
                     RE(t2), IM(t2), RE(wa[i]), IM(wa[i]));
+#else
+                ComplexMult(&IM(ch[ah+i+l1*ido]), &RE(ch[ah+i+l1*ido]),
+                    IM(t2), RE(t2), RE(wa[i]), IM(wa[i]));
+#endif
             }
         }
     }
@@ -290,10 +331,17 @@
                     RE(d3) = RE(c2) + IM(c3);
                     IM(d2) = IM(c2) + RE(c3);
 
+#if 0
                     ComplexMult(&IM(ch[ah+l1*ido]), &RE(ch[ah+l1*ido]),
                         IM(d2), RE(d2), RE(wa1[i]), IM(wa1[i]));
                     ComplexMult(&IM(ch[ah+2*l1*ido]), &RE(ch[ah+2*l1*ido]),
                         IM(d3), RE(d3), RE(wa2[i]), IM(wa2[i]));
+#else
+                    ComplexMult(&RE(ch[ah+l1*ido]), &IM(ch[ah+l1*ido]),
+                        RE(d2), IM(d2), RE(wa1[i]), IM(wa1[i]));
+                    ComplexMult(&RE(ch[ah+2*l1*ido]), &IM(ch[ah+2*l1*ido]),
+                        RE(d3), IM(d3), RE(wa2[i]), IM(wa2[i]));
+#endif
                 }
             }
         } else {
@@ -320,10 +368,17 @@
                     RE(d3) = RE(c2) - IM(c3);
                     IM(d2) = IM(c2) - RE(c3);
 
+#if 0
                     ComplexMult(&RE(ch[ah+l1*ido]), &IM(ch[ah+l1*ido]),
                         RE(d2), IM(d2), RE(wa1[i]), IM(wa1[i]));
                     ComplexMult(&RE(ch[ah+2*l1*ido]), &IM(ch[ah+2*l1*ido]),
                         RE(d3), IM(d3), RE(wa2[i]), IM(wa2[i]));
+#else
+                    ComplexMult(&IM(ch[ah+l1*ido]), &RE(ch[ah+l1*ido]),
+                        IM(d2), RE(d2), RE(wa1[i]), IM(wa1[i]));
+                    ComplexMult(&IM(ch[ah+2*l1*ido]), &RE(ch[ah+2*l1*ido]),
+                        IM(d3), RE(d3), RE(wa2[i]), IM(wa2[i]));
+#endif
                 }
             }
         }
@@ -331,158 +386,213 @@
 }
 
 #ifdef USE_SSE
-static void passf4pos_sse(const uint16_t ido, const uint16_t l1, const complex_t *cc,
-                          complex_t *ch, const complex_t *wa1, const complex_t *wa2,
-                          const complex_t *wa3)
+ALIGN static const int32_t negate[4] = { 0x0, 0x0, 0x0, 0x80000000 };
+
+__declspec(naked) static void passf4pos_sse(const uint16_t l1, const complex_t *cc,
+                                     complex_t *ch, const complex_t *wa1, const complex_t *wa2,
+                                     const complex_t *wa3)
 {
-    uint16_t i, k, ac, ah;
+    __asm {
+        push      ebx
+        mov       ebx, esp
+        and       esp, -16
+        push      edi
+        push      esi
+        sub       esp, 8
+        movzx     edi, WORD PTR [ebx+8]
 
-    if (ido == 1)
-    {
-        for (k = 0; k < l1; k+=2)
-        {
-            __m128 m1, m2, m3, m4, m5, m6, m7, m8, m9, m10;
-            __m128 n1, n2, n3, n4, n5, n6, n7, n8, n9, n10;
-            __m128 neg1 = _mm_set_ps(-1.0, 1.0, 1.0, 1.0);
+        movaps    xmm1, XMMWORD PTR negate
 
-            m1 = _mm_load_ps(&RE(cc[4*k]));
-            m2 = _mm_load_ps(&RE(cc[4*k+2]));
-            n1 = _mm_load_ps(&RE(cc[4*k+4]));
-            n2 = _mm_load_ps(&RE(cc[4*k+6]));
+        test      edi, edi
+        jle       l1_is_zero
 
-            m3 = _mm_add_ps(m1, m2);
+        lea       esi, DWORD PTR [edi+edi]
+        add       esi, esi
+        sub       esi, edi
+        add       esi, esi
+        add       esi, esi
+        add       esi, esi
+        mov       eax, DWORD PTR [ebx+16]
+        add       esi, eax
+        lea       ecx, DWORD PTR [edi+edi]
+        add       ecx, ecx
+        add       ecx, ecx
+        add       ecx, ecx
+        add       ecx, eax
+        lea       edx, DWORD PTR [edi+edi]
+        add       edx, edx
+        add       edx, edx
+        add       edx, eax
+        xor       eax, eax
+        mov       DWORD PTR [esp], ebp
+        mov       ebp, DWORD PTR [ebx+12]
 
-            n4 = _mm_mul_ps(neg1, n1);
-            n5 = _mm_mul_ps(neg1, n2);
-            m4 = _mm_mul_ps(neg1, m1);
-            m5 = _mm_mul_ps(neg1, m2);
+fftloop:
+        lea       edi, DWORD PTR [eax+eax]
+        add       edi, edi
+        movaps    xmm2, XMMWORD PTR [ebp+edi*8]
+        movaps    xmm0, XMMWORD PTR [ebp+edi*8+16]
+        movaps    xmm7, XMMWORD PTR [ebp+edi*8+32]
+        movaps    xmm5, XMMWORD PTR [ebp+edi*8+48]
+        movaps    xmm6, xmm2
+        addps     xmm6, xmm0
+        movaps    xmm4, xmm1
+        xorps     xmm4, xmm7
+        movaps    xmm3, xmm1
+        xorps     xmm3, xmm5
+        xorps     xmm2, xmm1
+        xorps     xmm0, xmm1
+        addps     xmm7, xmm5
+        subps     xmm2, xmm0
+        movaps    xmm0, xmm6
+        shufps    xmm0, xmm7, 68
+        subps     xmm4, xmm3
+        shufps    xmm6, xmm7, 238
+        movaps    xmm5, xmm2
+        shufps    xmm5, xmm4, 68
+        movaps    xmm3, xmm0
+        addps     xmm3, xmm6
+        shufps    xmm2, xmm4, 187
+        subps     xmm0, xmm6
+        movaps    xmm4, xmm5
+        addps     xmm4, xmm2
+        mov       edi, DWORD PTR [ebx+16]
+        movaps    XMMWORD PTR [edi+eax*8], xmm3
+        subps     xmm5, xmm2
+        movaps    XMMWORD PTR [edx+eax*8], xmm4
+        movaps    XMMWORD PTR [ecx+eax*8], xmm0
+        movaps    XMMWORD PTR [esi+eax*8], xmm5
+        add       eax, 2
+        movzx     eax, ax
+        movzx     edi, WORD PTR [ebx+8]
+        cmp       eax, edi
+        jl        fftloop
 
-            n3 = _mm_add_ps(n1, n2);
-            m6 = _mm_sub_ps(m4, m5);
+        mov       ebp, DWORD PTR [esp]
 
-            m7 = _mm_shuffle_ps(m3, n3, _MM_SHUFFLE(1, 0, 1, 0));
-            n6 = _mm_sub_ps(n4, n5);
-            m8 = _mm_shuffle_ps(m3, n3, _MM_SHUFFLE(3, 2, 3, 2));
+l1_is_zero:
 
-            n7 = _mm_shuffle_ps(m6, n6, _MM_SHUFFLE(1, 0, 1, 0));
-            m9 = _mm_add_ps(m7, m8);
-            n8 = _mm_shuffle_ps(m6, n6, _MM_SHUFFLE(2, 3, 2, 3));
+        add       esp, 8
+        pop       esi
+        pop       edi
+        mov       esp, ebx
+        pop       ebx
+        ret
+    }
+}
+#endif
 
-            m10 = _mm_sub_ps(m7, m8);
-            n9 = _mm_add_ps(n7, n8);
+#if 0
+static void passf4pos_sse_ido(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+                              complex_t *ch, const complex_t *wa1, const complex_t *wa2,
+                              const complex_t *wa3)
+{
+    uint16_t i, k, ac, ah;
 
-            _mm_store_ps(&RE(ch[k]), m9);
-            n10 = _mm_sub_ps(n7, n8);
-            _mm_store_ps(&RE(ch[k+l1]), n9);
-            _mm_store_ps(&RE(ch[k+2*l1]), m10);
-            _mm_store_ps(&RE(ch[k+3*l1]), n10);
-        }
-    } else {
-        for (k = 0; k < l1; k++)
+    for (k = 0; k < l1; k++)
+    {
+        ac = 4*k*ido;
+        ah = k*ido;
+
+        for (i = 0; i < ido; i+=2)
         {
-            ac = 4*k*ido;
-            ah = k*ido;
+            __m128 m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, m16;
+            __m128 n1, n2, n3, n4, n5, n6, n7, n8, n9, m17, m18, m19, m20, m21, m22, m23;
+            __m128 w1, w2, w3, w4, w5, w6, m24, m25, m26, m27, m28, m29, m30;
+            __m128 neg1 = _mm_set_ps(-1.0, 1.0, -1.0, 1.0);
 
-            for (i = 0; i < ido; i+=2)
-            {
-                __m128 m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, m16;
-                __m128 n1, n2, n3, n4, n5, n6, n7, n8, n9, m17, m18, m19, m20, m21, m22, m23;
-                __m128 w1, w2, w3, w4, w5, w6, m24, m25, m26, m27, m28, m29, m30;
-                __m128 neg1 = _mm_set_ps(-1.0, 1.0, -1.0, 1.0);
+            m1 = _mm_load_ps(&RE(cc[ac+i]));
+            m2 = _mm_load_ps(&RE(cc[ac+i+2*ido]));
+            m3 = _mm_add_ps(m1, m2);
+            m4 = _mm_sub_ps(m1, m2);
 
-                m1 = _mm_load_ps(&RE(cc[ac+i]));
-                m2 = _mm_load_ps(&RE(cc[ac+i+2*ido]));
-                m3 = _mm_add_ps(m1, m2);
-                m4 = _mm_sub_ps(m1, m2);
+            n1 = _mm_load_ps(&RE(cc[ac+i+ido]));
+            n2 = _mm_load_ps(&RE(cc[ac+i+3*ido]));
+            n3 = _mm_add_ps(n1, n2);
 
-                n1 = _mm_load_ps(&RE(cc[ac+i+ido]));
-                n2 = _mm_load_ps(&RE(cc[ac+i+3*ido]));
-                n3 = _mm_add_ps(n1, n2);
+            n4 = _mm_mul_ps(neg1, n1);
+            n5 = _mm_mul_ps(neg1, n2);
+            n6 = _mm_sub_ps(n4, n5);
 
-                n4 = _mm_mul_ps(neg1, n1);
-                n5 = _mm_mul_ps(neg1, n2);
-                n6 = _mm_sub_ps(n4, n5);
+            m5 = _mm_add_ps(m3, n3);
 
-                m5 = _mm_add_ps(m3, n3);
+            n7 = _mm_shuffle_ps(n6, n6, _MM_SHUFFLE(2, 3, 0, 1));
+            n8 = _mm_add_ps(m4, n7);
 
-                n7 = _mm_shuffle_ps(n6, n6, _MM_SHUFFLE(2, 3, 0, 1));
-                n8 = _mm_add_ps(m4, n7);
+            m6 = _mm_sub_ps(m3, n3);
+            n9 = _mm_sub_ps(m4, n7);
 
-                m6 = _mm_sub_ps(m3, n3);
-                n9 = _mm_sub_ps(m4, n7);
+            _mm_store_ps(&RE(ch[ah+i]), m5);
 
-                _mm_store_ps(&RE(ch[ah+i]), m5);
-
 #if 0
-  static INLINE void ComplexMult(real_t *y1, real_t *y2,
-      real_t x1, real_t x2, real_t c1, real_t c2)
-  {
-      *y1 = MUL_F(x1, c1) + MUL_F(x2, c2);
-      *y2 = MUL_F(x2, c1) - MUL_F(x1, c2);
-  }
+            static INLINE void ComplexMult(real_t *y1, real_t *y2,
+                real_t x1, real_t x2, real_t c1, real_t c2)
+            {
+                *y1 = MUL_F(x1, c1) + MUL_F(x2, c2);
+                *y2 = MUL_F(x2, c1) - MUL_F(x1, c2);
+            }
 
-  m7.0 = RE(c2)*RE(wa1[i])
-  m7.1 = IM(c2)*IM(wa1[i])
-  m7.2 = RE(c6)*RE(wa1[i+1])
-  m7.3 = IM(c6)*IM(wa1[i+1])
+            m7.0 = RE(c2)*RE(wa1[i])
+            m7.1 = IM(c2)*IM(wa1[i])
+            m7.2 = RE(c6)*RE(wa1[i+1])
+            m7.3 = IM(c6)*IM(wa1[i+1])
 
-  m8.0 = RE(c2)*IM(wa1[i])
-  m8.1 = IM(c2)*RE(wa1[i])
-  m8.2 = RE(c6)*IM(wa1[i+1])
-  m8.3 = IM(c6)*RE(wa1[i+1])
+            m8.0 = RE(c2)*IM(wa1[i])
+            m8.1 = IM(c2)*RE(wa1[i])
+            m8.2 = RE(c6)*IM(wa1[i+1])
+            m8.3 = IM(c6)*RE(wa1[i+1])
 
-  RE(0) = m7.0 - m7.1
-  IM(0) = m8.0 + m8.1
-  RE(1) = m7.2 - m7.3
-  IM(1) = m8.2 + m8.3
+            RE(0) = m7.0 - m7.1
+            IM(0) = m8.0 + m8.1
+            RE(1) = m7.2 - m7.3
+            IM(1) = m8.2 + m8.3
 
-////
-  RE(0) = RE(c2)*RE(wa1[i])   - IM(c2)*IM(wa1[i])
-  IM(0) = RE(c2)*IM(wa1[i])   + IM(c2)*RE(wa1[i])
-  RE(1) = RE(c6)*RE(wa1[i+1]) - IM(c6)*IM(wa1[i+1])
-  IM(1) = RE(c6)*IM(wa1[i+1]) + IM(c6)*RE(wa1[i+1])
+            ////
+            RE(0) = RE(c2)*RE(wa1[i])   - IM(c2)*IM(wa1[i])
+            IM(0) = RE(c2)*IM(wa1[i])   + IM(c2)*RE(wa1[i])
+            RE(1) = RE(c6)*RE(wa1[i+1]) - IM(c6)*IM(wa1[i+1])
+            IM(1) = RE(c6)*IM(wa1[i+1]) + IM(c6)*RE(wa1[i+1])
 #endif
 
-                w1 = _mm_load_ps(&RE(wa1[i]));
-                w3 = _mm_load_ps(&RE(wa2[i]));
-                w5 = _mm_load_ps(&RE(wa3[i]));
+            w1 = _mm_load_ps(&RE(wa1[i]));
+            w3 = _mm_load_ps(&RE(wa2[i]));
+            w5 = _mm_load_ps(&RE(wa3[i]));
 
-                w2 = _mm_shuffle_ps(w1, w1, _MM_SHUFFLE(2, 3, 0, 1));
-                w4 = _mm_shuffle_ps(w3, w3, _MM_SHUFFLE(2, 3, 0, 1));
-                w6 = _mm_shuffle_ps(w5, w5, _MM_SHUFFLE(2, 3, 0, 1));
+            w2 = _mm_shuffle_ps(w1, w1, _MM_SHUFFLE(2, 3, 0, 1));
+            w4 = _mm_shuffle_ps(w3, w3, _MM_SHUFFLE(2, 3, 0, 1));
+            w6 = _mm_shuffle_ps(w5, w5, _MM_SHUFFLE(2, 3, 0, 1));
 
-                m7 = _mm_mul_ps(n8, w1);
-                m15 = _mm_mul_ps(m6, w3);
-                m23 = _mm_mul_ps(n9, w5);
-                m8 = _mm_mul_ps(n8, w2);
-                m16 = _mm_mul_ps(m6, w4);
-                m24 = _mm_mul_ps(n9, w6);
+            m7 = _mm_mul_ps(n8, w1);
+            m15 = _mm_mul_ps(m6, w3);
+            m23 = _mm_mul_ps(n9, w5);
+            m8 = _mm_mul_ps(n8, w2);
+            m16 = _mm_mul_ps(m6, w4);
+            m24 = _mm_mul_ps(n9, w6);
 
-                m9  = _mm_shuffle_ps(m7, m8, _MM_SHUFFLE(2, 0, 2, 0));
-                m17 = _mm_shuffle_ps(m15, m16, _MM_SHUFFLE(2, 0, 2, 0));
-                m25 = _mm_shuffle_ps(m23, m24, _MM_SHUFFLE(2, 0, 2, 0));
-                m10 = _mm_shuffle_ps(m7, m8, _MM_SHUFFLE(3, 1, 3, 1));
-                m18 = _mm_shuffle_ps(m15, m16, _MM_SHUFFLE(3, 1, 3, 1));
-                m26 = _mm_shuffle_ps(m23, m24, _MM_SHUFFLE(3, 1, 3, 1));
+            m9  = _mm_shuffle_ps(m7, m8, _MM_SHUFFLE(2, 0, 2, 0));
+            m17 = _mm_shuffle_ps(m15, m16, _MM_SHUFFLE(2, 0, 2, 0));
+            m25 = _mm_shuffle_ps(m23, m24, _MM_SHUFFLE(2, 0, 2, 0));
+            m10 = _mm_shuffle_ps(m7, m8, _MM_SHUFFLE(3, 1, 3, 1));
+            m18 = _mm_shuffle_ps(m15, m16, _MM_SHUFFLE(3, 1, 3, 1));
+            m26 = _mm_shuffle_ps(m23, m24, _MM_SHUFFLE(3, 1, 3, 1));
 
-                m11 = _mm_add_ps(m9, m10);
-                m19 = _mm_add_ps(m17, m18);
-                m27 = _mm_add_ps(m25, m26);
-                m12 = _mm_sub_ps(m9, m10);
-                m20 = _mm_sub_ps(m17, m18);
-                m28 = _mm_sub_ps(m25, m26);
+            m11 = _mm_add_ps(m9, m10);
+            m19 = _mm_add_ps(m17, m18);
+            m27 = _mm_add_ps(m25, m26);
+            m12 = _mm_sub_ps(m9, m10);
+            m20 = _mm_sub_ps(m17, m18);
+            m28 = _mm_sub_ps(m25, m26);
 
-                m13 = _mm_shuffle_ps(m11, m11, _MM_SHUFFLE(0, 0, 3, 2));
-                m21 = _mm_shuffle_ps(m19, m19, _MM_SHUFFLE(0, 0, 3, 2));
-                m29 = _mm_shuffle_ps(m27, m27, _MM_SHUFFLE(0, 0, 3, 2));
-                m14 = _mm_unpacklo_ps(m12, m13);
-                m22 = _mm_unpacklo_ps(m20, m21);
-                m30 = _mm_unpacklo_ps(m28, m29);
+            m13 = _mm_shuffle_ps(m11, m11, _MM_SHUFFLE(0, 0, 3, 2));
+            m21 = _mm_shuffle_ps(m19, m19, _MM_SHUFFLE(0, 0, 3, 2));
+            m29 = _mm_shuffle_ps(m27, m27, _MM_SHUFFLE(0, 0, 3, 2));
+            m14 = _mm_unpacklo_ps(m12, m13);
+            m22 = _mm_unpacklo_ps(m20, m21);
+            m30 = _mm_unpacklo_ps(m28, m29);
 
-                _mm_store_ps(&RE(ch[ah+i+l1*ido]), m14);
-                _mm_store_ps(&RE(ch[ah+i+2*l1*ido]), m22);
-                _mm_store_ps(&RE(ch[ah+i+3*l1*ido]), m30);
-            }
+            _mm_store_ps(&RE(ch[ah+i+l1*ido]), m14);
+            _mm_store_ps(&RE(ch[ah+i+2*l1*ido]), m22);
+            _mm_store_ps(&RE(ch[ah+i+3*l1*ido]), m30);
         }
     }
 }
@@ -555,6 +665,7 @@
                 IM(ch[ah+i]) = IM(t2) + IM(t3);
                 IM(c3)       = IM(t2) - IM(t3);
 
+#if 0
                 ComplexMult(&IM(ch[ah+i+l1*ido]), &RE(ch[ah+i+l1*ido]),
                     IM(c2), RE(c2), RE(wa1[i]), IM(wa1[i]));
                 ComplexMult(&IM(ch[ah+i+2*l1*ido]), &RE(ch[ah+i+2*l1*ido]),
@@ -561,6 +672,14 @@
                     IM(c3), RE(c3), RE(wa2[i]), IM(wa2[i]));
                 ComplexMult(&IM(ch[ah+i+3*l1*ido]), &RE(ch[ah+i+3*l1*ido]),
                     IM(c4), RE(c4), RE(wa3[i]), IM(wa3[i]));
+#else
+                ComplexMult(&RE(ch[ah+i+l1*ido]), &IM(ch[ah+i+l1*ido]),
+                    RE(c2), IM(c2), RE(wa1[i]), IM(wa1[i]));
+                ComplexMult(&RE(ch[ah+i+2*l1*ido]), &IM(ch[ah+i+2*l1*ido]),
+                    RE(c3), IM(c3), RE(wa2[i]), IM(wa2[i]));
+                ComplexMult(&RE(ch[ah+i+3*l1*ido]), &IM(ch[ah+i+3*l1*ido]),
+                    RE(c4), IM(c4), RE(wa3[i]), IM(wa3[i]));
+#endif
             }
         }
     }
@@ -633,6 +752,7 @@
                 IM(ch[ah+i]) = IM(t2) + IM(t3);
                 IM(c3)       = IM(t2) - IM(t3);
 
+#if 0
                 ComplexMult(&RE(ch[ah+i+l1*ido]), &IM(ch[ah+i+l1*ido]),
                     RE(c2), IM(c2), RE(wa1[i]), IM(wa1[i]));
                 ComplexMult(&RE(ch[ah+i+2*l1*ido]), &IM(ch[ah+i+2*l1*ido]),
@@ -639,6 +759,14 @@
                     RE(c3), IM(c3), RE(wa2[i]), IM(wa2[i]));
                 ComplexMult(&RE(ch[ah+i+3*l1*ido]), &IM(ch[ah+i+3*l1*ido]),
                     RE(c4), IM(c4), RE(wa3[i]), IM(wa3[i]));
+#else
+                ComplexMult(&IM(ch[ah+i+l1*ido]), &RE(ch[ah+i+l1*ido]),
+                    IM(c2), RE(c2), RE(wa1[i]), IM(wa1[i]));
+                ComplexMult(&IM(ch[ah+i+2*l1*ido]), &RE(ch[ah+i+2*l1*ido]),
+                    IM(c3), RE(c3), RE(wa2[i]), IM(wa2[i]));
+                ComplexMult(&IM(ch[ah+i+3*l1*ido]), &RE(ch[ah+i+3*l1*ido]),
+                    IM(c4), RE(c4), RE(wa3[i]), IM(wa3[i]));
+#endif
             }
         }
     }
@@ -774,6 +902,7 @@
                     RE(d3) = RE(c3) - IM(c4);
                     IM(d4) = IM(c3) - RE(c4);
 
+#if 0
                     ComplexMult(&IM(ch[ah+l1*ido]), &RE(ch[ah+l1*ido]),
                         IM(d2), RE(d2), RE(wa1[i]), IM(wa1[i]));
                     ComplexMult(&IM(ch[ah+2*l1*ido]), &RE(ch[ah+2*l1*ido]),
@@ -782,6 +911,16 @@
                         IM(d4), RE(d4), RE(wa3[i]), IM(wa3[i]));
                     ComplexMult(&IM(ch[ah+4*l1*ido]), &RE(ch[ah+4*l1*ido]),
                         IM(d5), RE(d5), RE(wa4[i]), IM(wa4[i]));
+#else
+                    ComplexMult(&RE(ch[ah+l1*ido]), &IM(ch[ah+l1*ido]),
+                        RE(d2), IM(d2), RE(wa1[i]), IM(wa1[i]));
+                    ComplexMult(&RE(ch[ah+2*l1*ido]), &IM(ch[ah+2*l1*ido]),
+                        RE(d3), IM(d3), RE(wa2[i]), IM(wa2[i]));
+                    ComplexMult(&RE(ch[ah+3*l1*ido]), &IM(ch[ah+3*l1*ido]),
+                        RE(d4), IM(d4), RE(wa3[i]), IM(wa3[i]));
+                    ComplexMult(&RE(ch[ah+4*l1*ido]), &IM(ch[ah+4*l1*ido]),
+                        RE(d5), IM(d5), RE(wa4[i]), IM(wa4[i]));
+#endif
                 }
             }
         } else {
@@ -823,6 +962,7 @@
                     RE(d3) = RE(c3) + IM(c4);
                     IM(d4) = IM(c3) + RE(c4);
 
+#if 0
                     ComplexMult(&RE(ch[ah+l1*ido]), &IM(ch[ah+l1*ido]),
                         RE(d2), IM(d2), RE(wa1[i]), IM(wa1[i]));
                     ComplexMult(&RE(ch[ah+2*l1*ido]), &IM(ch[ah+2*l1*ido]),
@@ -831,6 +971,16 @@
                         RE(d4), IM(d4), RE(wa3[i]), IM(wa3[i]));
                     ComplexMult(&RE(ch[ah+4*l1*ido]), &IM(ch[ah+4*l1*ido]),
                         RE(d5), IM(d5), RE(wa4[i]), IM(wa4[i]));
+#else
+                    ComplexMult(&IM(ch[ah+l1*ido]), &RE(ch[ah+l1*ido]),
+                        IM(d2), RE(d2), RE(wa1[i]), IM(wa1[i]));
+                    ComplexMult(&IM(ch[ah+2*l1*ido]), &RE(ch[ah+2*l1*ido]),
+                        IM(d3), RE(d3), RE(wa2[i]), IM(wa2[i]));
+                    ComplexMult(&IM(ch[ah+3*l1*ido]), &RE(ch[ah+3*l1*ido]),
+                        IM(d4), RE(d4), RE(wa3[i]), IM(wa3[i]));
+                    ComplexMult(&IM(ch[ah+4*l1*ido]), &RE(ch[ah+4*l1*ido]),
+                        IM(d5), RE(d5), RE(wa4[i]), IM(wa4[i]));
+#endif
                 }
             }
         }
@@ -843,8 +993,12 @@
   ----------------------------------------------------------------------*/
 
 #ifdef USE_SSE
-INLINE void cfftf1pos_sse(uint16_t n, complex_t *c, complex_t *ch,
-                          const uint16_t *ifac, const complex_t *wa, const int8_t isign)
+
+#define CONV(A,B,C) ( (A<<2) | ((B & 0x1)<<1) | ((C==1)&0x1) )
+
+static INLINE void cfftf1pos_sse(uint16_t n, complex_t *c, complex_t *ch,
+                                 const uint16_t *ifac, const complex_t *wa,
+                                 const int8_t isign)
 {
     uint16_t i;
     uint16_t k1, l1, l2;
@@ -862,51 +1016,62 @@
         ido = n / l2;
         idl1 = ido*l1;
 
-        switch (ip)
-        {
-        case 4:
-            ix2 = iw + ido;
-            ix3 = ix2 + ido;
+        ix2 = iw + ido;
+        ix3 = ix2 + ido;
+        ix4 = ix3 + ido;
 
-            if (na == 0)
-                passf4pos_sse((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], &wa[ix3]);
-            else
-                passf4pos_sse((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], &wa[ix3]);
-
-            na = 1 - na;
+        switch (CONV(ip,na,ido))
+        {
+        case CONV(4,0,0):
+            //passf4pos_sse_ido((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], &wa[ix3]);
+            passf4pos((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], &wa[ix3]);
             break;
-        case 2:
-            if (na == 0)
-                passf2pos_sse((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw]);
-            else
-                passf2pos_sse((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw]);
-
-            na = 1 - na;
+        case CONV(4,0,1):
+            passf4pos_sse((const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], &wa[ix3]);
             break;
-        case 3:
-            ix2 = iw + ido;
-
-            if (na == 0)
-                passf3((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], isign);
-            else
-                passf3((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], isign);
-
-            na = 1 - na;
+        case CONV(4,1,0):
+            passf4pos((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], &wa[ix3]);
+            //passf4pos_sse_ido((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], &wa[ix3]);
             break;
-        case 5:
-            ix2 = iw + ido;
-            ix3 = ix2 + ido;
-            ix4 = ix3 + ido;
-
-            if (na == 0)
-                passf5((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], &wa[ix3], &wa[ix4], isign);
-            else
-                passf5((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], &wa[ix3], &wa[ix4], isign);
-
-            na = 1 - na;
+        case CONV(4,1,1):
+            passf4pos_sse((const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], &wa[ix3]);
             break;
+        case CONV(2,0,0):
+            passf2pos((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw]);
+            //passf2pos_sse_ido((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw]);
+            break;
+        case CONV(2,0,1):
+            passf2pos((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw]);
+            //passf2pos_sse((const uint16_t)l1, (const complex_t*)c, ch, &wa[iw]);
+            break;
+        case CONV(2,1,0):
+            passf2pos((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw]);
+            //passf2pos_sse_ido((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw]);
+            break;
+        case CONV(2,1,1):
+            passf2pos((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw]);
+            //passf2pos_sse((const uint16_t)l1, (const complex_t*)ch, c, &wa[iw]);
+            break;
+        case CONV(3,0,0):
+        case CONV(3,0,1):
+            passf3((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], isign);
+            break;
+        case CONV(3,1,0):
+        case CONV(3,1,1):
+            passf3((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], isign);
+            break;
+        case CONV(5,0,0):
+        case CONV(5,0,1):
+            passf5((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], &wa[ix3], &wa[ix4], isign);
+            break;
+        case CONV(5,1,0):
+        case CONV(5,1,1):
+            passf5((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], &wa[ix3], &wa[ix4], isign);
+            break;
         }
 
+        na = 1 - na;
+
         l1 = l2;
         iw += (ip-1) * ido;
     }
@@ -922,8 +1087,9 @@
 }
 #endif
 
-INLINE void cfftf1pos(uint16_t n, complex_t *c, complex_t *ch,
-                      const uint16_t *ifac, const complex_t *wa, const int8_t isign)
+static INLINE void cfftf1pos(uint16_t n, complex_t *c, complex_t *ch,
+                             const uint16_t *ifac, const complex_t *wa,
+                             const int8_t isign)
 {
     uint16_t i;
     uint16_t k1, l1, l2;
@@ -1000,8 +1166,9 @@
     }
 }
 
-INLINE void cfftf1neg(uint16_t n, complex_t *c, complex_t *ch,
-                      const uint16_t *ifac, const complex_t *wa, const int8_t isign)
+static INLINE void cfftf1neg(uint16_t n, complex_t *c, complex_t *ch,
+                             const uint16_t *ifac, const complex_t *wa,
+                             const int8_t isign)
 {
     uint16_t i;
     uint16_t k1, l1, l2;
@@ -1104,7 +1271,7 @@
     uint16_t i1, k1, l1, l2;
     uint16_t ld, ii, ip;
 #endif
-    uint16_t ntry, i, j;
+    uint16_t ntry = 0, i, j;
     uint16_t ib;
     uint16_t nf, nl, nq, nr;
 
@@ -1174,7 +1341,11 @@
                 fi++;
                 arg = fi * argld;
                 RE(wa[i]) = (real_t)cos(arg);
+#if 0
                 IM(wa[i]) = (real_t)sin(arg);
+#else
+                IM(wa[i]) = (real_t)-sin(arg);
+#endif
             }
 
             if (ip > 5)
--- a/libfaad/cfft.h
+++ b/libfaad/cfft.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: cfft.h,v 1.15 2003/12/23 18:41:42 menno Exp $
+** $Id: cfft.h,v 1.16 2004/01/05 14:05:11 menno Exp $
 **/
 
 #ifndef __CFFT_H__
@@ -46,30 +46,9 @@
 cfft_info *cffti(uint16_t n);
 void cfftu(cfft_info *cfft);
 
-
 #ifdef USE_SSE
 void cfftb_sse(cfft_info *cfft, complex_t *c);
-static void passf2pos_sse(const uint16_t ido, const uint16_t l1, const complex_t *cc,
-                          complex_t *ch, const complex_t *wa);
-static void passf4pos_sse(const uint16_t ido, const uint16_t l1, const complex_t *cc, complex_t *ch,
-                          const complex_t *wa1, const complex_t *wa2, const complex_t *wa3);
 #endif
-static void passf2pos(const uint16_t ido, const uint16_t l1, const complex_t *cc,
-                      complex_t *ch, const complex_t *wa);
-static void passf2neg(const uint16_t ido, const uint16_t l1, const complex_t *cc,
-                      complex_t *ch, const complex_t *wa);
-static void passf3(const uint16_t ido, const uint16_t l1, const complex_t *cc,
-                   complex_t *ch, const complex_t *wa1, const complex_t *wa2, const int8_t isign);
-static void passf4pos(const uint16_t ido, const uint16_t l1, const complex_t *cc, complex_t *ch,
-                      const complex_t *wa1, const complex_t *wa2, const complex_t *wa3);
-static void passf4neg(const uint16_t ido, const uint16_t l1, const complex_t *cc, complex_t *ch,
-                      const complex_t *wa1, const complex_t *wa2, const complex_t *wa3);
-static void passf5(const uint16_t ido, const uint16_t l1, const complex_t *cc, complex_t *ch,
-                   const complex_t *wa1, const complex_t *wa2, const complex_t *wa3,
-                   const complex_t *wa4, const int8_t isign);
-INLINE void cfftf1(uint16_t n, complex_t *c, complex_t *ch,
-                   const uint16_t *ifac, const complex_t *wa, const int8_t isign);
-static void cffti1(uint16_t n, complex_t *wa, uint16_t *ifac);
 
 
 #ifdef __cplusplus
--- a/libfaad/cfft_tab.h
+++ b/libfaad/cfft_tab.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: cfft_tab.h,v 1.11 2003/12/17 14:43:16 menno Exp $
+** $Id: cfft_tab.h,v 1.12 2004/01/05 14:05:11 menno Exp $
 **/
 
 #ifndef __CFFT_TAB_H__
--- a/libfaad/common.c
+++ b/libfaad/common.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: common.c,v 1.14 2003/12/23 18:41:42 menno Exp $
+** $Id: common.c,v 1.15 2004/01/05 14:05:11 menno Exp $
 **/
 
 /* just some common functions that could be used anywhere */
@@ -34,7 +34,7 @@
 #include "syntax.h"
 
 #ifdef USE_SSE
-__declspec(naked) static int32_t __fastcall test_cpuid()
+__declspec(naked) static int32_t __fastcall test_cpuid(void)
 {
     __asm
     {
@@ -233,7 +233,7 @@
 /* common malloc function */
 void *faad_malloc(int32_t size)
 {
-#ifdef _WIN32
+#if 0 // defined(_WIN32) && !defined(_WIN32_WCE)
     return _aligned_malloc(size, 16);
 #else
     return malloc(size);
@@ -243,7 +243,7 @@
 /* common free function */
 void faad_free(void *b)
 {
-#ifdef _WIN32
+#if 0 // defined(_WIN32) && !defined(_WIN32_WCE)
     _aligned_free(b);
 #else
     free(b);
@@ -293,7 +293,6 @@
  */
 uint32_t random_int(void)
 {
-    static const uint32_t rnd_seed = 16428320;
 	uint32_t  t1, t2, t3, t4;
 
 	t3   = t1 = __r1;   t4   = t2 = __r2;       // Parity calculation is done via table lookup, this is also available
--- a/libfaad/common.h
+++ b/libfaad/common.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: common.h,v 1.41 2003/12/23 18:41:42 menno Exp $
+** $Id: common.h,v 1.42 2004/01/05 14:05:11 menno Exp $
 **/
 
 #ifndef __COMMON_H__
@@ -33,7 +33,7 @@
 #endif
 
 #define INLINE __inline
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(_WIN32_WCE)
 #define ALIGN __declspec(align(16))
 #else
 #define ALIGN
@@ -120,7 +120,7 @@
 #if ((defined(_WIN32) && !defined(_WIN32_WCE)) /* || ((__GNUC__ >= 3) && defined(__i386__)) */ )
 #ifndef FIXED_POINT
 /* includes <xmmintrin.h> to enable SSE intrinsics */
-#define USE_SSE
+//#define USE_SSE
 #endif
 #endif
 
@@ -379,7 +379,7 @@
 
 
 /* common functions */
-uint8_t cpu_has_sse();
+uint8_t cpu_has_sse(void);
 uint32_t random_int(void);
 uint8_t get_sr_index(const uint32_t samplerate);
 uint8_t max_pred_sfb(const uint8_t sr_index);
--- a/libfaad/decoder.c
+++ b/libfaad/decoder.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: decoder.c,v 1.83 2003/12/17 14:43:16 menno Exp $
+** $Id: decoder.c,v 1.84 2004/01/05 14:05:11 menno Exp $
 **/
 
 #include "common.h"
@@ -54,7 +54,7 @@
     return err_msg[errcode];
 }
 
-uint32_t FAADAPI faacDecGetCapabilities()
+uint32_t FAADAPI faacDecGetCapabilities(void)
 {
     uint32_t cap = 0;
 
@@ -80,7 +80,7 @@
     return cap;
 }
 
-faacDecHandle FAADAPI faacDecOpen()
+faacDecHandle FAADAPI faacDecOpen(void)
 {
     uint8_t i;
     faacDecHandle hDecoder = NULL;
--- a/libfaad/decoder.h
+++ b/libfaad/decoder.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: decoder.h,v 1.34 2003/12/17 14:43:16 menno Exp $
+** $Id: decoder.h,v 1.35 2004/01/05 14:05:11 menno Exp $
 **/
 
 #ifndef __DECODER_H__
@@ -78,9 +78,9 @@
 
 int8_t* FAADAPI faacDecGetErrorMessage(uint8_t errcode);
 
-uint32_t FAADAPI faacDecGetCapabilities();
+uint32_t FAADAPI faacDecGetCapabilities(void);
 
-faacDecHandle FAADAPI faacDecOpen();
+faacDecHandle FAADAPI faacDecOpen(void);
 
 faacDecConfigurationPtr FAADAPI faacDecGetCurrentConfiguration(faacDecHandle hDecoder);
 
--- a/libfaad/drc.c
+++ b/libfaad/drc.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: drc.c,v 1.20 2003/12/17 14:43:16 menno Exp $
+** $Id: drc.c,v 1.21 2004/01/05 14:05:11 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/drc.h
+++ b/libfaad/drc.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: drc.h,v 1.14 2003/12/17 14:43:16 menno Exp $
+** $Id: drc.h,v 1.15 2004/01/05 14:05:11 menno Exp $
 **/
 
 #ifndef __DRC_H__
--- a/libfaad/error.c
+++ b/libfaad/error.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,13 +22,13 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: error.c,v 1.18 2003/12/23 18:41:42 menno Exp $
+** $Id: error.c,v 1.19 2004/01/05 14:05:11 menno Exp $
 **/
 
 #include "common.h"
 #include "error.h"
 
-extern int8_t *err_msg[] = {
+int8_t *err_msg[] = {
     "No error",
     "Gain control not yet implemented",
     "Pulse coding not allowed in short blocks",
@@ -48,4 +48,5 @@
     "Maximum number of scalefactor bands exceeded",
     "Quantised value out of range",
     "LTP lag out of range"
-};
\ No newline at end of file
+};
+
--- a/libfaad/error.h
+++ b/libfaad/error.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: error.h,v 1.13 2003/12/23 18:41:42 menno Exp $
+** $Id: error.h,v 1.14 2004/01/05 14:05:11 menno Exp $
 **/
 
 #ifndef __ERROR_H__
--- a/libfaad/filtbank.c
+++ b/libfaad/filtbank.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: filtbank.c,v 1.33 2003/12/17 14:43:16 menno Exp $
+** $Id: filtbank.c,v 1.34 2004/01/05 14:05:11 menno Exp $
 **/
 
 #include "common.h"
@@ -120,7 +120,7 @@
 static INLINE void imdct_long(fb_info *fb, real_t *in_data, real_t *out_data, uint16_t len)
 {
 #ifdef LD_DEC
-    mdct_info *mdct;
+    mdct_info *mdct = NULL;
 
     switch (len)
     {
@@ -144,7 +144,7 @@
 static INLINE void imdct_long_sse(fb_info *fb, real_t *in_data, real_t *out_data, uint16_t len)
 {
 #ifdef LD_DEC
-    mdct_info *mdct;
+    mdct_info *mdct = NULL;
 
     switch (len)
     {
@@ -168,7 +168,7 @@
 #ifdef LTP_DEC
 static INLINE void mdct(fb_info *fb, real_t *in_data, real_t *out_data, uint16_t len)
 {
-    mdct_info *mdct;
+    mdct_info *mdct = NULL;
 
     switch (len)
     {
@@ -199,10 +199,10 @@
     int16_t i;
     ALIGN real_t transf_buf[2*1024] = {0};
 
-    const real_t *window_long;
-    const real_t *window_long_prev;
-    const real_t *window_short;
-    const real_t *window_short_prev;
+    const real_t *window_long = NULL;
+    const real_t *window_long_prev = NULL;
+    const real_t *window_short = NULL;
+    const real_t *window_short_prev = NULL;
 
     uint16_t nlong = frame_len;
     uint16_t nshort = frame_len/8;
@@ -323,10 +323,10 @@
     int16_t i;
     ALIGN real_t transf_buf[2*1024] = {0};
 
-    const real_t *window_long;
-    const real_t *window_long_prev;
-    const real_t *window_short;
-    const real_t *window_short_prev;
+    const real_t *window_long = NULL;
+    const real_t *window_long_prev = NULL;
+    const real_t *window_short = NULL;
+    const real_t *window_short_prev = NULL;
 
     uint16_t nlong = frame_len;
     uint16_t nshort = frame_len/8;
@@ -359,27 +359,23 @@
         imdct_long_sse(fb, freq_in, transf_buf, 2*nlong);
         for (i = 0; i < nlong; i+=4)
         {
-            __m128 m1 = _mm_load_ps(&transf_buf[i]);
-            __m128 m2 = _mm_load_ps(&window_long_prev[i]);
-            __m128 m3 = _mm_load_ps(&time_out[nlong+i]);
+            __m128 m1, m2, m3, m4, m5, m6, m7, m8;
 
-            __m128 m4 = _mm_mul_ps(m1, m2);
+            m1 = _mm_load_ps(&transf_buf[i]);
+            m2 = _mm_load_ps(&window_long_prev[i]);
+            m6 = _mm_load_ps(&window_long[nlong-4-i]);
+            m3 = _mm_load_ps(&time_out[nlong+i]);
+            m5 = _mm_load_ps(&transf_buf[nlong+i]);
+
+            m4 = _mm_mul_ps(m1, m2);
+            m7 = _mm_shuffle_ps(m6, m6, _MM_SHUFFLE(0, 1, 2, 3));
+
             m4 = _mm_add_ps(m4, m3);
+            m8 = _mm_mul_ps(m5, m7);
 
             _mm_store_ps(&time_out[i], m4);
+            _mm_store_ps(&time_out[nlong+i], m8);
         }
-        for (i = 0; i < nlong; i+=4)
-        {
-            __m128 m1 = _mm_load_ps(&transf_buf[nlong+i]);
-            __m128 m2 = _mm_load_ps(&window_long[nlong-4-i]);
-            __m128 m3, m4;
-
-            m3 = _mm_shuffle_ps(m2, m2, _MM_SHUFFLE(0, 1, 2, 3));
-
-            m4 = _mm_mul_ps(m1, m3);
-
-            _mm_store_ps(&time_out[nlong+i], m4);
-        }
         break;
 
     case LONG_START_SEQUENCE:
@@ -420,14 +416,14 @@
         break;
 
     case EIGHT_SHORT_SEQUENCE:
-        faad_imdct_sse(fb->mdct256, freq_in+0*nshort, transf_buf+2*nshort*0);
-        faad_imdct_sse(fb->mdct256, freq_in+1*nshort, transf_buf+2*nshort*1);
-        faad_imdct_sse(fb->mdct256, freq_in+2*nshort, transf_buf+2*nshort*2);
-        faad_imdct_sse(fb->mdct256, freq_in+3*nshort, transf_buf+2*nshort*3);
-        faad_imdct_sse(fb->mdct256, freq_in+4*nshort, transf_buf+2*nshort*4);
-        faad_imdct_sse(fb->mdct256, freq_in+5*nshort, transf_buf+2*nshort*5);
-        faad_imdct_sse(fb->mdct256, freq_in+6*nshort, transf_buf+2*nshort*6);
-        faad_imdct_sse(fb->mdct256, freq_in+7*nshort, transf_buf+2*nshort*7);
+        faad_imdct_sse(fb->mdct256, &freq_in[0*nshort], &transf_buf[2*nshort*0]);
+        faad_imdct_sse(fb->mdct256, &freq_in[1*nshort], &transf_buf[2*nshort*1]);
+        faad_imdct_sse(fb->mdct256, &freq_in[2*nshort], &transf_buf[2*nshort*2]);
+        faad_imdct_sse(fb->mdct256, &freq_in[3*nshort], &transf_buf[2*nshort*3]);
+        faad_imdct_sse(fb->mdct256, &freq_in[4*nshort], &transf_buf[2*nshort*4]);
+        faad_imdct_sse(fb->mdct256, &freq_in[5*nshort], &transf_buf[2*nshort*5]);
+        faad_imdct_sse(fb->mdct256, &freq_in[6*nshort], &transf_buf[2*nshort*6]);
+        faad_imdct_sse(fb->mdct256, &freq_in[7*nshort], &transf_buf[2*nshort*7]);
         for (i = 0; i < nflat_ls; i+=4)
         {
             __m128 m1 = _mm_load_ps(&time_out[nlong+i]);
@@ -657,10 +653,10 @@
     int16_t i;
     ALIGN real_t windowed_buf[2*1024] = {0};
 
-    const real_t *window_long;
-    const real_t *window_long_prev;
-    const real_t *window_short;
-    const real_t *window_short_prev;
+    const real_t *window_long = NULL;
+    const real_t *window_long_prev = NULL;
+    const real_t *window_short = NULL;
+    const real_t *window_short_prev = NULL;
 
     uint16_t nlong = frame_len;
     uint16_t nshort = frame_len/8;
--- a/libfaad/filtbank.h
+++ b/libfaad/filtbank.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: filtbank.h,v 1.18 2003/12/17 14:43:16 menno Exp $
+** $Id: filtbank.h,v 1.19 2004/01/05 14:05:11 menno Exp $
 **/
 
 #ifndef __FILTBANK_H__
--- a/libfaad/fixed.h
+++ b/libfaad/fixed.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: fixed.h,v 1.16 2003/12/17 14:43:16 menno Exp $
+** $Id: fixed.h,v 1.17 2004/01/05 14:05:11 menno Exp $
 **/
 
 #ifndef __FIXED_H__
--- a/libfaad/hcr.c
+++ b/libfaad/hcr.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2002 A. Kurpiers
+** Copyright (C) 2002-2004 A. Kurpiers
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: hcr.c,v 1.12 2003/12/17 14:43:16 menno Exp $
+** $Id: hcr.c,v 1.13 2004/01/05 14:05:11 menno Exp $
 **/
 
 #include "common.h"
@@ -153,7 +153,6 @@
     bits_t	Segment[ 512 ];
 
     uint8_t PCW_decoded=0;
-    uint16_t segment_index=0, codeword_index=0;
     uint16_t nshort = hDecoder->frameLength/8;
 
 
--- a/libfaad/huffman.c
+++ b/libfaad/huffman.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: huffman.c,v 1.10 2003/12/17 14:43:16 menno Exp $
+** $Id: huffman.c,v 1.11 2004/01/05 14:05:11 menno Exp $
 **/
 
 #include "common.h"
@@ -38,6 +38,20 @@
 #include "codebook/hcb.h"
 
 
+/* static function declarations */
+static INLINE void huffman_sign_bits(bitfile *ld, int16_t *sp, uint8_t len);
+static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp);
+static uint8_t huffman_2step_quad(uint8_t cb, bitfile *ld, int16_t *sp);
+static uint8_t huffman_2step_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp);
+static uint8_t huffman_2step_pair(uint8_t cb, bitfile *ld, int16_t *sp);
+static uint8_t huffman_2step_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp);
+static uint8_t huffman_binary_quad(uint8_t cb, bitfile *ld, int16_t *sp);
+static uint8_t huffman_binary_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp);
+static uint8_t huffman_binary_pair(uint8_t cb, bitfile *ld, int16_t *sp);
+static uint8_t huffman_binary_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp);
+static int16_t huffman_codebook(uint8_t i);
+
+
 int8_t huffman_scale_factor(bitfile *ld)
 {
     uint16_t offset = 0;
@@ -104,10 +118,20 @@
     }
 }
 
+#ifdef _WIN32
+static INLINE uint32_t bsr(uint32_t bits)
+{
+    __asm
+    {
+        bsr eax, dword ptr [bits]
+    }
+}
+#endif
+
 static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp)
 {
     uint8_t neg, i;
-    int16_t j;
+    int32_t j;
 	int32_t off;
 
     if (sp < 0)
@@ -116,11 +140,12 @@
             return sp;
         neg = 1;
     } else {
-        if(sp != 16)
+        if (sp != 16)
             return sp;
         neg = 0;
     }
 
+#ifndef _WIN32
     for (i = 4; ; i++)
     {
         if (faad_get1bit(ld
@@ -129,11 +154,22 @@
             break;
         }
     }
+#else
+    /* maximum quantised value is 8192,
+     * so the maximum number of bits for 1 value is log[2](8192)=13
+     * minimum bits used when escape is present is 4 bits
+     * this leaves a maximum of 9 bits to be read at this point
+     */
+    j = faad_showbits(ld, 9) | 0xFFFFFE00;
+    i = 12 - bsr(~j);
+    faad_getbits(ld, i-3
+        DEBUGVAR(1,6,"huffman_getescape(): escape size"));
+#endif
 
     off = faad_getbits(ld, i
         DEBUGVAR(1,9,"huffman_getescape(): escape"));
 
-    j = off + (1<<i);
+    j = off | (1<<i);
     if (neg)
         j = -j;
 
@@ -216,7 +252,7 @@
     return 0;
 }
 
-static huffman_2step_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp)
+static uint8_t huffman_2step_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp)
 {
     uint8_t err = huffman_2step_pair(cb, ld, sp);
     huffman_sign_bits(ld, sp, PAIR_LEN);
@@ -357,7 +393,6 @@
     uint16_t offset = 0;
     uint8_t extra_bits;
     uint8_t i;
-    uint8_t save_cb = cb;
 
 
     switch (cb)
--- a/libfaad/huffman.h
+++ b/libfaad/huffman.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: huffman.h,v 1.20 2003/12/17 14:43:16 menno Exp $
+** $Id: huffman.h,v 1.21 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __HUFFMAN_H__
@@ -31,19 +31,6 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-
-
-static INLINE void huffman_sign_bits(bitfile *ld, int16_t *sp, uint8_t len);
-static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp);
-static uint8_t huffman_2step_quad(uint8_t cb, bitfile *ld, int16_t *sp);
-static uint8_t huffman_2step_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp);
-static uint8_t huffman_2step_pair(uint8_t cb, bitfile *ld, int16_t *sp);
-static huffman_2step_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp);
-static uint8_t huffman_binary_quad(uint8_t cb, bitfile *ld, int16_t *sp);
-static uint8_t huffman_binary_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp);
-static uint8_t huffman_binary_pair(uint8_t cb, bitfile *ld, int16_t *sp);
-static uint8_t huffman_binary_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp);
-static int16_t huffman_codebook(uint8_t i);
 
 int8_t huffman_scale_factor(bitfile *ld);
 uint8_t huffman_spectral_data(uint8_t cb, bitfile *ld, int16_t *sp);
--- a/libfaad/ic_predict.c
+++ b/libfaad/ic_predict.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: ic_predict.c,v 1.19 2003/12/17 14:43:16 menno Exp $
+** $Id: ic_predict.c,v 1.20 2004/01/05 14:05:12 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/ic_predict.h
+++ b/libfaad/ic_predict.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: ic_predict.h,v 1.15 2003/12/17 14:43:16 menno Exp $
+** $Id: ic_predict.h,v 1.16 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifdef MAIN_DEC
--- a/libfaad/iq_table.h
+++ b/libfaad/iq_table.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: iq_table.h,v 1.11 2003/12/17 14:43:16 menno Exp $
+** $Id: iq_table.h,v 1.12 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef IQ_TABLE_H__
--- a/libfaad/is.c
+++ b/libfaad/is.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: is.c,v 1.18 2003/12/17 14:43:16 menno Exp $
+** $Id: is.c,v 1.19 2004/01/05 14:05:12 menno Exp $
 **/
 
 #include "common.h"
@@ -47,7 +47,7 @@
                uint16_t frame_len)
 {
     uint8_t g, sfb, b;
-    uint16_t i, k;
+    uint16_t i;
 #ifndef FIXED_POINT
     real_t scale;
 #else
@@ -84,18 +84,17 @@
                        do not touch left channel */
                     for (i = icsr->swb_offset[sfb]; i < icsr->swb_offset[sfb+1]; i++)
                     {
-                        k = (group*nshort)+i;
 #ifndef FIXED_POINT
-                        r_spec[k] = MUL_R(l_spec[k], scale);
+                        r_spec[(group*nshort)+i] = MUL_R(l_spec[(group*nshort)+i], scale);
 #else
                         if (exp < 0)
-                            r_spec[k] = l_spec[k] << -exp;
+                            r_spec[(group*nshort)+i] = l_spec[(group*nshort)+i] << -exp;
                         else
-                            r_spec[k] = l_spec[k] >> exp;
-                        r_spec[k] = MUL_C(r_spec[k], pow05_table[frac + 3]);
+                            r_spec[(group*nshort)+i] = l_spec[(group*nshort)+i] >> exp;
+                        r_spec[(group*nshort)+i] = MUL_C(r_spec[(group*nshort)+i], pow05_table[frac + 3]);
 #endif
                         if (is_intensity(icsr, g, sfb) != invert_intensity(ics, g, sfb))
-                            r_spec[k] = -r_spec[k];
+                            r_spec[(group*nshort)+i] = -r_spec[(group*nshort)+i];
                     }
                 }
             }
--- a/libfaad/is.h
+++ b/libfaad/is.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: is.h,v 1.12 2003/12/17 14:43:16 menno Exp $
+** $Id: is.h,v 1.13 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __IS_H__
--- a/libfaad/kbd_win.h
+++ b/libfaad/kbd_win.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: kbd_win.h,v 1.12 2003/12/17 14:43:16 menno Exp $
+** $Id: kbd_win.h,v 1.13 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __KBD_WIN_H__
--- a/libfaad/lt_predict.c
+++ b/libfaad/lt_predict.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: lt_predict.c,v 1.19 2003/12/17 14:43:16 menno Exp $
+** $Id: lt_predict.c,v 1.20 2004/01/05 14:05:12 menno Exp $
 **/
 
 
@@ -37,6 +37,11 @@
 #include "filtbank.h"
 #include "tns.h"
 
+
+/* static function declarations */
+static int16_t real_to_int16(real_t sig_in);
+
+
 /* check if the object type is an object type that can have LTP */
 uint8_t is_ltp_ot(uint8_t object_type)
 {
@@ -128,7 +133,7 @@
 }
 
 #ifdef FIXED_POINT
-INLINE int16_t real_to_int16(real_t sig_in)
+static INLINE int16_t real_to_int16(real_t sig_in)
 {
     if (sig_in >= 0)
     {
@@ -144,7 +149,7 @@
     return (sig_in >> REAL_BITS);
 }
 #else
-INLINE int16_t real_to_int16(real_t sig_in)
+static INLINE int16_t real_to_int16(real_t sig_in)
 {
     if (sig_in >= 0)
     {
--- a/libfaad/lt_predict.h
+++ b/libfaad/lt_predict.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: lt_predict.h,v 1.12 2003/12/17 14:43:16 menno Exp $
+** $Id: lt_predict.h,v 1.13 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifdef LTP_DEC
@@ -54,9 +54,6 @@
                      real_t *overlap,
                      uint16_t frame_len,
                      uint8_t object_type);
-
-
-static int16_t real_to_int16(real_t sig_in);
 
 #ifdef __cplusplus
 }
--- a/libfaad/mdct.c
+++ b/libfaad/mdct.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: mdct.c,v 1.36 2003/12/23 18:41:42 menno Exp $
+** $Id: mdct.c,v 1.37 2004/01/05 14:05:12 menno Exp $
 **/
 
 /*
@@ -119,7 +119,8 @@
 };
 #endif
 
-uint8_t map_N_to_idx(uint16_t N)
+#ifdef FIXED_POINT
+static uint8_t map_N_to_idx(uint16_t N)
 {
     /* gives an index into const_tab above */
     /* for normal AAC deocding (eg. no scalable profile) only */
@@ -139,6 +140,7 @@
     }
     return 0;
 }
+#endif
 
 mdct_info *faad_mdct_init(uint16_t N)
 {
--- a/libfaad/mdct.h
+++ b/libfaad/mdct.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: mdct.h,v 1.21 2003/12/17 14:43:16 menno Exp $
+** $Id: mdct.h,v 1.22 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __MDCT_H__
--- a/libfaad/mp4.c
+++ b/libfaad/mp4.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: mp4.c,v 1.25 2003/12/17 14:43:16 menno Exp $
+** $Id: mp4.c,v 1.26 2004/01/05 14:05:12 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/mp4.h
+++ b/libfaad/mp4.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: mp4.h,v 1.16 2003/12/17 14:43:16 menno Exp $
+** $Id: mp4.h,v 1.17 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __MP4_H__
--- a/libfaad/ms.c
+++ b/libfaad/ms.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: ms.c,v 1.12 2003/12/17 14:43:16 menno Exp $
+** $Id: ms.c,v 1.13 2004/01/05 14:05:12 menno Exp $
 **/
 
 #include "common.h"
@@ -49,7 +49,7 @@
         {
             for (b = 0; b < ics->window_group_length[g]; b++)
             {
-                for(sfb = 0; sfb < ics->max_sfb; sfb++)
+                for (sfb = 0; sfb < ics->max_sfb; sfb++)
                 {
                     /* If intensity stereo coding or noise substitution is on
                        for a particular scalefactor band, no M/S stereo decoding
--- a/libfaad/ms.h
+++ b/libfaad/ms.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: ms.h,v 1.11 2003/12/17 14:43:16 menno Exp $
+** $Id: ms.h,v 1.12 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __MS_H__
--- a/libfaad/output.h
+++ b/libfaad/output.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: output.h,v 1.16 2003/12/23 18:41:42 menno Exp $
+** $Id: output.h,v 1.17 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __OUTPUT_H__
@@ -38,9 +38,6 @@
                     uint8_t channels,
                     uint16_t frame_len,
                     uint8_t format);
-
-static int64_t dither_output(uint8_t dithering, uint8_t shapingtype,
-                             uint16_t i, double Sum, uint8_t k);
 
 #ifdef __cplusplus
 }
--- a/libfaad/pns.c
+++ b/libfaad/pns.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: pns.c,v 1.28 2003/12/17 14:43:16 menno Exp $
+** $Id: pns.c,v 1.29 2004/01/05 14:05:12 menno Exp $
 **/
 
 #include "common.h"
@@ -29,6 +29,11 @@
 #include "structs.h"
 
 #include "pns.h"
+
+
+/* static function declarations */
+static void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t size,
+                            uint8_t sub);
 
 
 #ifdef FIXED_POINT
--- a/libfaad/pns.h
+++ b/libfaad/pns.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: pns.h,v 1.18 2003/12/17 14:43:16 menno Exp $
+** $Id: pns.h,v 1.19 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __PNS_H__
@@ -41,10 +41,6 @@
 void pns_decode(ic_stream *ics_left, ic_stream *ics_right,
                 real_t *spec_left, real_t *spec_right, uint16_t frame_len,
                 uint8_t channel_pair, uint8_t object_type);
-
-static INLINE int32_t random2();
-static void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t size,
-                            uint8_t sub);
 
 static INLINE uint8_t is_noise(ic_stream *ics, uint8_t group, uint8_t sfb)
 {
--- a/libfaad/pulse.c
+++ b/libfaad/pulse.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: pulse.c,v 1.13 2003/12/17 14:43:16 menno Exp $
+** $Id: pulse.c,v 1.14 2004/01/05 14:05:12 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/pulse.h
+++ b/libfaad/pulse.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: pulse.h,v 1.12 2003/12/17 14:43:16 menno Exp $
+** $Id: pulse.h,v 1.13 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __PULSE_H__
--- a/libfaad/rvlc.c
+++ b/libfaad/rvlc.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: rvlc.c,v 1.12 2003/12/17 14:43:16 menno Exp $
+** $Id: rvlc.c,v 1.13 2004/01/05 14:05:12 menno Exp $
 **/
 
 /* RVLC scalefactor decoding
@@ -52,6 +52,22 @@
 
 //#define PRINT_RVLC
 
+/* static function declarations */
+static uint8_t rvlc_decode_sf_forward(ic_stream *ics,
+                                      bitfile *ld_sf,
+                                      bitfile *ld_esc,
+                                      uint8_t *is_used);
+#if 0
+static uint8_t rvlc_decode_sf_reverse(ic_stream *ics,
+                                      bitfile *ld_sf,
+                                      bitfile *ld_esc,
+                                      uint8_t is_used);
+#endif
+static int8_t rvlc_huffman_sf(bitfile *ld_sf, bitfile *ld_esc,
+                              int8_t direction);
+static int8_t rvlc_huffman_esc(bitfile *ld_esc, int8_t direction);
+
+
 uint8_t rvlc_scale_factor_data(ic_stream *ics, bitfile *ld)
 {
     uint8_t bits = 9;
@@ -235,6 +251,7 @@
     return 0;
 }
 
+#if 0 // not used right now, doesn't work correctly yet
 static uint8_t rvlc_decode_sf_reverse(ic_stream *ics, bitfile *ld_sf, bitfile *ld_esc,
                                       uint8_t intensity_used)
 {
@@ -337,6 +354,7 @@
 
     return 0;
 }
+#endif
 
 /* index == 99 means not allowed codeword */
 static rvlc_huff_table book_rvlc[] = {
@@ -508,4 +526,5 @@
     return h->index;
 }
 
-#endif
\ No newline at end of file
+#endif
+
--- a/libfaad/rvlc.h
+++ b/libfaad/rvlc.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: rvlc.h,v 1.9 2003/12/17 14:43:16 menno Exp $
+** $Id: rvlc.h,v 1.10 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __RVLC_SCF_H__
@@ -45,18 +45,6 @@
 
 uint8_t rvlc_scale_factor_data(ic_stream *ics, bitfile *ld);
 uint8_t rvlc_decode_scale_factors(ic_stream *ics, bitfile *ld);
-
-static uint8_t rvlc_decode_sf_forward(ic_stream *ics,
-                                      bitfile *ld_sf,
-                                      bitfile *ld_esc,
-                                      uint8_t *is_used);
-static uint8_t rvlc_decode_sf_reverse(ic_stream *ics,
-                                      bitfile *ld_sf,
-                                      bitfile *ld_esc,
-                                      uint8_t is_used);
-static int8_t rvlc_huffman_sf(bitfile *ld_sf, bitfile *ld_esc,
-                              int8_t direction);
-static int8_t rvlc_huffman_esc(bitfile *ld_esc, int8_t direction);
 
 
 #ifdef __cplusplus
--- a/libfaad/sbr_dct.c
+++ b/libfaad/sbr_dct.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_dct.c,v 1.9 2003/12/17 14:43:16 menno Exp $
+** $Id: sbr_dct.c,v 1.10 2004/01/05 14:05:12 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/sbr_dct.h
+++ b/libfaad/sbr_dct.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_dct.h,v 1.9 2003/12/17 14:43:16 menno Exp $
+** $Id: sbr_dct.h,v 1.10 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __SBR_DCT_H__
--- a/libfaad/sbr_dec.c
+++ b/libfaad/sbr_dec.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_dec.c,v 1.18 2003/12/17 14:43:16 menno Exp $
+** $Id: sbr_dec.c,v 1.19 2004/01/05 14:05:12 menno Exp $
 **/
 
 
@@ -41,6 +41,8 @@
 #include "sbr_hfgen.h"
 #include "sbr_hfadj.h"
 
+/* static function declarations */
+static void sbr_save_prev_data(sbr_info *sbr, uint8_t ch);
 
 sbr_info *sbrDecodeInit(uint16_t framelength
 #ifdef DRM
@@ -113,7 +115,7 @@
     }
 }
 
-void sbr_save_prev_data(sbr_info *sbr, uint8_t ch)
+static void sbr_save_prev_data(sbr_info *sbr, uint8_t ch)
 {
     uint8_t i;
 
--- a/libfaad/sbr_dec.h
+++ b/libfaad/sbr_dec.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_dec.h,v 1.13 2003/12/17 14:43:16 menno Exp $
+** $Id: sbr_dec.h,v 1.14 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __SBR_DEC_H__
--- a/libfaad/sbr_e_nf.c
+++ b/libfaad/sbr_e_nf.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_e_nf.c,v 1.10 2003/12/17 14:43:16 menno Exp $
+** $Id: sbr_e_nf.c,v 1.11 2004/01/05 14:05:12 menno Exp $
 **/
 
 #include "common.h"
@@ -53,39 +53,39 @@
     REAL_CONST(0.0078125), REAL_CONST(0.015625),
     REAL_CONST(0.03125), REAL_CONST(0.0625),
     REAL_CONST(0.125), REAL_CONST(0.25),
-    REAL_CONST(0.5), REAL_CONST(1),
-    REAL_CONST(2), REAL_CONST(4),
-    REAL_CONST(8), REAL_CONST(16),
-    REAL_CONST(32), REAL_CONST(64),
-    REAL_CONST(128), REAL_CONST(256),
-    REAL_CONST(512), REAL_CONST(1024),
-    REAL_CONST(2048), REAL_CONST(4096),
-    REAL_CONST(8192), REAL_CONST(16384),
-    REAL_CONST(32768), REAL_CONST(65536),
-    REAL_CONST(131072), REAL_CONST(262144),
-    REAL_CONST(524288), REAL_CONST(1048576),
-    REAL_CONST(2097152), REAL_CONST(4194304),
-    REAL_CONST(8388608), REAL_CONST(16777216),
-    REAL_CONST(33554432), REAL_CONST(67108864),
-    REAL_CONST(134217728), REAL_CONST(268435456),
-    REAL_CONST(536870912), REAL_CONST(1073741824),
-    REAL_CONST(2147483648), REAL_CONST(4294967296),
-    REAL_CONST(8589934592), REAL_CONST(17179869184),
-    REAL_CONST(34359738368), REAL_CONST(68719476736),
-    REAL_CONST(137438953472), REAL_CONST(274877906944),
-    REAL_CONST(549755813888), REAL_CONST(1099511627776),
-    REAL_CONST(2199023255552), REAL_CONST(4398046511104),
-    REAL_CONST(8796093022208), REAL_CONST(17592186044416),
-    REAL_CONST(35184372088832), REAL_CONST(70368744177664),
-    REAL_CONST(140737488355328), REAL_CONST(281474976710656),
-    REAL_CONST(562949953421312), REAL_CONST(1125899906842624),
-    REAL_CONST(2251799813685248), REAL_CONST(4503599627370496),
-    REAL_CONST(9007199254740992), REAL_CONST(18014398509481984),
-    REAL_CONST(36028797018963968), REAL_CONST(72057594037927936),
-    REAL_CONST(144115188075855870), REAL_CONST(288230376151711740),
-    REAL_CONST(576460752303423490), REAL_CONST(1152921504606847000),
-    REAL_CONST(2305843009213694000), REAL_CONST(4611686018427387900),
-    REAL_CONST(9223372036854775800), REAL_CONST(1.8446744073709552E+019),
+    REAL_CONST(0.5), REAL_CONST(1.0),
+    REAL_CONST(2.0), REAL_CONST(4.0),
+    REAL_CONST(8.0), REAL_CONST(16.0),
+    REAL_CONST(32.0), REAL_CONST(64.0),
+    REAL_CONST(128.0), REAL_CONST(256.0),
+    REAL_CONST(512.0), REAL_CONST(1024.0),
+    REAL_CONST(2048.0), REAL_CONST(4096.0),
+    REAL_CONST(8192.0), REAL_CONST(16384.0),
+    REAL_CONST(32768.0), REAL_CONST(65536.0),
+    REAL_CONST(131072.0), REAL_CONST(262144.0),
+    REAL_CONST(524288.0), REAL_CONST(1048576.0),
+    REAL_CONST(2097152.0), REAL_CONST(4194304.0),
+    REAL_CONST(8388608.0), REAL_CONST(16777216.0),
+    REAL_CONST(33554432.0), REAL_CONST(67108864.0),
+    REAL_CONST(134217728.0), REAL_CONST(268435456.0),
+    REAL_CONST(536870912.0), REAL_CONST(1073741824.0),
+    REAL_CONST(2147483648.0), REAL_CONST(4294967296.0),
+    REAL_CONST(8589934592.0), REAL_CONST(17179869184.0),
+    REAL_CONST(34359738368.0), REAL_CONST(68719476736.0),
+    REAL_CONST(137438953472.0), REAL_CONST(274877906944.0),
+    REAL_CONST(549755813888.0), REAL_CONST(1099511627776.0),
+    REAL_CONST(2199023255552.0), REAL_CONST(4398046511104.0),
+    REAL_CONST(8796093022208.0), REAL_CONST(17592186044416.0),
+    REAL_CONST(35184372088832.0), REAL_CONST(70368744177664.0),
+    REAL_CONST(140737488355328.0), REAL_CONST(281474976710656.0),
+    REAL_CONST(562949953421312.0), REAL_CONST(1125899906842624.0),
+    REAL_CONST(2251799813685248.0), REAL_CONST(4503599627370496.0),
+    REAL_CONST(9007199254740992.0), REAL_CONST(18014398509481984.0),
+    REAL_CONST(36028797018963968.0), REAL_CONST(72057594037927936.0),
+    REAL_CONST(144115188075855870.0), REAL_CONST(288230376151711740.0),
+    REAL_CONST(576460752303423490.0), REAL_CONST(1152921504606847000.0),
+    REAL_CONST(2305843009213694000.0), REAL_CONST(4611686018427387900.0),
+    REAL_CONST(9223372036854775800.0), REAL_CONST(1.8446744073709552E+019),
     REAL_CONST(3.6893488147419103E+019), REAL_CONST(7.3786976294838206E+019),
     REAL_CONST(1.4757395258967641E+020), REAL_CONST(2.9514790517935283E+020),
     REAL_CONST(5.9029581035870565E+020), REAL_CONST(1.1805916207174113E+021),
@@ -256,11 +256,7 @@
                 /* +6 for the *64 and -10 for the /32 in the synthesis QMF
                  * since this is a energy value: (x/32)^2 = (x^2)/1024
                  */
-                exp = (sbr->E[ch][k][l] >> amp) + 6
-#ifdef FIXED_POINT
-                    - 10
-#endif
-                    ;
+                exp = (sbr->E[ch][k][l] >> amp) + 6;
 
                 if ((exp < -P2_TABLE_OFFSET) || (exp > P2_TABLE_MAX))
                 {
@@ -287,11 +283,7 @@
                     sbr->Q_orig[ch][k][l] = 0;
                 } else {
                     exp = NOISE_FLOOR_OFFSET - sbr->Q[ch][k][l];
-#ifdef FIXED_POINT
-                    sbr->Q_orig[ch][k][l] = pow2deq_q[exp + P2Q_TABLE_OFFSET];
-#else
                     sbr->Q_orig[ch][k][l] = pow2deq[exp + P2_TABLE_OFFSET];
-#endif
                 }
             }
         }
@@ -311,11 +303,8 @@
         for (k = 0; k < sbr->n[sbr->f[0][l]]; k++)
         {
             /* +6: * 64 ; +1: * 2 ; -10: /1024 QMF */
-            exp0 = (sbr->E[0][k][l] >> amp0) + 7
-#ifdef FIXED_POINT
-                - 10
-#endif
-                ;
+            exp0 = (sbr->E[0][k][l] >> amp0) + 7;
+
             /* UN_MAP removed: (x / 4096) same as (x >> 12) */
             /* E[1] is always even so no need for compensating the divide by 2 with
              * an extra multiplication
@@ -334,11 +323,7 @@
 
                 /* FIXED POINT TODO: E_orig: INTEGER!! */
                 sbr->E_orig[1][k][l] = MUL_F(tmp, pow2deq_rcp[exp1 + P2_TABLE_RCP_OFFSET]);
-#ifdef FIXED_POINT
                 sbr->E_orig[0][k][l] = MUL_R(sbr->E_orig[1][k][l], pow2deq[exp1 + P2_TABLE_OFFSET]);
-#else
-                sbr->E_orig[0][k][l] = MUL_R(sbr->E_orig[1][k][l], pow2deq[exp1 + P2_TABLE_OFFSET]);
-#endif
             }
         }
     }
@@ -355,13 +340,8 @@
                 exp0 = NOISE_FLOOR_OFFSET - sbr->Q[0][k][l] + 1;
                 exp1 = sbr->Q[1][k][l] - 12;
 
-#ifdef FIXED_POINT
-                sbr->Q_orig[1][k][l] = MUL_F(pow2deq_q[exp0 + P2Q_TABLE_OFFSET], pow2deq_rcp[exp1 + P2_TABLE_RCP_OFFSET]);
-                sbr->Q_orig[0][k][l] = MUL_R(sbr->Q_orig[1][k][l], pow2deq_q[exp1 + P2Q_TABLE_OFFSET]);
-#else
                 sbr->Q_orig[1][k][l] = MUL_F(pow2deq[exp0 + P2_TABLE_OFFSET], pow2deq_rcp[exp1 + P2_TABLE_RCP_OFFSET]);
                 sbr->Q_orig[0][k][l] = MUL_R(sbr->Q_orig[1][k][l], pow2deq[exp1 + P2_TABLE_OFFSET]);
-#endif
             }
         }
     }
--- a/libfaad/sbr_e_nf.h
+++ b/libfaad/sbr_e_nf.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_e_nf.h,v 1.8 2003/12/17 14:43:16 menno Exp $
+** $Id: sbr_e_nf.h,v 1.9 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __SBR_E_NF_H__
--- a/libfaad/sbr_fbt.c
+++ b/libfaad/sbr_fbt.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_fbt.c,v 1.8 2003/12/17 14:43:16 menno Exp $
+** $Id: sbr_fbt.c,v 1.9 2004/01/05 14:05:12 menno Exp $
 **/
 
 /* Calculate frequency band tables */
@@ -36,6 +36,10 @@
 
 #include "sbr_syntax.h"
 #include "sbr_fbt.h"
+
+/* static function declarations */
+static int32_t find_bands(uint8_t warp, uint8_t bands, uint8_t a0, uint8_t a1);
+
 
 /* calculate the start QMF channel for the master frequency band table */
 /* parameter is also called k0 */
--- a/libfaad/sbr_fbt.h
+++ b/libfaad/sbr_fbt.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_fbt.h,v 1.8 2003/12/17 14:43:16 menno Exp $
+** $Id: sbr_fbt.h,v 1.9 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __SBR_FBT_H__
@@ -32,7 +32,6 @@
 extern "C" {
 #endif
 
-static int32_t find_bands(uint8_t warp, uint8_t bands, uint8_t a0, uint8_t a1);
 uint8_t qmf_start_channel(uint8_t bs_start_freq, uint8_t bs_samplerate_mode,
                            uint32_t sample_rate);
 uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate,
--- a/libfaad/sbr_hfadj.c
+++ b/libfaad/sbr_hfadj.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_hfadj.c,v 1.9 2003/12/17 14:43:16 menno Exp $
+** $Id: sbr_hfadj.c,v 1.10 2004/01/05 14:05:12 menno Exp $
 **/
 
 /* High Frequency adjustment */
@@ -37,6 +37,20 @@
 
 #include "sbr_noise.h"
 
+
+/* static function delcarations */
+static void map_noise_data(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch);
+static void map_sinusoids(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch);
+static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj,
+                                      qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch);
+static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch);
+#ifdef SBR_LOW_POWER
+static void calc_gain_groups(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch);
+static void aliasing_reduction(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch);
+#endif
+static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch);
+
+
 void hf_adjustment(sbr_info *sbr, qmf_t Xsbr[MAX_NTSRHFG][64]
 #ifdef SBR_LOW_POWER
                    ,real_t *deg /* aliasing degree */
@@ -43,7 +57,7 @@
 #endif
                    ,uint8_t ch)
 {
-    ALIGN sbr_hfadj_info adj = {0};
+    ALIGN sbr_hfadj_info adj = {{{0}}};
 
     map_noise_data(sbr, &adj, ch);
     map_sinusoids(sbr, &adj, ch);
@@ -266,6 +280,7 @@
 #define EPS (1e-12)
 
 #define ONE (1)
+
 
 static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch)
 {
--- a/libfaad/sbr_hfadj.h
+++ b/libfaad/sbr_hfadj.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_hfadj.h,v 1.8 2003/12/17 14:43:16 menno Exp $
+** $Id: sbr_hfadj.h,v 1.9 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __SBR_HFADJ_H__
@@ -51,20 +51,6 @@
                    ,real_t *deg
 #endif
                    ,uint8_t ch);
-
-
-static void map_envelope_data(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch);
-static void map_noise_data(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch);
-static void map_sinusoids(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch);
-static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj,
-                                      qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch);
-static void additional_component_levels(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch);
-static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch);
-#ifdef SBR_LOW_POWER
-static void calc_gain_groups(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch);
-static void aliasing_reduction(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch);
-#endif
-static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch);
 
 
 #ifdef __cplusplus
--- a/libfaad/sbr_hfgen.c
+++ b/libfaad/sbr_hfgen.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_hfgen.c,v 1.11 2003/12/17 14:43:16 menno Exp $
+** $Id: sbr_hfgen.c,v 1.12 2004/01/05 14:05:12 menno Exp $
 **/
 
 /* High Frequency generation */
@@ -36,7 +36,22 @@
 #include "sbr_hfgen.h"
 #include "sbr_fbt.h"
 
-void hf_generation(sbr_info *sbr, const qmf_t Xlow[MAX_NTSRHFG][32],
+
+/* static function declarations */
+static void calc_prediction_coef(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][32],
+                                 complex_t *alpha_0, complex_t *alpha_1
+#ifdef SBR_LOW_POWER
+                                 , real_t *rxx
+#endif
+                                 );
+#ifdef SBR_LOW_POWER
+static void calc_aliasing_degree(sbr_info *sbr, real_t *rxx, real_t *deg);
+#endif
+static void calc_chirp_factors(sbr_info *sbr, uint8_t ch);
+static void patch_construction(sbr_info *sbr);
+
+
+void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][32],
                    qmf_t Xhigh[MAX_NTSRHFG][64]
 #ifdef SBR_LOW_POWER
                    ,real_t *deg
@@ -172,7 +187,7 @@
 
 #ifdef SBR_LOW_POWER
 static void auto_correlation(sbr_info *sbr, acorr_coef *ac,
-                             const qmf_t buffer[MAX_NTSRHFG][32],
+                             qmf_t buffer[MAX_NTSRHFG][32],
                              uint8_t bd, uint8_t len)
 {
     real_t r01 = 0, r02 = 0, r11 = 0;
@@ -180,6 +195,7 @@
     uint8_t offset = sbr->tHFAdj;
     const real_t rel = 1 / (1 + 1e-6f);
 
+
     for (j = offset; j < len + offset; j++)
     {
         r01 += QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-1][bd]);
@@ -199,7 +215,7 @@
     ac->det = MUL_R(RE(ac->r11), RE(ac->r22)) - MUL_C(MUL_R(RE(ac->r12), RE(ac->r12)), rel);
 }
 #else
-static void auto_correlation(sbr_info *sbr, acorr_coef *ac, const qmf_t buffer[MAX_NTSRHFG][32],
+static void auto_correlation(sbr_info *sbr, acorr_coef *ac, qmf_t buffer[MAX_NTSRHFG][32],
                              uint8_t bd, uint8_t len)
 {
     real_t r01r = 0, r01i = 0, r02r = 0, r02i = 0, r11r = 0;
@@ -243,7 +259,7 @@
 #endif
 
 /* calculate linear prediction coefficients using the covariance method */
-static void calc_prediction_coef(sbr_info *sbr, const qmf_t Xlow[MAX_NTSRHFG][32],
+static void calc_prediction_coef(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][32],
                                  complex_t *alpha_0, complex_t *alpha_1
 #ifdef SBR_LOW_POWER
                                  , real_t *rxx
--- a/libfaad/sbr_hfgen.h
+++ b/libfaad/sbr_hfgen.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_hfgen.h,v 1.9 2003/12/17 14:43:16 menno Exp $
+** $Id: sbr_hfgen.h,v 1.10 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __SBR_HFGEN_H__
@@ -32,22 +32,12 @@
 extern "C" {
 #endif
 
-void hf_generation(sbr_info *sbr, const qmf_t Xlow[MAX_NTSRHFG][32],
+void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][32],
                    qmf_t Xhigh[MAX_NTSRHFG][64]
 #ifdef SBR_LOW_POWER
                    ,real_t *deg
 #endif
                    ,uint8_t ch);
-
-static void calc_prediction_coef(sbr_info *sbr, const qmf_t Xlow[MAX_NTSRHFG][32],
-                                 complex_t *alpha_0, complex_t *alpha_1
-#ifdef SBR_LOW_POWER
-                                 , real_t *rxx
-#endif
-                                 );
-static void calc_aliasing_degree(sbr_info *sbr, real_t *rxx, real_t *deg);
-static void calc_chirp_factors(sbr_info *sbr, uint8_t ch);
-static void patch_construction(sbr_info *sbr);
 
 #ifdef __cplusplus
 }
--- a/libfaad/sbr_huff.c
+++ b/libfaad/sbr_huff.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_huff.c,v 1.12 2003/12/17 14:43:16 menno Exp $
+** $Id: sbr_huff.c,v 1.13 2004/01/05 14:05:12 menno Exp $
 **/
 
 #include "common.h"
@@ -220,7 +220,7 @@
 };
 
 
-INLINE int16_t sbr_huff_dec(bitfile *ld, sbr_huff_tab t_huff)
+static INLINE int16_t sbr_huff_dec(bitfile *ld, sbr_huff_tab t_huff)
 {
     uint8_t bit;
     int16_t index = 0;
--- a/libfaad/sbr_huff.h
+++ b/libfaad/sbr_huff.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_huff.h,v 1.12 2003/12/17 14:43:16 menno Exp $
+** $Id: sbr_huff.h,v 1.13 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __SBR_HUFF_H__
--- a/libfaad/sbr_noise.h
+++ b/libfaad/sbr_noise.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_noise.h,v 1.8 2003/12/17 14:43:16 menno Exp $
+** $Id: sbr_noise.h,v 1.9 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __SBR_NOISE_H__
@@ -557,4 +557,5 @@
 #ifdef __cplusplus
 
 #endif
-#endif
\ No newline at end of file
+#endif
+
--- a/libfaad/sbr_qmf.c
+++ b/libfaad/sbr_qmf.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_qmf.c,v 1.18 2003/12/17 14:43:16 menno Exp $
+** $Id: sbr_qmf.c,v 1.19 2004/01/05 14:05:12 menno Exp $
 **/
 
 #include "common.h"
@@ -82,7 +82,11 @@
         /* add new samples to input buffer x */
         for (n = 32 - 1; n >= 0; n--)
         {
+#ifdef FIXED_POINT
+            qmfa->x[n] = (input[in++]) >> 5;
+#else
             qmfa->x[n] = input[in++];
+#endif
         }
 
         /* window and summation to create array u */
@@ -109,7 +113,11 @@
         {
             if (n < kx)
             {
+#ifdef FIXED_POINT
+                QMF_RE(X[l + offset][n]) = u[n] << 1;
+#else
                 QMF_RE(X[l + offset][n]) = 2. * u[n];
+#endif
             } else {
                 QMF_RE(X[l + offset][n]) = 0;
             }
@@ -129,8 +137,13 @@
         {
             if (n < kx)
             {
+#ifdef FIXED_POINT
+                QMF_RE(X[l + offset][n]) = y[n] << 1;
+                QMF_IM(X[l + offset][n]) = -y[63-n] << 1;
+#else
                 QMF_RE(X[l + offset][n]) = 2. * y[n];
                 QMF_IM(X[l + offset][n]) = -2. * y[63-n];
+#endif
             } else {
                 QMF_RE(X[l + offset][n]) = 0;
                 QMF_IM(X[l + offset][n]) = 0;
@@ -184,7 +197,7 @@
 }
 
 #ifdef SBR_LOW_POWER
-void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t X[MAX_NTSRHFG][64],
+void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
                           real_t *output)
 {
     ALIGN real_t x[64];
@@ -210,7 +223,11 @@
         /* calculate 128 samples */
         for (k = 0; k < 64; k++)
         {
+#ifdef FIXED_POINT
+            x[k] = QMF_RE(X[l][k]);
+#else
             x[k] = QMF_RE(X[l][k]) / 32.;
+#endif
         }
 
         for (n = 0; n < 32; n++)
@@ -266,37 +283,7 @@
     }
 }
 
-void DST2(real_t *in, real_t *out, int32_t len)
-{
-    int r, i;
-
-    for (r = 1; r <= len; r++)
-    {
-        double sum = 0;
-        for (i = 1; i <= len; i++)
-        {
-            sum += in[i-1] * sin(((real_t)r)*((real_t)i-0.5)*M_PI/(real_t)len);
-        }
-        out[r-1] = (real_t)sum;
-    }
-}
-
-void DCT2(real_t *in, real_t *out, int32_t len)
-{
-    int r, i;
-
-    for (r = 0; r < len; r++)
-    {
-        double sum = 0;
-        for (i = 0; i < len; i++)
-        {
-            sum += in[i] * cos(((real_t)r)*((real_t)i+0.5)*M_PI/(real_t)len);
-        }
-        out[r] = (real_t)sum;
-    }
-}
-
-void sbr_qmf_synthesis_64_sse(sbr_info *sbr, qmfs_info *qmfs, const qmf_t X[MAX_NTSRHFG][64],
+void sbr_qmf_synthesis_64_sse(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
                               real_t *output)
 {
     ALIGN real_t x[64];
@@ -322,7 +309,11 @@
         /* calculate 128 samples */
         for (k = 0; k < 64; k++)
         {
+#ifdef FIXED_POINT
+            x[k] = QMF_RE(X[l][k]);
+#else
             x[k] = QMF_RE(X[l][k]) / 32.;
+#endif
         }
 
         for (n = 0; n < 32; n++)
@@ -379,7 +370,7 @@
     }
 }
 #else
-void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t X[MAX_NTSRHFG][64],
+void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
                           real_t *output)
 {
     ALIGN real_t x1[64], x2[64];
@@ -459,7 +450,7 @@
     }
 }
 
-void sbr_qmf_synthesis_64_sse(sbr_info *sbr, qmfs_info *qmfs, const qmf_t X[MAX_NTSRHFG][64],
+void sbr_qmf_synthesis_64_sse(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
                               real_t *output)
 {
     ALIGN real_t x1[64], x2[64];
--- a/libfaad/sbr_qmf.h
+++ b/libfaad/sbr_qmf.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_qmf.h,v 1.13 2003/12/17 14:43:16 menno Exp $
+** $Id: sbr_qmf.h,v 1.14 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __SBR_QMF_H__
@@ -39,12 +39,10 @@
 
 void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
                          qmf_t X[MAX_NTSRHFG][32], uint8_t offset, uint8_t kx);
-void sbr_qmf_synthesis_32(qmfs_info *qmfs, const qmf_t *X,
+void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
                           real_t *output);
-void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t X[MAX_NTSRHFG][64],
-                          real_t *output);
 #ifdef USE_SSE
-void sbr_qmf_synthesis_64_sse(sbr_info *sbr, qmfs_info *qmfs, const qmf_t X[MAX_NTSRHFG][64],
+void sbr_qmf_synthesis_64_sse(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
                               real_t *output);
 #endif
 
--- a/libfaad/sbr_qmf_c.h
+++ b/libfaad/sbr_qmf_c.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_qmf_c.h,v 1.8 2003/12/17 14:43:16 menno Exp $
+** $Id: sbr_qmf_c.h,v 1.9 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __SBR_QMF_C_H__
@@ -361,4 +361,5 @@
     FRAC_CONST(-0.00056176925738), FRAC_CONST(-0.00055252865047)
 };
 
-#endif
\ No newline at end of file
+#endif
+
--- a/libfaad/sbr_syntax.c
+++ b/libfaad/sbr_syntax.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_syntax.c,v 1.17 2003/12/17 16:37:34 menno Exp $
+** $Id: sbr_syntax.c,v 1.18 2004/01/05 14:05:12 menno Exp $
 **/
 
 #include "common.h"
@@ -39,6 +39,17 @@
 #include "bits.h"
 #include "analysis.h"
 
+/* static function declarations */
+static void sbr_header(bitfile *ld, sbr_info *sbr);
+static uint8_t sbr_data(bitfile *ld, sbr_info *sbr);
+static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr);
+static uint8_t sbr_channel_pair_element(bitfile *ld, sbr_info *sbr);
+static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch);
+static void sbr_dtdf(bitfile *ld, sbr_info *sbr, uint8_t ch);
+static void invf_mode(bitfile *ld, sbr_info *sbr, uint8_t ch);
+static void sinusoidal_coding(bitfile *ld, sbr_info *sbr, uint8_t ch);
+
+
 static void sbr_reset(sbr_info *sbr)
 {
 #if 0
@@ -484,7 +495,7 @@
 {
     uint8_t i, env, rel, result;
     uint8_t bs_abs_bord, bs_abs_bord_1;
-    uint8_t bs_num_env;
+    uint8_t bs_num_env = 0;
 
     sbr->bs_frame_class[ch] = (uint8_t)faad_getbits(ld, 2
         DEBUGVAR(1,248,"sbr_grid(): bs_frame_class"));
--- a/libfaad/sbr_syntax.h
+++ b/libfaad/sbr_syntax.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_syntax.h,v 1.13 2003/12/17 14:43:16 menno Exp $
+** $Id: sbr_syntax.h,v 1.14 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __SBR_SYNTAX_H__
@@ -56,14 +56,6 @@
 
 
 uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr);
-static void sbr_header(bitfile *ld, sbr_info *sbr);
-static uint8_t sbr_data(bitfile *ld, sbr_info *sbr);
-static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr);
-static uint8_t sbr_channel_pair_element(bitfile *ld, sbr_info *sbr);
-static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch);
-static void sbr_dtdf(bitfile *ld, sbr_info *sbr, uint8_t ch);
-static void invf_mode(bitfile *ld, sbr_info *sbr, uint8_t ch);
-static void sinusoidal_coding(bitfile *ld, sbr_info *sbr, uint8_t ch);
 
 #ifdef __cplusplus
 }
--- a/libfaad/sbr_tf_grid.c
+++ b/libfaad/sbr_tf_grid.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_tf_grid.c,v 1.9 2003/12/17 14:43:16 menno Exp $
+** $Id: sbr_tf_grid.c,v 1.10 2004/01/05 14:05:12 menno Exp $
 **/
 
 /* Time/Frequency grid */
@@ -37,6 +37,15 @@
 #include "sbr_syntax.h"
 #include "sbr_tf_grid.h"
 
+
+/* static function declarations */
+#if 0
+static int16_t rel_bord_lead(sbr_info *sbr, uint8_t ch, uint8_t l);
+static int16_t rel_bord_trail(sbr_info *sbr, uint8_t ch, uint8_t l);
+#endif
+static uint8_t middleBorder(sbr_info *sbr, uint8_t ch);
+
+
 uint8_t envelope_time_border_vector(sbr_info *sbr, uint8_t ch)
 {
     uint8_t l, border, temp;
@@ -155,6 +164,7 @@
     }
 }
 
+#if 0
 static int16_t rel_bord_lead(sbr_info *sbr, uint8_t ch, uint8_t l)
 {
     uint8_t i;
@@ -209,10 +219,11 @@
 
     return 0;
 }
+#endif
 
 static uint8_t middleBorder(sbr_info *sbr, uint8_t ch)
 {
-    int8_t retval;
+    int8_t retval = 0;
 
     switch (sbr->bs_frame_class[ch])
     {
--- a/libfaad/sbr_tf_grid.h
+++ b/libfaad/sbr_tf_grid.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_tf_grid.h,v 1.8 2003/12/17 14:43:16 menno Exp $
+** $Id: sbr_tf_grid.h,v 1.9 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __SBR_TF_GRID_H__
@@ -35,10 +35,6 @@
 
 uint8_t envelope_time_border_vector(sbr_info *sbr, uint8_t ch);
 void noise_floor_time_border_vector(sbr_info *sbr, uint8_t ch);
-
-static int16_t rel_bord_lead(sbr_info *sbr, uint8_t ch, uint8_t l);
-static int16_t rel_bord_trail(sbr_info *sbr, uint8_t ch, uint8_t l);
-static uint8_t middleBorder(sbr_info *sbr, uint8_t ch);
 
 
 #ifdef __cplusplus
--- a/libfaad/sine_win.h
+++ b/libfaad/sine_win.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sine_win.h,v 1.10 2003/12/17 14:43:16 menno Exp $
+** $Id: sine_win.h,v 1.11 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __SINE_WIN_H__
--- a/libfaad/specrec.c
+++ b/libfaad/specrec.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: specrec.c,v 1.36 2003/12/23 18:41:42 menno Exp $
+** $Id: specrec.c,v 1.37 2004/01/05 14:05:12 menno Exp $
 **/
 
 /*
@@ -52,6 +52,11 @@
 #endif
 
 
+/* static function declarations */
+static void quant_to_spec(ic_stream *ics, real_t *spec_data, uint16_t frame_len);
+static uint8_t inverse_quantization(real_t *x_invquant, const int16_t *x_quant, const uint16_t frame_len);
+
+
 #ifdef LD_DEC
 ALIGN static const uint8_t num_swb_512_window[] =
 {
@@ -511,7 +516,7 @@
     uint8_t error = 0; /* Init error flag */
     const real_t *tab = iq_table;
 
-    for(i = 0; i < frame_len; i+=4)
+    for (i = 0; i < frame_len; i+=4)
     {
         x_invquant[i] = iquant(x_quant[i], tab, &error);
         x_invquant[i+1] = iquant(x_quant[i+1], tab, &error);
@@ -532,19 +537,19 @@
     0.0009765625, 0.001953125, 0.00390625,
     0.0078125, 0.015625, 0.03125,
     0.0625, 0.125, 0.25,
-    0.5, 1, 2,
-    4, 8, 16, 32,
-    64, 128, 256,
-    512, 1024, 2048,
-    4096, 8192, 16384,
-    32768, 65536, 131072,
-    262144, 524288, 1048576,
-    2097152, 4194304, 8388608,
-    16777216, 33554432, 67108864,
-    134217728, 268435456, 536870912,
-    1073741824, 2147483648, 4294967296,
-    8589934592, 17179869184, 34359738368,
-    68719476736, 137438953472, 274877906944
+    0.5, 1.0, 2.0,
+    4.0, 8.0, 16.0, 32.0,
+    64.0, 128.0, 256.0,
+    512.0, 1024.0, 2048.0,
+    4096.0, 8192.0, 16384.0,
+    32768.0, 65536.0, 131072.0,
+    262144.0, 524288.0, 1048576.0,
+    2097152.0, 4194304.0, 8388608.0,
+    16777216.0, 33554432.0, 67108864.0,
+    134217728.0, 268435456.0, 536870912.0,
+    1073741824.0, 2147483648.0, 4294967296.0,
+    8589934592.0, 17179869184.0, 34359738368.0,
+    68719476736.0, 137438953472.0, 274877906944.0
 };
 #endif
 
--- a/libfaad/specrec.h
+++ b/libfaad/specrec.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: specrec.h,v 1.22 2003/12/23 18:41:42 menno Exp $
+** $Id: specrec.h,v 1.23 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __SPECREC_H__
@@ -35,8 +35,6 @@
 #include "syntax.h"
 
 uint8_t window_grouping_info(faacDecHandle hDecoder, ic_stream *ics);
-static void quant_to_spec(ic_stream *ics, real_t *spec_data, uint16_t frame_len);
-static uint8_t inverse_quantization(real_t *x_invquant, const int16_t *x_quant, const uint16_t frame_len);
 void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics, real_t *x_invquant,
                         uint16_t frame_len);
 #ifdef USE_SSE
--- a/libfaad/ssr.c
+++ b/libfaad/ssr.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: ssr.c,v 1.11 2003/12/17 14:43:16 menno Exp $
+** $Id: ssr.c,v 1.12 2004/01/05 14:05:12 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/ssr.h
+++ b/libfaad/ssr.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: ssr.h,v 1.11 2003/12/17 14:43:16 menno Exp $
+** $Id: ssr.h,v 1.12 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __SSR_H__
--- a/libfaad/ssr_fb.c
+++ b/libfaad/ssr_fb.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: ssr_fb.c,v 1.9 2003/12/17 14:43:16 menno Exp $
+** $Id: ssr_fb.c,v 1.10 2004/01/05 14:05:12 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/ssr_ipqf.c
+++ b/libfaad/ssr_ipqf.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: ssr_ipqf.c,v 1.10 2003/12/17 14:43:16 menno Exp $
+** $Id: ssr_ipqf.c,v 1.11 2004/01/05 14:05:12 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/structs.h
+++ b/libfaad/structs.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: structs.h,v 1.23 2003/12/24 16:04:56 menno Exp $
+** $Id: structs.h,v 1.24 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __STRUCTS_H__
--- a/libfaad/syntax.c
+++ b/libfaad/syntax.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: syntax.c,v 1.63 2003/12/23 18:41:42 menno Exp $
+** $Id: syntax.c,v 1.64 2004/01/05 14:05:12 menno Exp $
 **/
 
 /*
@@ -51,6 +51,48 @@
 #endif
 
 
+/* static function declarations */
+static uint8_t single_lfe_channel_element(faacDecHandle hDecoder, bitfile *ld,
+                                          uint8_t channel, uint8_t *tag);
+static uint8_t channel_pair_element(faacDecHandle hDecoder, bitfile *ld,
+                                    uint8_t channel, uint8_t *tag);
+#ifdef COUPLING_DEC
+static uint8_t coupling_channel_element(faacDecHandle hDecoder, bitfile *ld);
+#endif
+static uint16_t data_stream_element(faacDecHandle hDecoder, bitfile *ld);
+static uint8_t program_config_element(program_config *pce, bitfile *ld);
+static uint8_t fill_element(faacDecHandle hDecoder, bitfile *ld, drc_info *drc
+#ifdef SBR_DEC
+                            ,uint8_t sbr_ele
+#endif
+                            );
+static uint8_t individual_channel_stream(faacDecHandle hDecoder, element *ele,
+                                         bitfile *ld, ic_stream *ics, uint8_t scal_flag,
+                                         int16_t *spec_data);
+static uint8_t ics_info(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld,
+                        uint8_t common_window);
+static uint8_t section_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld);
+static uint8_t scale_factor_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld);
+#ifdef SSR_DEC
+static void gain_control_data(bitfile *ld, ic_stream *ics);
+#endif
+static uint8_t spectral_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld,
+                             int16_t *spectral_data);
+static uint16_t extension_payload(bitfile *ld, drc_info *drc, uint16_t count);
+static uint8_t pulse_data(ic_stream *ics, pulse_info *pul, bitfile *ld);
+static void tns_data(ic_stream *ics, tns_info *tns, bitfile *ld);
+static uint8_t ltp_data(faacDecHandle hDecoder, ic_stream *ics, ltp_info *ltp, bitfile *ld);
+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);
+static uint8_t dynamic_range_info(bitfile *ld, drc_info *drc);
+static uint8_t excluded_channels(bitfile *ld, drc_info *drc);
+#ifdef SCALABLE_DEC
+static int8_t aac_scalable_main_header(faacDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2,
+                                       bitfile *ld, uint8_t this_layer_stereo);
+#endif
+
+
 /* Table 4.4.1 */
 int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC,
                         program_config *pce_out)
@@ -869,7 +911,7 @@
 
     for (i = 0; i < count; i++)
     {
-        uint8_t data = (uint8_t)faad_getbits(ld, LEN_BYTE
+        faad_getbits(ld, LEN_BYTE
             DEBUGVAR(1,64,"data_stream_element(): data_stream_byte"));
     }
 
@@ -1687,8 +1729,7 @@
 {
     int8_t i;
     uint8_t g;
-    int16_t *sp;
-    uint16_t k, p = 0;
+    uint16_t inc, k, p = 0;
     uint8_t groups = 0;
     uint8_t sect_cb;
     uint8_t result;
@@ -1698,9 +1739,6 @@
     int64_t count = faad_get_ts();
 #endif
 
-    sp = spectral_data;
-    /*memset(sp, 0, hDecoder->frameLength*sizeof(int16_t));*/
-
     for(g = 0; g < ics->num_window_groups; g++)
     {
         p = groups*nshort;
@@ -1709,6 +1747,8 @@
         {
             sect_cb = ics->sect_cb[g][i];
 
+            inc = (sect_cb >= FIRST_PAIR_HCB) ? 2 : 4;
+
             switch (sect_cb)
             {
             case ZERO_HCB:
@@ -1720,18 +1760,11 @@
                 break;
             default:
                 for (k = ics->sect_sfb_offset[g][ics->sect_start[g][i]];
-                     k < ics->sect_sfb_offset[g][ics->sect_end[g][i]]; k += 4)
+                     k < ics->sect_sfb_offset[g][ics->sect_end[g][i]]; k += inc)
                 {
-                    sp = spectral_data + p;
-
-                    if ((result = huffman_spectral_data(sect_cb, ld, sp)) > 0)
+                    if ((result = huffman_spectral_data(sect_cb, ld, &spectral_data[p])) > 0)
                         return result;
-                    if (sect_cb >= FIRST_PAIR_HCB)
-                    {
-                        if ((result = huffman_spectral_data(sect_cb, ld, sp+2)) > 0)
-                            return result;
-                    }
-                    p += 4;
+                    p += inc;
                 }
                 break;
             }
--- a/libfaad/syntax.h
+++ b/libfaad/syntax.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: syntax.h,v 1.44 2003/12/23 18:41:42 menno Exp $
+** $Id: syntax.h,v 1.45 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __SYNTAX_H__
@@ -115,50 +115,9 @@
                 uint8_t id_syn_ele);
 void raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo,
                     bitfile *ld, program_config *pce, drc_info *drc);
+uint8_t reordered_spectral_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld,
+                                int16_t *spectral_data);
 
-
-/* static functions */
-static uint8_t single_lfe_channel_element(faacDecHandle hDecoder, bitfile *ld,
-                                          uint8_t channel, uint8_t *tag);
-static uint8_t channel_pair_element(faacDecHandle hDecoder, bitfile *ld,
-                                    uint8_t channel, uint8_t *tag);
-#ifdef COUPLING_DEC
-static uint8_t coupling_channel_element(faacDecHandle hDecoder, bitfile *ld);
-#endif
-static uint16_t data_stream_element(faacDecHandle hDecoder, bitfile *ld);
-static uint8_t program_config_element(program_config *pce, bitfile *ld);
-static uint8_t fill_element(faacDecHandle hDecoder, bitfile *ld, drc_info *drc
-#ifdef SBR_DEC
-                            ,uint8_t sbr_ele
-#endif
-                            );
-static uint8_t individual_channel_stream(faacDecHandle hDecoder, element *ele,
-                                         bitfile *ld, ic_stream *ics, uint8_t scal_flag,
-                                         int16_t *spec_data);
-static uint8_t ics_info(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld,
-                        uint8_t common_window);
-static uint8_t section_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld);
-static uint8_t scale_factor_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld);
-static void gain_control_data(bitfile *ld, ic_stream *ics);
-static uint8_t spectral_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld,
-                             int16_t *spectral_data);
-static uint16_t extension_payload(bitfile *ld, drc_info *drc, uint16_t count);
-#ifdef ERROR_RESILIENCE
-uint8_t reordered_spectral_data(faacDecHandle hDecoder, ic_stream *ics,
-                                bitfile *ld, int16_t *spectral_data);
-#endif
-static uint8_t pulse_data(ic_stream *ics, pulse_info *pul, bitfile *ld);
-static void tns_data(ic_stream *ics, tns_info *tns, bitfile *ld);
-static uint8_t ltp_data(faacDecHandle hDecoder, ic_stream *ics, ltp_info *ltp, bitfile *ld);
-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);
-static uint8_t dynamic_range_info(bitfile *ld, drc_info *drc);
-static uint8_t excluded_channels(bitfile *ld, drc_info *drc);
-#ifdef SCALABLE_DEC
-static int8_t aac_scalable_main_header(faacDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2,
-                                       bitfile *ld, uint8_t this_layer_stereo);
-#endif
 
 #ifdef __cplusplus
 }
--- a/libfaad/tns.c
+++ b/libfaad/tns.c
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: tns.c,v 1.28 2003/12/17 14:43:17 menno Exp $
+** $Id: tns.c,v 1.29 2004/01/05 14:05:12 menno Exp $
 **/
 
 #include "common.h"
@@ -30,6 +30,16 @@
 
 #include "syntax.h"
 #include "tns.h"
+
+
+/* static function declarations */
+static void tns_decode_coef(uint8_t order, uint8_t coef_res_bits, uint8_t coef_compress,
+                            uint8_t *coef, real_t *a);
+static void tns_ar_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *lpc,
+                          uint8_t order);
+static void tns_ma_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *lpc,
+                          uint8_t order);
+
 
 #ifdef _MSC_VER
 #pragma warning(disable:4305)
--- a/libfaad/tns.h
+++ b/libfaad/tns.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: tns.h,v 1.15 2003/12/17 14:43:17 menno Exp $
+** $Id: tns.h,v 1.16 2004/01/05 14:05:12 menno Exp $
 **/
 
 #ifndef __TNS_H__
@@ -40,13 +40,6 @@
                       uint8_t object_type, real_t *spec, uint16_t frame_len);
 void tns_encode_frame(ic_stream *ics, tns_info *tns, uint8_t sr_index,
                       uint8_t object_type, real_t *spec, uint16_t frame_len);
-
-static void tns_decode_coef(uint8_t order, uint8_t coef_res_bits, uint8_t coef_compress,
-                            uint8_t *coef, real_t *a);
-static void tns_ar_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *lpc,
-                          uint8_t order);
-static void tns_ma_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *lpc,
-                          uint8_t order);
 
 
 #ifdef __cplusplus
--- a/plugins/mpeg4ip/aa_file.cpp
+++ b/plugins/mpeg4ip/aa_file.cpp
@@ -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: aa_file.cpp,v 1.1 2003/08/07 17:21:21 menno Exp $
+** $Id: aa_file.cpp,v 1.2 2004/01/05 14:05:12 menno Exp $
 **/
 /*
  * aa_file.cpp - create media structure for aac files
@@ -26,7 +26,11 @@
 codec_data_t *aac_file_check (lib_message_func_t message,
                   const char *name,
                   double *max,
-                  char *desc[4])
+                  char *desc[4]
+#ifdef HAVE_PLUGIN_VERSION_0_8
+                , CConfigSet *pConfig
+#endif
+)
 {
   aac_codec_t *aac;
   int len = strlen(name);
--- a/plugins/mpeg4ip/faad2.cpp
+++ b/plugins/mpeg4ip/faad2.cpp
@@ -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: faad2.cpp,v 1.1 2003/08/07 17:21:21 menno Exp $
+** $Id: faad2.cpp,v 1.2 2004/01/05 14:05:12 menno Exp $
 **/
 #include "faad2.h"
 #include <mpeg4_audio_config.h>
@@ -26,6 +26,10 @@
 
 #define DEBUG_SYNC 2
 
+#ifndef M_LLU
+#define M_LLU M_64
+#define LLU U64
+#endif
 const char *aaclib="faad2";
 
 /*
@@ -282,7 +286,11 @@
                 int profile,
                 format_list_t *fptr,
                 const uint8_t *userdata,
-                uint32_t userdata_size)
+                uint32_t userdata_size
+#ifdef HAVE_PLUGIN_VERSION_0_8
+              ,CConfigSet *pConfig
+#endif
+              )
 {
   fmtp_parse_t *fmtp = NULL;
   if (compressor != NULL &&
@@ -344,6 +352,7 @@
   return -1;
 }
 
+#ifndef HAVE_PLUGIN_VERSION_0_8
 AUDIO_CODEC_WITH_RAW_FILE_PLUGIN("faad2",
                  aac_codec_create,
                  aac_do_pause,
@@ -355,7 +364,25 @@
                  aac_file_next_frame,
                  aac_file_used_for_frame,
                  aac_raw_file_seek_to,
-                 aac_file_eof);
+               aac_file_eof
+               );
+#else
+AUDIO_CODEC_WITH_RAW_FILE_PLUGIN("faad2",
+               aac_codec_create,
+               aac_do_pause,
+               aac_decode,
+               NULL,
+               aac_close,
+               aac_codec_check,
+               aac_file_check,
+               aac_file_next_frame,
+               aac_file_used_for_frame,
+               aac_raw_file_seek_to,
+               aac_file_eof,
+               NULL,
+               0
+               );
+#endif
 /* end file aa.cpp */
 
 
--- a/plugins/mpeg4ip/faad2.h
+++ b/plugins/mpeg4ip/faad2.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: faad2.h,v 1.1 2003/08/07 17:21:21 menno Exp $
+** $Id: faad2.h,v 1.2 2004/01/05 14:05:12 menno Exp $
 **/
 /*
  * aa.h - class definition for AAC codec.
@@ -27,6 +27,11 @@
 #include "faad.h"
 #include "codec_plugin.h"
 
+#ifndef M_LLU
+#define M_LLU M_64
+#define LLU U64
+#endif
+
 typedef struct aac_codec_t {
   codec_data_t c;
   audio_vft_t *m_vft;
@@ -68,7 +73,11 @@
 codec_data_t *aac_file_check(lib_message_func_t message,
                  const char *name,
                  double *max,
-                 char *desc[4]);
+                 char *desc[4]
+#ifdef HAVE_PLUGIN_VERSION_0_8
+               , CConfigSet *pConfig
+#endif
+);
 
 int aac_file_next_frame(codec_data_t *ifptr,
             uint8_t **buffer,