shithub: aacdec

Download patch

ref: 34148793ec79f0d0c46c38d3648b573d9d48bcfb
parent: 2cfe0e13e96fe21d3a132af144740c391c7a7327
author: menno <menno>
date: Sun Nov 2 15:24:05 EST 2003

Sync with Ahead CVS
temporarily removed dithering, should be moved outside of library (done) and into frontends. Dither code was also samplerate dependant, but only tables for 44kHz included.
various speed updates in sbr decoder, less memeory usage, code cleanup

--- a/frontend/audio.c
+++ b/frontend/audio.c
@@ -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.19 2003/09/03 20:19:29 menno Exp $
+** $Id: audio.c,v 1.20 2003/11/02 20:24:03 menno Exp $
 **/
 
 #ifdef _WIN32
@@ -52,10 +52,6 @@
     switch (outputFormat)
     {
     case FAAD_FMT_16BIT:
-    case FAAD_FMT_16BIT_DITHER:
-    case FAAD_FMT_16BIT_L_SHAPE:
-    case FAAD_FMT_16BIT_M_SHAPE:
-    case FAAD_FMT_16BIT_H_SHAPE:
         aufile->bits_per_sample = 16;
         break;
     case FAAD_FMT_24BIT:
@@ -103,10 +99,6 @@
     switch (aufile->outputFormat)
     {
     case FAAD_FMT_16BIT:
-    case FAAD_FMT_16BIT_DITHER:
-    case FAAD_FMT_16BIT_L_SHAPE:
-    case FAAD_FMT_16BIT_M_SHAPE:
-    case FAAD_FMT_16BIT_H_SHAPE:
         return write_audio_16bit(aufile, buf + offset*2, samples);
     case FAAD_FMT_24BIT:
         return write_audio_24bit(aufile, buf + offset*4, samples);
--- a/frontend/audio.h
+++ b/frontend/audio.h
@@ -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.10 2003/09/03 20:19:29 menno Exp $
+** $Id: audio.h,v 1.11 2003/11/02 20:24:03 menno Exp $
 **/
 
 #ifndef AUDIO_H_INCLUDED
--- a/frontend/main.c
+++ b/frontend/main.c
@@ -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.56 2003/10/19 19:33:16 menno Exp $
+** $Id: main.c,v 1.57 2003/11/02 20:24:03 menno Exp $
 **/
 
 #ifdef _WIN32
@@ -373,10 +373,6 @@
     fprintf(stdout, "        3:  32 bit PCM data.\n");
     fprintf(stdout, "        4:  32 bit floating point data.\n");
     fprintf(stdout, "        5:  64 bit floating point data.\n");
-    fprintf(stdout, "        6:  16 bit PCM data (dithered).\n");
-    fprintf(stdout, "        7:  16 bit PCM data (dithered with LIGHT noise shaping).\n");
-    fprintf(stdout, "        8:  16 bit PCM data (dithered with MEDIUM noise shaping).\n");
-    fprintf(stdout, "        9:  16 bit PCM data (dithered with HEAVY noise shaping).\n");
     fprintf(stdout, " -s X  Force the samplerate to X (for RAW files).\n");
     fprintf(stdout, " -l X  Set object type. Supported object types:\n");
     fprintf(stdout, "        1:  Main object type.\n");
@@ -1107,7 +1103,7 @@
                     outputFormat = FAAD_FMT_16BIT; /* just use default */
                 } else {
                     outputFormat = atoi(dr);
-                    if ((outputFormat < 1) || (outputFormat > 9))
+                    if ((outputFormat < 1) || (outputFormat > 5))
                         showHelp = 1;
                 }
             }
--- a/include/faad.h
+++ b/include/faad.h
@@ -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.33 2003/09/24 19:55:34 menno Exp $
+** $Id: faad.h,v 1.34 2003/11/02 20:24:03 menno Exp $
 **/
 
 #ifndef __AACDEC_H__
@@ -73,18 +73,14 @@
 #define FAAD_FMT_32BIT  3
 #define FAAD_FMT_FLOAT  4
 #define FAAD_FMT_DOUBLE 5
-#define FAAD_FMT_16BIT_DITHER  6
-#define FAAD_FMT_16BIT_L_SHAPE 7
-#define FAAD_FMT_16BIT_M_SHAPE 8
-#define FAAD_FMT_16BIT_H_SHAPE 9
 
 /* Capabilities */
-#define LC_DEC_CAP            (1<<0)
-#define MAIN_DEC_CAP          (1<<1)
-#define LTP_DEC_CAP           (1<<2)
-#define LD_DEC_CAP            (1<<3)
-#define ERROR_RESILIENCE_CAP  (1<<4)
-#define FIXED_POINT_CAP       (1<<5)
+#define LC_DEC_CAP           (1<<0) /* Can decode LC */
+#define MAIN_DEC_CAP         (1<<1) /* Can decode MAIN */
+#define LTP_DEC_CAP          (1<<2) /* Can decode LTP */
+#define LD_DEC_CAP           (1<<3) /* Can decode LD */
+#define ERROR_RESILIENCE_CAP (1<<4) /* Can decode ER */
+#define FIXED_POINT_CAP      (1<<5) /* Fixed point */
 
 /* Channel definitions */
 #define FRONT_CHANNEL_CENTER (1)
--- a/libfaad/Makefile.am
+++ b/libfaad/Makefile.am
@@ -1,7 +1,7 @@
 lib_LTLIBRARIES = libfaad.la
 include_HEADERS = ../include/faad.h
 
-libfaad_la_SOURCES = bits.c cfft.c decoder.c dither.c drc.c \
+libfaad_la_SOURCES = bits.c cfft.c decoder.c drc.c \
 error.c filtbank.c \
 ic_predict.c is.c lt_predict.c mdct.c mp4.c ms.c output.c pns.c \
 pulse.c specrec.c syntax.c tns.c hcr.c huffman.c \
@@ -9,7 +9,7 @@
 sbr_dct.c sbr_e_nf.c sbr_fbt.c sbr_hfadj.c sbr_hfgen.c \
 sbr_huff.c sbr_qmf.c sbr_syntax.c sbr_tf_grid.c sbr_dec.c \
 analysis.h bits.h cfft.h cfft_tab.h common.h \
-decoder.h dither.h drc.h error.h fixed.h filtbank.h \
+decoder.h drc.h error.h fixed.h filtbank.h \
 huffman.h ic_predict.h iq_table.h is.h kbd_win.h lt_predict.h mdct.h mp4.h \
 ms.h output.h pns.h pulse.h rvlc.h sine_win.h ssr.h ssr_fb.h ssr_ipqf.h \
 ssr_win.h specrec.h syntax.h structs.h tns.h \
--- a/libfaad/cfft.c
+++ b/libfaad/cfft.c
@@ -1,19 +1,19 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
 ** Copyright (C) 2003 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
 ** the Free Software Foundation; either version 2 of the License, or
 ** (at your option) any later version.
-** 
+**
 ** This program is distributed in the hope that it will be useful,
 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ** GNU General Public License for more details.
-** 
+**
 ** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software 
+** along with this program; if not, write to the Free Software
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
 ** Any non-GPL usage of this software or parts of this software is strictly
@@ -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.15 2003/10/19 18:11:19 menno Exp $
+** $Id: cfft.c,v 1.16 2003/11/02 20:24:03 menno Exp $
 **/
 
 /*
@@ -38,11 +38,6 @@
 #include "structs.h"
 
 #include <stdlib.h>
-#ifdef _WIN32_WCE
-#define assert(x)
-#else
-#include <assert.h>
-#endif
 
 #include "cfft.h"
 #include "cfft_tab.h"
@@ -537,13 +532,18 @@
 
     switch (n)
     {
-    case 60: cfft->tab = cfft_tab_60; break;
     case 64: cfft->tab = cfft_tab_64; break;
-    case 480: cfft->tab = cfft_tab_480; break;
     case 512: cfft->tab = cfft_tab_512; break;
 #ifdef LD_DEC
-    case 240: cfft->tab = cfft_tab_240; break;
     case 256: cfft->tab = cfft_tab_256; break;
+#endif
+
+#ifdef ALLOW_SMALL_FRAMELENGTH
+    case 60: cfft->tab = cfft_tab_60; break;
+    case 480: cfft->tab = cfft_tab_480; break;
+#ifdef LD_DEC
+    case 240: cfft->tab = cfft_tab_240; break;
+#endif
 #endif
     }
 #endif
--- a/libfaad/cfft_tab.h
+++ b/libfaad/cfft_tab.h
@@ -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.6 2003/10/19 18:11:19 menno Exp $
+** $Id: cfft_tab.h,v 1.8 2003/11/04 21:43:30 menno Exp $
 **/
 
 #ifndef __CFFT_TAB_H__
@@ -550,6 +550,7 @@
     { COEF_CONST(0.00000001), COEF_CONST(-1.00000000) }
 };
 
+#ifdef ALLOW_SMALL_FRAMELENGTH
 complex_t cfft_tab_480[] =
 {
     { COEF_CONST(1.00000000), COEF_CONST(0.00000000) },
@@ -1033,6 +1034,7 @@
     { COEF_CONST(1.00000000), COEF_CONST(0.00000000) },
     { COEF_CONST(0.30901712), COEF_CONST(-0.95105648) }
 };
+#endif
 
 complex_t cfft_tab_64[] =
 {
@@ -1102,6 +1104,7 @@
     { COEF_CONST(0.00000001), COEF_CONST(-1.00000000) }
 };
 
+#ifdef ALLOW_SMALL_FRAMELENGTH
 complex_t cfft_tab_60[] =
 {
     { COEF_CONST(1.00000000), COEF_CONST(0.00000000) },
@@ -1165,6 +1168,7 @@
     { COEF_CONST(1.00000000), COEF_CONST(0.00000000) },
     { COEF_CONST(0.30901712), COEF_CONST(-0.95105648) }
 };
+#endif
 
 #ifdef LD_DEC
 
@@ -1428,6 +1432,7 @@
     { COEF_CONST(0.00000001), COEF_CONST(-1.00000000) }
 };
 
+#ifdef ALLOW_SMALL_FRAMELENGTH
 complex_t cfft_tab_240[] =
 {
     { COEF_CONST(1.00000000), COEF_CONST(0.00000000) },
@@ -1671,6 +1676,7 @@
     { COEF_CONST(1.00000000), COEF_CONST(0.00000000) },
     { COEF_CONST(0.30901712), COEF_CONST(-0.95105648) }
 };
+#endif
 
 #endif
 
--- a/libfaad/decoder.c
+++ b/libfaad/decoder.c
@@ -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.77 2003/10/20 15:43:52 menno Exp $
+** $Id: decoder.c,v 1.78 2003/11/02 20:24:03 menno Exp $
 **/
 
 #include "common.h"
@@ -36,7 +36,6 @@
 #include "syntax.h"
 #include "error.h"
 #include "output.h"
-#include "dither.h"
 #ifdef SBR_DEC
 #include "sbr_dec.h"
 #endif
@@ -279,11 +278,6 @@
     if (can_decode_ot(hDecoder->object_type) < 0)
         return -1;
 
-#ifndef FIXED_POINT
-    if (hDecoder->config.outputFormat >= FAAD_FMT_DITHER_LOWEST)
-        Init_Dither(16, (uint8_t)(hDecoder->config.outputFormat - FAAD_FMT_DITHER_LOWEST));
-#endif
-
     return bits;
 }
 
@@ -363,11 +357,6 @@
         hDecoder->frameLength >>= 1;
 #endif
 
-#ifndef FIXED_POINT
-    if (hDecoder->config.outputFormat >= FAAD_FMT_DITHER_LOWEST)
-        Init_Dither(16, (uint8_t)(hDecoder->config.outputFormat - FAAD_FMT_DITHER_LOWEST));
-#endif
-
     return 0;
 }
 
@@ -413,11 +402,6 @@
 
     /* must be done before frameLength is divided by 2 for LD */
     hDecoder->fb = filter_bank_init(hDecoder->frameLength);
-
-#ifndef FIXED_POINT
-    if (hDecoder->config.outputFormat >= FAAD_FMT_DITHER_LOWEST)
-        Init_Dither(16, (uint8_t)(hDecoder->config.outputFormat - FAAD_FMT_DITHER_LOWEST));
-#endif
 
     /* Take care of buffers */
     if (hDecoder->sample_buffer) free(hDecoder->sample_buffer);
--- a/libfaad/decoder.h
+++ b/libfaad/decoder.h
@@ -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.30 2003/10/19 18:11:19 menno Exp $
+** $Id: decoder.h,v 1.32 2003/11/04 21:43:30 menno Exp $
 **/
 
 #ifndef __DECODER_H__
@@ -57,12 +57,6 @@
 #define FAAD_FMT_32BIT  3
 #define FAAD_FMT_FLOAT  4
 #define FAAD_FMT_DOUBLE 5
-#define FAAD_FMT_16BIT_DITHER  6
-#define FAAD_FMT_16BIT_L_SHAPE 7
-#define FAAD_FMT_16BIT_M_SHAPE 8
-#define FAAD_FMT_16BIT_H_SHAPE 9
-
-#define FAAD_FMT_DITHER_LOWEST FAAD_FMT_16BIT_DITHER
 
 #define LC_DEC_CAP            (1<<0)
 #define MAIN_DEC_CAP          (1<<1)
--- a/libfaad/dither.c
+++ /dev/null
@@ -1,130 +1,0 @@
-/* This program is licensed under the GNU Library General Public License, version 2,
- * a copy of which is included with this program (with filename LICENSE.LGPL).
- *
- * (c) 2002 John Edwards
- * mostly lifted from work by Frank Klemm
- * random functions for dithering.
- *
- * last modified:
- * $Id: dither.c,v 1.11 2003/10/19 18:11:19 menno Exp $
- */
-#include "common.h"
-
-#ifndef FIXED_POINT
-
-#include <string.h>
-#include "dither.h"
-#include "common.h"
-
-
-double
-Random_Equi ( double mult )                     // gives a equal distributed random number
-{                                               // between -2^31*mult and +2^31*mult
-	return mult * (int) random_int ();
-}
-
-double
-Random_Triangular ( double mult )               // gives a triangular distributed random number
-{                                               // between -2^32*mult and +2^32*mult
-	return mult * ( (double) (int) random_int () + (double) (int) random_int () );
-}
-
-/*********************************************************************************************************************/
-
-static const float32_t  F44_0 [16 + 32] = {
-	(float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0,
-	(float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0,
-
-	(float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0,
-	(float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0,
-
-	(float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0,
-	(float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0
-};
-
-
-static const float32_t  F44_1 [16 + 32] = {  /* SNR(w) = 4.843163 dB, SNR = -3.192134 dB */
-	(float) 0.85018292704024355931, (float) 0.29089597350995344721, (float)-0.05021866022121039450, (float)-0.23545456294599161833,
-	(float)-0.58362726442227032096, (float)-0.67038978965193036429, (float)-0.38566861572833459221, (float)-0.15218663390367969967,
-	(float)-0.02577543084864530676, (float) 0.14119295297688728127, (float) 0.22398848581628781612, (float) 0.15401727203382084116,
-	(float) 0.05216161232906000929, (float)-0.00282237820999675451, (float)-0.03042794608323867363, (float)-0.03109780942998826024,
-
-	(float) 0.85018292704024355931, (float) 0.29089597350995344721, (float)-0.05021866022121039450, (float)-0.23545456294599161833,
-	(float)-0.58362726442227032096, (float)-0.67038978965193036429, (float)-0.38566861572833459221, (float)-0.15218663390367969967,
-	(float)-0.02577543084864530676, (float) 0.14119295297688728127, (float) 0.22398848581628781612, (float) 0.15401727203382084116,
-	(float) 0.05216161232906000929, (float)-0.00282237820999675451, (float)-0.03042794608323867363, (float)-0.03109780942998826024,
-
-	(float) 0.85018292704024355931, (float) 0.29089597350995344721, (float)-0.05021866022121039450, (float)-0.23545456294599161833,
-	(float)-0.58362726442227032096, (float)-0.67038978965193036429, (float)-0.38566861572833459221, (float)-0.15218663390367969967,
-	(float)-0.02577543084864530676, (float) 0.14119295297688728127, (float) 0.22398848581628781612, (float) 0.15401727203382084116,
-	(float) 0.05216161232906000929, (float)-0.00282237820999675451, (float)-0.03042794608323867363, (float)-0.03109780942998826024,
-};
-
-
-static const float32_t  F44_2 [16 + 32] = {  /* SNR(w) = 10.060213 dB, SNR = -12.766730 dB */
-	(float) 1.78827593892108555290, (float) 0.95508210637394326553, (float)-0.18447626783899924429, (float)-0.44198126506275016437,
-	(float)-0.88404052492547413497, (float)-1.42218907262407452967, (float)-1.02037566838362314995, (float)-0.34861755756425577264,
-	(float)-0.11490230170431934434, (float) 0.12498899339968611803, (float) 0.38065885268563131927, (float) 0.31883491321310506562,
-	(float) 0.10486838686563442765, (float)-0.03105361685110374845, (float)-0.06450524884075370758, (float)-0.02939198261121969816,
-
-	(float) 1.78827593892108555290, (float) 0.95508210637394326553, (float)-0.18447626783899924429, (float)-0.44198126506275016437,
-	(float)-0.88404052492547413497, (float)-1.42218907262407452967, (float)-1.02037566838362314995, (float)-0.34861755756425577264,
-	(float)-0.11490230170431934434, (float) 0.12498899339968611803, (float) 0.38065885268563131927, (float) 0.31883491321310506562,
-	(float) 0.10486838686563442765, (float)-0.03105361685110374845, (float)-0.06450524884075370758, (float)-0.02939198261121969816,
-
-	(float) 1.78827593892108555290, (float) 0.95508210637394326553, (float)-0.18447626783899924429, (float)-0.44198126506275016437,
-	(float)-0.88404052492547413497, (float)-1.42218907262407452967, (float)-1.02037566838362314995, (float)-0.34861755756425577264,
-	(float)-0.11490230170431934434, (float) 0.12498899339968611803, (float) 0.38065885268563131927, (float) 0.31883491321310506562,
-	(float) 0.10486838686563442765, (float)-0.03105361685110374845, (float)-0.06450524884075370758, (float)-0.02939198261121969816,
-};
-
-
-static const float32_t  F44_3 [16 + 32] = {  /* SNR(w) = 15.382598 dB, SNR = -29.402334 dB */
-	(float) 2.89072132015058161445, (float) 2.68932810943698754106, (float) 0.21083359339410251227, (float)-0.98385073324997617515,
-	(float)-1.11047823227097316719, (float)-2.18954076314139673147, (float)-2.36498032881953056225, (float)-0.95484132880101140785,
-	(float)-0.23924057925542965158, (float)-0.13865235703915925642, (float) 0.43587843191057992846, (float) 0.65903257226026665927,
-	(float) 0.24361815372443152787, (float)-0.00235974960154720097, (float) 0.01844166574603346289, (float) 0.01722945988740875099,
-
-	(float) 2.89072132015058161445, (float) 2.68932810943698754106, (float) 0.21083359339410251227, (float)-0.98385073324997617515,
-	(float)-1.11047823227097316719, (float)-2.18954076314139673147, (float)-2.36498032881953056225, (float)-0.95484132880101140785,
-	(float)-0.23924057925542965158, (float)-0.13865235703915925642, (float) 0.43587843191057992846, (float) 0.65903257226026665927,
-	(float) 0.24361815372443152787, (float)-0.00235974960154720097, (float) 0.01844166574603346289, (float) 0.01722945988740875099,
-
-	(float) 2.89072132015058161445, (float) 2.68932810943698754106, (float) 0.21083359339410251227, (float)-0.98385073324997617515,
-	(float)-1.11047823227097316719, (float)-2.18954076314139673147, (float)-2.36498032881953056225, (float)-0.95484132880101140785,
-	(float)-0.23924057925542965158, (float)-0.13865235703915925642, (float) 0.43587843191057992846, (float) 0.65903257226026665927,
-	(float) 0.24361815372443152787, (float)-0.00235974960154720097, (float) 0.01844166574603346289, (float) 0.01722945988740875099
-};
-
-
-double
-scalar16 ( const float32_t* x, const float32_t* y )
-{
-	return x[ 0]*y[ 0] + x[ 1]*y[ 1] + x[ 2]*y[ 2] + x[ 3]*y[ 3]
-	     + x[ 4]*y[ 4] + x[ 5]*y[ 5] + x[ 6]*y[ 6] + x[ 7]*y[ 7]
-	     + x[ 8]*y[ 8] + x[ 9]*y[ 9] + x[10]*y[10] + x[11]*y[11]
-	     + x[12]*y[12] + x[13]*y[13] + x[14]*y[14] + x[15]*y[15];
-}
-
-
-void
-Init_Dither ( uint8_t bits, uint8_t shapingtype )
-{
-	static uint8_t          default_dither [] = { 92, 92, 88, 84, 81, 78, 74, 67,  0,  0 };
-	static const float32_t*              F [] = { F44_0, F44_1, F44_2, F44_3 };
-	uint8_t                 index;
-
-	if (shapingtype > 3) shapingtype = 3;
-	index = bits - 11 - shapingtype;
-	if (index > 9) index = 9;
-
-	memset ( Dither.ErrorHistory , 0, sizeof (Dither.ErrorHistory ) );
-	memset ( Dither.DitherHistory, 0, sizeof (Dither.DitherHistory) );
-
-	Dither.FilterCoeff = F [shapingtype];
-	Dither.Mask   = ((uint64_t)-1) << (32 - bits);
-	Dither.Add    = 0.5     * ((1L << (32 - bits)) - 1);
-	Dither.Dither = (float32_t)0.01*default_dither[index] / (((int64_t)1) << bits);
-}
-
-#endif
--- a/libfaad/dither.h
+++ /dev/null
@@ -1,47 +1,0 @@
-/* This program is licensed under the GNU Library General Public License, version 2,
- * a copy of which is included with this program (with filename LICENSE.LGPL).
- *
- * (c) 2002 John Edwards
- *
- * rand_t header.
- *
- * last modified: $ID:$
- */
-
-#include "common.h"
-
-#ifndef __RAND_T_H
-#define __RAND_T_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif 
-
-#ifndef FIXED_POINT
-
-typedef struct {
-    const float32_t*  FilterCoeff;
-    uint64_t          Mask;
-    double            Add;
-    float32_t         Dither;
-    float32_t         ErrorHistory     [2] [16];       // max. 2 channels, 16th order Noise shaping
-    float32_t         DitherHistory    [2] [16];
-    int32_t           LastRandomNumber [2];
-} dither_t;
-
-extern dither_t            Dither;
-extern double              doubletmp;
-//static const uint8_t       Parity [256];
-uint32_t                   random_int ( void );
-extern double              scalar16 ( const float32_t* x, const float32_t* y );
-extern double              Random_Equi ( double mult );
-extern double              Random_Triangular ( double mult );
-void                       Init_Dither ( uint8_t bits, uint8_t shapingtype );
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif 
-
-#endif
--- a/libfaad/filtbank.c
+++ b/libfaad/filtbank.c
@@ -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.29 2003/10/19 18:11:19 menno Exp $
+** $Id: filtbank.c,v 1.31 2003/11/04 21:43:30 menno Exp $
 **/
 
 #include "common.h"
@@ -62,8 +62,10 @@
     fb->mdct1024 = faad_mdct_init(2*frame_len_ld);
 #endif
 
+#ifdef ALLOW_SMALL_FRAMELENGTH
     if (frame_len == 1024)
     {
+#endif
         fb->long_window[0]  = sine_long_1024;
         fb->short_window[0] = sine_short_128;
         fb->long_window[1]  = kbd_long_1024;
@@ -72,6 +74,7 @@
         fb->ld_window[0] = sine_mid_512;
         fb->ld_window[1] = ld_mid_512;
 #endif
+#ifdef ALLOW_SMALL_FRAMELENGTH
     } else /* (frame_len == 960) */ {
         fb->long_window[0]  = sine_long_960;
         fb->short_window[0] = sine_short_120;
@@ -82,6 +85,7 @@
         fb->ld_window[1] = ld_mid_480;
 #endif
     }
+#endif
 
     return fb;
 }
--- a/libfaad/kbd_win.h
+++ b/libfaad/kbd_win.h
@@ -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.8 2003/10/19 18:11:20 menno Exp $
+** $Id: kbd_win.h,v 1.10 2003/11/04 21:43:30 menno Exp $
 **/
 
 #ifndef __KBD_WIN_H__
@@ -1065,6 +1065,7 @@
     COEF_CONST(0.99999995720387)
 };
 
+#ifdef ALLOW_SMALL_FRAMELENGTH
 real_t kbd_long_960[] = {
     COEF_CONST(0.0003021562530949),
     COEF_CONST(0.0004452267024786),
@@ -2027,6 +2028,7 @@
     COEF_CONST(0.9999999008865869),
     COEF_CONST(0.9999999543507984)
 };
+#endif
 
 real_t kbd_short_128[] =
 {
@@ -2160,6 +2162,7 @@
     COEF_CONST(0.99999999904096815)
 };
 
+#ifdef ALLOW_SMALL_FRAMELENGTH
 real_t kbd_short_120[] =
 {
     COEF_CONST(0.0000452320086910),
@@ -2283,6 +2286,7 @@
     COEF_CONST(0.9999999918774242),
     COEF_CONST(0.9999999989770326)
 };
+#endif
 
 #ifdef __cplusplus
 }
--- a/libfaad/libfaad.dsp
+++ b/libfaad/libfaad.dsp
@@ -40,8 +40,8 @@
 # PROP Output_Dir "Release"
 # PROP Intermediate_Dir "Release"
 # PROP Target_Dir ""
-F90=df.exe
 MTL=midl.exe
+F90=df.exe
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
 # ADD CPP /nologo /G6 /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /YX /FD /c
 # ADD BASE RSC /l 0x413 /d "NDEBUG"
@@ -65,8 +65,8 @@
 # PROP Output_Dir "Debug"
 # PROP Intermediate_Dir "Debug"
 # PROP Target_Dir ""
-F90=df.exe
 MTL=midl.exe
+F90=df.exe
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
 # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
 # ADD BASE RSC /l 0x413 /d "_DEBUG"
@@ -102,10 +102,6 @@
 # Begin Source File
 
 SOURCE=.\decoder.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\dither.c
 # End Source File
 # Begin Source File
 
--- a/libfaad/mdct.c
+++ b/libfaad/mdct.c
@@ -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.30 2003/10/19 18:11:20 menno Exp $
+** $Id: mdct.c,v 1.32 2003/11/04 21:43:30 menno Exp $
 **/
 
 /*
@@ -280,7 +280,11 @@
     uint16_t N4 = N >> 2;
     uint16_t N8 = N >> 3;
 
+#ifndef FIXED_POINT
 	real_t scale = REAL_CONST(N);
+#else
+	real_t scale = REAL_CONST(4.0/N);
+#endif
 
     /* pre-FFT complex multiplication */
     for (k = 0; k < N8; k++)
@@ -292,11 +296,17 @@
         RE(Z1[k]) = -MUL_R_C(RE(x), RE(sincos[k])) - MUL_R_C(IM(x), IM(sincos[k]));
         IM(Z1[k]) = -MUL_R_C(IM(x), RE(sincos[k])) + MUL_R_C(RE(x), IM(sincos[k]));
 
+        RE(Z1[k]) = MUL(RE(Z1[k]), scale);
+        IM(Z1[k]) = MUL(IM(Z1[k]), scale);
+
         RE(x) =  X_in[N2 - 1 - n] - X_in[        n];
         IM(x) =  X_in[N2 +     n] + X_in[N - 1 - n];
 
         RE(Z1[k + N8]) = -MUL_R_C(RE(x), RE(sincos[k + N8])) - MUL_R_C(IM(x), IM(sincos[k + N8]));
         IM(Z1[k + N8]) = -MUL_R_C(IM(x), RE(sincos[k + N8])) + MUL_R_C(RE(x), IM(sincos[k + N8]));
+
+        RE(Z1[k + N8]) = MUL(RE(Z1[k + N8]), scale);
+        IM(Z1[k + N8]) = MUL(IM(Z1[k + N8]), scale);
     }
 
     /* complex FFT, any non-scaling FFT can be used here  */
@@ -306,8 +316,8 @@
     for (k = 0; k < N4; k++)
     {
         uint16_t n = k << 1;
-        RE(x) = MUL(MUL_R_C(RE(Z1[k]), RE(sincos[k])) + MUL_R_C(IM(Z1[k]), IM(sincos[k])), scale);
-        IM(x) = MUL(MUL_R_C(IM(Z1[k]), RE(sincos[k])) - MUL_R_C(RE(Z1[k]), IM(sincos[k])), scale);
+        RE(x) = MUL_R_C(RE(Z1[k]), RE(sincos[k])) + MUL_R_C(IM(Z1[k]), IM(sincos[k]));
+        IM(x) = MUL_R_C(IM(Z1[k]), RE(sincos[k])) - MUL_R_C(RE(Z1[k]), IM(sincos[k]));
 
         X_out[         n] =  RE(x);
         X_out[N2 - 1 - n] = -IM(x);
--- a/libfaad/output.c
+++ b/libfaad/output.c
@@ -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.c,v 1.23 2003/10/19 18:11:20 menno Exp $
+** $Id: output.c,v 1.24 2003/11/02 20:24:04 menno Exp $
 **/
 
 #include "common.h"
@@ -33,7 +33,6 @@
 
 #ifndef FIXED_POINT
 
-#include "dither.h"
 
 
 #define ftol(A,B) {tmp = *(int32_t*) & A - 0x4B7F8000; \
@@ -43,13 +42,8 @@
 
 #define ROUND32(x) ROUND(x)
 
-#define ROUND64(x) (doubletmp = (x) + Dither.Add + (int64_t)0x001FFFFD80000000L, *(int64_t*)(&doubletmp) - (int64_t)0x433FFFFD80000000L)
-
 #define FLOAT_SCALE (1.0f/(1<<15))
 
-dither_t Dither;
-double doubletmp;
-
 #define DM_MUL ((real_t)1.0/((real_t)1.0+(real_t)sqrt(2.0)))
 
 static INLINE real_t get_sample(real_t **input, uint8_t channel, uint16_t sample,
@@ -102,42 +96,6 @@
                 ftol(ftemp, short_sample_buffer[(i*channels)+ch]);
             }
             break;
-        case FAAD_FMT_16BIT_DITHER:
-            for(i = 0; i < frame_len; i++, j++)
-            {
-                //real_t inp = input[internal_channel][i];
-                real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel);
-                double Sum = inp * 65535.f;
-                int64_t val;
-                if(j > 31)
-                   j = 0;
-                val = dither_output(1, 0, j, Sum, ch) / 65536;
-                if (val > (1<<15)-1)
-                    val = (1<<15)-1;
-                else if (val < -(1<<15))
-                    val = -(1<<15);
-                short_sample_buffer[(i*channels)+ch] = (int16_t)val;
-            }
-            break;
-        case FAAD_FMT_16BIT_L_SHAPE:
-        case FAAD_FMT_16BIT_M_SHAPE:
-        case FAAD_FMT_16BIT_H_SHAPE:
-            for(i = 0; i < frame_len; i++, j++)
-            {
-                //real_t inp = input[internal_channel][i];
-                real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel);
-                double Sum = inp * 65535.f;
-                int64_t val;
-                if(j > 31)
-                   j = 0;
-                val = dither_output(1, 1, j, Sum, ch) / 65536;
-                if (val > (1<<15)-1)
-                    val = (1<<15)-1;
-                else if (val < -(1<<15))
-                    val = -(1<<15);
-                short_sample_buffer[(i*channels)+ch] = (int16_t)val;
-            }
-            break;
         case FAAD_FMT_24BIT:
             for(i = 0; i < frame_len; i++)
             {
@@ -182,34 +140,6 @@
     }
 
     return sample_buffer;
-}
-
-
-/* Dither output */
-static int64_t dither_output(uint8_t dithering, uint8_t shapingtype, uint16_t i, double Sum, uint8_t k)
-{
-    double Sum2;
-    int64_t val;
-    if(dithering)
-    {
-        if(!shapingtype)
-        {
-            double tmp = Random_Equi(Dither.Dither);
-            Sum2 = tmp - (double)Dither.LastRandomNumber[k];
-            Dither.LastRandomNumber[k] = (int32_t)tmp;
-            Sum2 = Sum += Sum2;
-            val = ROUND64(Sum2)&Dither.Mask;
-        } else {
-            Sum2 = Random_Triangular(Dither.Dither) - scalar16(Dither.DitherHistory[k], Dither.FilterCoeff + i);
-            Sum += Dither.DitherHistory[k][(-1-i)&15] = (float32_t)Sum2;
-            Sum2 = Sum + scalar16(Dither.ErrorHistory[k], Dither.FilterCoeff + i );
-            val = ROUND64(Sum2)&Dither.Mask;
-            Dither.ErrorHistory[k][(-1-i)&15] = (float)(Sum - val);
-        }
-        return val;
-    }
-    else
-        return ROUND64 (Sum);
 }
 
 #else
--- a/libfaad/sbr_hfadj.c
+++ b/libfaad/sbr_hfadj.c
@@ -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.6 2003/10/20 13:57:32 menno Exp $
+** $Id: sbr_hfadj.c,v 1.7 2003/11/02 20:24:05 menno Exp $
 **/
 
 /* High Frequency adjustment */
@@ -263,7 +263,6 @@
 }
 
 #define EPS (1e-12)
-
 #define ONE (1)
 
 
@@ -472,6 +471,7 @@
                 acc = 0;
             else
                 acc = E_total / (acc + EPS);
+
             for(m = sbr->f_group[l][(k<<1)]; m < sbr->f_group[l][(k<<1) + 1]; m++)
             {
                 adj->G_lim_boost[l][m-sbr->kx] = MUL(acc, adj->G_lim_boost[l][m-sbr->kx]);
--- a/libfaad/sbr_hfgen.c
+++ b/libfaad/sbr_hfgen.c
@@ -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.8 2003/10/20 13:57:32 menno Exp $
+** $Id: sbr_hfgen.c,v 1.9 2003/11/02 20:24:05 menno Exp $
 **/
 
 /* High Frequency generation */
@@ -180,9 +180,9 @@
                              const qmf_t buffer[MAX_NTSRHFG][32],
                              uint8_t bd, uint8_t len)
 {
+    real_t r01 = 0, r02 = 0, r11 = 0;
     int8_t j;
     uint8_t offset;
-    real_t r01, r11;
     const real_t rel = 1 / (1 + 1e-6f);
 
 #ifdef DRM
@@ -194,21 +194,21 @@
         offset = sbr->tHFAdj;
     }
 
-    memset(ac, 0, sizeof(acorr_coef));
-
-    r01 = QMF_RE(buffer[offset-1][bd]) * QMF_RE(buffer[offset-2][bd]);
-    r11 = QMF_RE(buffer[offset-2][bd]) * QMF_RE(buffer[offset-2][bd]);
-
     for (j = offset; j < len + offset; j++)
     {
-        RE(ac->r12) += r01;
-        r01 = QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-1][bd]);
-        RE(ac->r01) += r01;
+        RE(ac->r01) += QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-1][bd]);
         RE(ac->r02) += QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-2][bd]);
-        RE(ac->r22) += r11;
-        r11 = QMF_RE(buffer[j-1][bd]) * QMF_RE(buffer[j-1][bd]);
-        RE(ac->r11) += r11;
+        RE(ac->r11) += QMF_RE(buffer[j-1][bd]) * QMF_RE(buffer[j-1][bd]);
     }
+    RE(ac->r12) = r01 -
+        QMF_RE(buffer[len+offset-1][bd]) * QMF_RE(buffer[len+offset-2][bd]) +
+        QMF_RE(buffer[offset-1][bd]) * QMF_RE(buffer[offset-2][bd]);
+    RE(ac->r22) = r11 -
+        QMF_RE(buffer[len+offset-2][bd]) * QMF_RE(buffer[len+offset-2][bd]) +
+        QMF_RE(buffer[offset-2][bd]) * QMF_RE(buffer[offset-2][bd]);
+    RE(ac->r01) = r01;
+    RE(ac->r02) = r02;
+    RE(ac->r11) = r11;
 
     ac->det = MUL(RE(ac->r11), RE(ac->r22)) - MUL_R_C(MUL(RE(ac->r12), RE(ac->r12)), rel);
 }
@@ -216,10 +216,10 @@
 static void auto_correlation(sbr_info *sbr, acorr_coef *ac, const qmf_t buffer[MAX_NTSRHFG][32],
                              uint8_t bd, uint8_t len)
 {
+    real_t r01r = 0, r01i = 0, r02r = 0, r02i = 0, r11r = 0;
+    const real_t rel = 1 / (1 + 1e-6f);
     int8_t j;
     uint8_t offset;
-    real_t r01, i01, r11;
-    const real_t rel = 1 / (1 + 1e-6f);
 
 #ifdef DRM
     if (sbr->Is_DRM_SBR)
@@ -230,39 +230,41 @@
         offset = sbr->tHFAdj;
     }
 
-    memset(ac, 0, sizeof(acorr_coef));
-
-    r01 = QMF_RE(buffer[offset-1][bd]) * QMF_RE(buffer[offset-2][bd]) +
-        QMF_IM(buffer[offset-1][bd]) * QMF_IM(buffer[offset-2][bd]);
-    i01 = QMF_IM(buffer[offset-1][bd]) * QMF_RE(buffer[offset-2][bd]) -
-        QMF_RE(buffer[offset-1][bd]) * QMF_IM(buffer[offset-2][bd]);
-    r11 = QMF_RE(buffer[offset-2][bd]) * QMF_RE(buffer[offset-2][bd]) +
-        QMF_IM(buffer[offset-2][bd]) * QMF_IM(buffer[offset-2][bd]);
-
     for (j = offset; j < len + offset; j++)
     {
-        RE(ac->r12) += r01;
-        IM(ac->r12) += i01;
-        r01 = QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-1][bd]) +
+        r01r += QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-1][bd]) +
             QMF_IM(buffer[j][bd]) * QMF_IM(buffer[j-1][bd]);
-        RE(ac->r01) += r01;
-        i01 = QMF_IM(buffer[j][bd]) * QMF_RE(buffer[j-1][bd]) -
+        r01i += QMF_IM(buffer[j][bd]) * QMF_RE(buffer[j-1][bd]) -
             QMF_RE(buffer[j][bd]) * QMF_IM(buffer[j-1][bd]);
-        IM(ac->r01) += i01;
-        RE(ac->r02) += QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-2][bd]) +
+        r02r += QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-2][bd]) +
             QMF_IM(buffer[j][bd]) * QMF_IM(buffer[j-2][bd]);
-        IM(ac->r02) += QMF_IM(buffer[j][bd]) * QMF_RE(buffer[j-2][bd]) -
+        r02i += QMF_IM(buffer[j][bd]) * QMF_RE(buffer[j-2][bd]) -
             QMF_RE(buffer[j][bd]) * QMF_IM(buffer[j-2][bd]);
-        RE(ac->r22) += r11;
-        r11 = QMF_RE(buffer[j-1][bd]) * QMF_RE(buffer[j-1][bd]) +
+        r11r += QMF_RE(buffer[j-1][bd]) * QMF_RE(buffer[j-1][bd]) +
             QMF_IM(buffer[j-1][bd]) * QMF_IM(buffer[j-1][bd]);
-        RE(ac->r11) += r11;
     }
 
+    RE(ac->r01) = r01r;
+    IM(ac->r01) = r01i;
+    RE(ac->r02) = r02r;
+    IM(ac->r02) = r02i;
+    RE(ac->r11) = r11r;
+
+    RE(ac->r12) = r01r -
+        (QMF_RE(buffer[len+offset-1][bd]) * QMF_RE(buffer[len+offset-2][bd]) + QMF_IM(buffer[len+offset-1][bd]) * QMF_IM(buffer[len+offset-2][bd])) +
+        (QMF_RE(buffer[offset-1][bd]) * QMF_RE(buffer[offset-2][bd]) + QMF_IM(buffer[offset-1][bd]) * QMF_IM(buffer[offset-2][bd]));
+    IM(ac->r12) = r01i -
+        (QMF_IM(buffer[len+offset-1][bd]) * QMF_RE(buffer[len+offset-2][bd]) - QMF_RE(buffer[len+offset-1][bd]) * QMF_IM(buffer[len+offset-2][bd])) +
+        (QMF_IM(buffer[offset-1][bd]) * QMF_RE(buffer[offset-2][bd]) - QMF_RE(buffer[offset-1][bd]) * QMF_IM(buffer[offset-2][bd]));
+    RE(ac->r22) = r11r -
+        (QMF_RE(buffer[len+offset-2][bd]) * QMF_RE(buffer[len+offset-2][bd]) + QMF_IM(buffer[len+offset-2][bd]) * QMF_IM(buffer[len+offset-2][bd])) +
+        (QMF_RE(buffer[offset-2][bd]) * QMF_RE(buffer[offset-2][bd]) + QMF_IM(buffer[offset-2][bd]) * QMF_IM(buffer[offset-2][bd]));
+
     ac->det = RE(ac->r11) * RE(ac->r22) - rel * (RE(ac->r12) * RE(ac->r12) + IM(ac->r12) * IM(ac->r12));
 }
 #endif
 
+/* calculate linear prediction coefficients using the covariance method */
 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
--- a/libfaad/sbr_qmf.c
+++ b/libfaad/sbr_qmf.c
@@ -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.15 2003/10/20 13:57:32 menno Exp $
+** $Id: sbr_qmf.c,v 1.16 2003/11/02 20:24:05 menno Exp $
 **/
 
 #include "common.h"
@@ -62,7 +62,6 @@
 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)
 {
-    uint8_t l;
     real_t u[64];
 #ifndef SBR_LOW_POWER
     real_t x[64], y[64];
@@ -69,7 +68,8 @@
 #else
     real_t y[32];
 #endif
-    const real_t *inptr = input;
+    uint16_t in = 0;
+    uint8_t l;
 
     /* qmf subsample l */
     for (l = 0; l < sbr->numTimeSlotsRate; l++)
@@ -83,9 +83,9 @@
         for (n = 32 - 1; n >= 0; n--)
         {
 #ifdef FIXED_POINT
-            qmfa->x[n] = (*inptr++) >> 5;
+            qmfa->x[n] = (input[in++]) >> 5;
 #else
-            qmfa->x[n] = *inptr++;
+            qmfa->x[n] = input[in++];
 #endif
         }
 
@@ -123,18 +123,7 @@
             }
         }
 #else
-#if 0
         x[0] = u[0];
-        x[63] = u[32];
-        for (n = 2; n < 64; n += 2)
-        {
-            x[n-1] = u[(n>>1)];
-            x[n] = -u[64-(n>>1)];
-        }
-
-        DCT4_64(y, x);
-#else
-        x[0] = u[0];
         for (n = 0; n < 31; n++)
         {
             x[2*n+1] = u[n+1] + u[63-n];
@@ -143,7 +132,6 @@
         x[63] = u[32];
 
         DCT4_64_kernel(y, x);
-#endif
 
         for (n = 0; n < 32; n++)
         {
@@ -167,7 +155,6 @@
 
 qmfs_info *qmfs_init(uint8_t channels)
 {
-    int size = 0;
     qmfs_info *qmfs = (qmfs_info*)malloc(sizeof(qmfs_info));
 
     qmfs->v[0] = (real_t*)malloc(channels * 10 * sizeof(real_t));
@@ -196,10 +183,9 @@
 void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t X[MAX_NTSRHFG][64],
                           real_t *output)
 {
-    uint8_t l;
-    int16_t n, k;
     real_t x[64];
-    real_t *outptr = output;
+    int16_t n, k, out = 0;
+    uint8_t l;
 
 
     /* qmf subsample l */
@@ -243,7 +229,7 @@
         /* calculate 64 output samples and window */
         for (k = 0; k < 64; k++)
         {
-            *outptr++ = MUL_R_C(v0[k], qmf_c[k]) +
+            output[out++] = MUL_R_C(v0[k], qmf_c[k]) +
                 MUL_R_C(v0[64 + k], qmf_c[64 + k]) +
                 MUL_R_C(v0[128 + k], qmf_c[128 + k]) +
                 MUL_R_C(v0[192 + k], qmf_c[192 + k]) +
@@ -261,9 +247,8 @@
                           real_t *output)
 {
     real_t x1[64], x2[64];
-    real_t *outptr = output;
     real_t scale = 1.f/64.f;
-    int16_t n, k;
+    int16_t n, k, out = 0;
     uint8_t l;
 
 
@@ -308,7 +293,7 @@
         /* calculate 64 output samples and window */
         for (k = 0; k < 64; k++)
         {
-            *outptr++ = MUL_R_C(v0[k], qmf_c[k]) +
+            output[out++] = MUL_R_C(v0[k], qmf_c[k]) +
                 MUL_R_C(v0[64 + k], qmf_c[64 + k]) +
                 MUL_R_C(v0[128 + k], qmf_c[128 + k]) +
                 MUL_R_C(v0[192 + k], qmf_c[192 + k]) +
--- a/libfaad/sine_win.h
+++ b/libfaad/sine_win.h
@@ -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.5 2003/10/19 18:11:20 menno Exp $
+** $Id: sine_win.h,v 1.7 2003/11/04 21:43:30 menno Exp $
 **/
 
 #ifndef __SINE_WIN_H__
@@ -1065,6 +1065,7 @@
     COEF_CONST(0.9999997059)
 };
 
+#ifdef ALLOW_SMALL_FRAMELENGTH
 real_t sine_long_960[] =
 {
     COEF_CONST(0.0008181230),
@@ -2028,6 +2029,7 @@
     COEF_CONST(0.9999969881),
     COEF_CONST(0.9999996654)
 };
+#endif
 
 real_t sine_short_128[] =
 {
@@ -2161,6 +2163,7 @@
     COEF_CONST(0.9999811755)
 };
 
+#ifdef ALLOW_SMALL_FRAMELENGTH
 real_t sine_short_120[] =
 {
     COEF_CONST(0.0065449381),
@@ -2284,6 +2287,7 @@
     COEF_CONST(0.9998072413),
     COEF_CONST(0.9999785819)
 };
+#endif
 
 #ifdef LD_DEC
 real_t sine_mid_512[] =
@@ -2802,6 +2806,7 @@
     COEF_CONST(0.9999988235)
 };
 
+#ifdef ALLOW_SMALL_FRAMELENGTH
 real_t sine_mid_480[] =
 {
     COEF_CONST(0.0016362455),
@@ -3285,6 +3290,7 @@
     COEF_CONST(0.9999879524),
     COEF_CONST(0.9999986614)
 };
+#endif
 
 real_t ld_mid_512[] =
 {
@@ -3802,6 +3808,7 @@
     COEF_CONST(1.0000000000)
 };
 
+#ifdef ALLOW_SMALL_FRAMELENGTH
 real_t ld_mid_480[] =
 {
     COEF_CONST(0.0000000000),
@@ -4285,6 +4292,7 @@
     COEF_CONST(1.0000000000),
     COEF_CONST(1.0000000000)
 };
+#endif
 #endif
 
 #ifdef __cplusplus
--- a/libfaad/syntax.c
+++ b/libfaad/syntax.c
@@ -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.58 2003/10/19 18:11:20 menno Exp $
+** $Id: syntax.c,v 1.59 2003/11/02 20:24:05 menno Exp $
 **/
 
 /*
@@ -60,6 +60,10 @@
     /* 1024 or 960 */
     mp4ASC->frameLengthFlag = faad_get1bit(ld
         DEBUGVAR(1,138,"GASpecificConfig(): FrameLengthFlag"));
+#ifndef ALLOW_SMALL_FRAMELENGTH
+    if (mp4ASC->frameLengthFlag == 1)
+        return -3;
+#endif
 
     mp4ASC->dependsOnCoreCoder = faad_get1bit(ld
         DEBUGVAR(1,139,"GASpecificConfig(): DependsOnCoreCoder"));
--- a/plugins/in_mp4/in_mp4.c
+++ b/plugins/in_mp4/in_mp4.c
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: in_mp4.c,v 1.43 2003/10/17 17:11:38 ca5e Exp $
+** $Id: in_mp4.c,v 1.44 2003/11/02 20:24:05 menno Exp $
 **/
 
 //#define DEBUG_OUTPUT
@@ -60,7 +60,7 @@
     IDC_32BITS,
     0,
     0,
-    IDC_16BITS_DITHERED
+    /*IDC_16BITS_DITHERED*/ IDC_16BITS /* temp hack */
 };
 static int res_table[] = {
     16,
--- a/plugins/in_mp4/in_mp4.rc
+++ b/plugins/in_mp4/in_mp4.rc
@@ -104,7 +104,7 @@
     CONTROL         "16 bits",IDC_16BITS,"Button",BS_AUTORADIOBUTTON,77,18,
                     37,10
     CONTROL         "16 bits dithered",IDC_16BITS_DITHERED,"Button",
-                    BS_AUTORADIOBUTTON,77,29,64,10
+                    BS_AUTORADIOBUTTON | WS_DISABLED,77,29,64,10
     CONTROL         "24 bits",IDC_24BITS,"Button",BS_AUTORADIOBUTTON,77,40,
                     37,10
     CONTROL         "32 bits",IDC_32BITS,"Button",BS_AUTORADIOBUTTON,77,51,