shithub: aacdec

Download patch

ref: 4208c44ee74d94a434da96e364a9dd028acfbbec
parent: 5a3586372506a3bf38f16985f00a5a44aa11c43c
author: menno <menno>
date: Tue Aug 27 06:24:57 EDT 2002

Fixed point decoding working correctly now

--- a/include/faad.h
+++ b/include/faad.h
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: faad.h,v 1.13 2002/08/26 19:08:39 menno Exp $
+** $Id: faad.h,v 1.14 2002/08/27 10:24:54 menno Exp $
 **/
 
 #ifndef __AACDEC_H__
@@ -80,7 +80,7 @@
     unsigned char error;
 } faacDecFrameInfo;
 
-unsigned char* FAADAPI faacDecGetErrorMessage(unsigned char errcode);
+char* FAADAPI faacDecGetErrorMessage(unsigned char errcode);
 
 faacDecHandle FAADAPI faacDecOpen();
 
--- a/libfaad/cfft.c
+++ b/libfaad/cfft.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: cfft.c,v 1.5 2002/08/26 18:41:47 menno Exp $
+** $Id: cfft.c,v 1.6 2002/08/27 10:24:54 menno Exp $
 **/
 
 /*
@@ -65,8 +65,8 @@
                 tr2 = cc[ac] - cc[ac+ido];
                 ch[ah+1] = cc[ac+1] + cc[ac+1+ido];
                 ti2 = cc[ac+1] - cc[ac+1+ido];
-                ch[ah+l1*ido+1] = MUL_R_C(ti2,wa1[i]) + isign*MUL_R_C(tr2,wa1[i+1]);
-                ch[ah+l1*ido] = MUL_R_C(tr2,wa1[i]) - isign*MUL_R_C(ti2,wa1[i+1]);
+                ch[ah+l1*ido+1] = MUL_R_C(ti2,wa1[i]) + MUL_R_C(tr2,wa1[i+1])*isign;
+                ch[ah+l1*ido] = MUL_R_C(tr2,wa1[i]) - MUL_R_C(ti2,wa1[i+1])*isign;
             }
         }
     }
@@ -95,8 +95,8 @@
             ci2 = cc[ac-ido+1] + MUL_R_C(ti2,taur);
             ch[ah+1] = cc[ac-ido+1] + ti2;
 
-            cr3 = isign * MUL_R_C((cc[ac] - cc[ac+ido]), taui);
-            ci3 = isign * MUL_R_C((cc[ac+1] - cc[ac+ido+1]), taui);
+            cr3 = MUL_R_C((cc[ac] - cc[ac+ido]), taui)*isign;
+            ci3 = MUL_R_C((cc[ac+1] - cc[ac+ido+1]), taui)*isign;
             ch[ah+l1*ido] = cr2 - ci3;
             ch[ah+2*l1*ido] = cr2 + ci3;
             ch[ah+l1*ido+1] = ci2 + cr3;
@@ -115,16 +115,16 @@
                 ti2 = cc[ac+1] + cc[ac+ido+1];
                 ci2 = cc[ac-ido+1] + MUL_R_C(ti2,taur);
                 ch[ah+1] = cc[ac-ido+1] + ti2;
-                cr3 = isign * MUL_R_C((cc[ac] - cc[ac+ido]), taui);
-                ci3 = isign * MUL_R_C((cc[ac+1] - cc[ac+ido+1]), taui);
+                cr3 = MUL_R_C((cc[ac] - cc[ac+ido]), taui)*isign;
+                ci3 = MUL_R_C((cc[ac+1] - cc[ac+ido+1]), taui)*isign;
                 dr2 = cr2 - ci3;
                 dr3 = cr2 + ci3;
                 di2 = ci2 + cr3;
                 di3 = ci2 - cr3;
-                ch[ah+l1*ido+1] = MUL_R_C(di2,wa1[i]) + isign*MUL_R_C(dr2,wa1[i+1]);
-                ch[ah+l1*ido] = MUL_R_C(dr2,wa1[i]) - isign*MUL_R_C(di2,wa1[i+1]);
-                ch[ah+2*l1*ido+1] = MUL_R_C(di3,wa2[i]) + isign*MUL_R_C(dr3,wa2[i+1]);
-                ch[ah+2*l1*ido] = MUL_R_C(dr3,wa2[i]) - isign*MUL_R_C(di3,wa2[i+1]);
+                ch[ah+l1*ido+1] = MUL_R_C(di2,wa1[i]) + MUL_R_C(dr2,wa1[i+1])*isign;
+                ch[ah+l1*ido] = MUL_R_C(dr2,wa1[i]) - MUL_R_C(di2,wa1[i+1])*isign;
+                ch[ah+2*l1*ido+1] = MUL_R_C(di3,wa2[i]) + MUL_R_C(dr3,wa2[i+1])*isign;
+                ch[ah+2*l1*ido] = MUL_R_C(dr3,wa2[i]) - MUL_R_C(di3,wa2[i+1])*isign;
             }
         }
     }
@@ -156,10 +156,10 @@
             ch[ah+2*l1*ido] = tr2 - tr3;
             ch[ah+1] = ti2 + ti3;
             ch[ah+2*l1*ido+1] = ti2 - ti3;
-            ch[ah+l1*ido] = tr1 + isign*tr4;
-            ch[ah+3*l1*ido] = tr1 - isign*tr4;
-            ch[ah+l1*ido+1] = ti1 + isign*ti4;
-            ch[ah+3*l1*ido+1] = ti1 - isign*ti4;
+            ch[ah+l1*ido] = tr1 + tr4*isign;
+            ch[ah+3*l1*ido] = tr1 - tr4*isign;
+            ch[ah+l1*ido+1] = ti1 + ti4*isign;
+            ch[ah+3*l1*ido+1] = ti1 - ti4*isign;
         }
     } else {
         for (k = 0; k < l1; k++)
@@ -180,16 +180,16 @@
                 cr3 = tr2 - tr3;
                 ch[ah+1] = ti2 + ti3;
                 ci3 = ti2 - ti3;
-                cr2 = tr1 + isign*tr4;
-                cr4 = tr1 - isign*tr4;
-                ci2 = ti1 + isign*ti4;
-                ci4 = ti1 - isign*ti4;
-                ch[ah+l1*ido] = MUL_R_C(cr2,wa1[i]) - isign*MUL_R_C(ci2,wa1[i+1]);
-                ch[ah+l1*ido+1] = MUL_R_C(ci2,wa1[i]) + isign*MUL_R_C(cr2,wa1[i+1]);
-                ch[ah+2*l1*ido] = MUL_R_C(cr3,wa2[i]) - isign*MUL_R_C(ci3,wa2[i+1]);
-                ch[ah+2*l1*ido+1] = MUL_R_C(ci3,wa2[i]) + isign*MUL_R_C(cr3,wa2[i+1]);
-                ch[ah+3*l1*ido] = MUL_R_C(cr4,wa3[i]) - isign*MUL_R_C(ci4,wa3[i+1]);
-                ch[ah+3*l1*ido+1] = MUL_R_C(ci4,wa3[i]) + isign*MUL_R_C(cr4,wa3[i+1]);
+                cr2 = tr1 + tr4*isign;
+                cr4 = tr1 - tr4*isign;
+                ci2 = ti1 + ti4*isign;
+                ci4 = ti1 - ti4*isign;
+                ch[ah+l1*ido] = MUL_R_C(cr2,wa1[i]) - MUL_R_C(ci2,wa1[i+1])*isign;
+                ch[ah+l1*ido+1] = MUL_R_C(ci2,wa1[i]) + MUL_R_C(cr2,wa1[i+1])*isign;
+                ch[ah+2*l1*ido] = MUL_R_C(cr3,wa2[i]) - MUL_R_C(ci3,wa2[i+1])*isign;
+                ch[ah+2*l1*ido+1] = MUL_R_C(ci3,wa2[i]) + MUL_R_C(cr3,wa2[i+1])*isign;
+                ch[ah+3*l1*ido] = MUL_R_C(cr4,wa3[i]) - MUL_R_C(ci4,wa3[i+1])*isign;
+                ch[ah+3*l1*ido+1] = MUL_R_C(ci4,wa3[i]) + MUL_R_C(cr4,wa3[i+1])*isign;
             }
         }
     }
@@ -228,10 +228,10 @@
             ci2 = cc[ac-ido] + MUL_R_C(ti2,tr11) + MUL_R_C(ti3,tr12);
             cr3 = cc[ac-ido-1] + MUL_R_C(tr2,tr12) + MUL_R_C(tr3,tr11);
             ci3 = cc[ac-ido] + MUL_R_C(ti2,tr12) + MUL_R_C(ti3,tr11);
-            cr5 = isign * (MUL_R_C(tr5,ti11) + MUL_R_C(tr4,ti12));
-            ci5 = isign * (MUL_R_C(ti5,ti11) + MUL_R_C(ti4,ti12));
-            cr4 = isign * (MUL_R_C(tr5,ti12) - MUL_R_C(tr4,ti11));
-            ci4 = isign * (MUL_R_C(ti5,ti12) - MUL_R_C(ti4,ti11));
+            cr5 = (MUL_R_C(tr5,ti11)*isign + MUL_R_C(tr4,ti12));
+            ci5 = (MUL_R_C(ti5,ti11)*isign + MUL_R_C(ti4,ti12));
+            cr4 = (MUL_R_C(tr5,ti12)*isign - MUL_R_C(tr4,ti11));
+            ci4 = (MUL_R_C(ti5,ti12)*isign - MUL_R_C(ti4,ti11));
             ch[ah+l1*ido] = cr2 - ci5;
             ch[ah+4*l1*ido] = cr2 + ci5;
             ch[ah+l1*ido+1] = ci2 + cr5;
@@ -262,10 +262,10 @@
                 ci2 = cc[ac-ido] + MUL_R_C(ti2,tr11) + MUL_R_C(ti3,tr12);
                 cr3 = cc[ac-ido-1] + MUL_R_C(tr2,tr12) + MUL_R_C(tr3,tr11);
                 ci3 = cc[ac-ido] + MUL_R_C(ti2,tr12) + MUL_R_C(ti3,tr11);
-                cr5 = isign * (MUL_R_C(tr5,ti11) + MUL_R_C(tr4,ti12));
-                ci5 = isign * (MUL_R_C(ti5,ti11) + MUL_R_C(ti4,ti12));
-                cr4 = isign * (MUL_R_C(tr5,ti12) - MUL_R_C(tr4,ti11));
-                ci4 = isign * (MUL_R_C(ti5,ti12) - MUL_R_C(ti4,ti11));
+                cr5 = (MUL_R_C(tr5,ti11)*isign + MUL_R_C(tr4,ti12));
+                ci5 = (MUL_R_C(ti5,ti11)*isign + MUL_R_C(ti4,ti12));
+                cr4 = (MUL_R_C(tr5,ti12)*isign - MUL_R_C(tr4,ti11));
+                ci4 = (MUL_R_C(ti5,ti12)*isign - MUL_R_C(ti4,ti11));
                 dr3 = cr3 - ci4;
                 dr4 = cr3 + ci4;
                 di3 = ci3 + cr4;
@@ -274,14 +274,14 @@
                 dr2 = cr2 - ci5;
                 di5 = ci2 - cr5;
                 di2 = ci2 + cr5;
-                ch[ah+l1*ido] = MUL_R_C(dr2,wa1[i]) - isign*MUL_R_C(di2,wa1[i+1]);
-                ch[ah+l1*ido+1] = MUL_R_C(di2,wa1[i]) + isign*MUL_R_C(dr2,wa1[i+1]);
-                ch[ah+2*l1*ido] = MUL_R_C(dr3,wa2[i]) - isign*MUL_R_C(di3,wa2[i+1]);
-                ch[ah+2*l1*ido+1] = MUL_R_C(di3,wa2[i]) + isign*MUL_R_C(dr3,wa2[i+1]);
-                ch[ah+3*l1*ido] = MUL_R_C(dr4,wa3[i]) - isign*MUL_R_C(di4,wa3[i+1]);
-                ch[ah+3*l1*ido+1] = MUL_R_C(di4,wa3[i]) + isign*MUL_R_C(dr4,wa3[i+1]);
-                ch[ah+4*l1*ido] = MUL_R_C(dr5,wa4[i]) - isign*MUL_R_C(di5,wa4[i+1]);
-                ch[ah+4*l1*ido+1] = MUL_R_C(di5,wa4[i]) + isign*MUL_R_C(dr5,wa4[i+1]);
+                ch[ah+l1*ido] = MUL_R_C(dr2,wa1[i]) - MUL_R_C(di2,wa1[i+1])*isign;
+                ch[ah+l1*ido+1] = MUL_R_C(di2,wa1[i]) + MUL_R_C(dr2,wa1[i+1])*isign;
+                ch[ah+2*l1*ido] = MUL_R_C(dr3,wa2[i]) - MUL_R_C(di3,wa2[i+1])*isign;
+                ch[ah+2*l1*ido+1] = MUL_R_C(di3,wa2[i]) + MUL_R_C(dr3,wa2[i+1])*isign;
+                ch[ah+3*l1*ido] = MUL_R_C(dr4,wa3[i]) - MUL_R_C(di4,wa3[i+1])*isign;
+                ch[ah+3*l1*ido+1] = MUL_R_C(di4,wa3[i]) + MUL_R_C(dr4,wa3[i+1])*isign;
+                ch[ah+4*l1*ido] = MUL_R_C(dr5,wa4[i]) - MUL_R_C(di5,wa4[i+1])*isign;
+                ch[ah+4*l1*ido+1] = MUL_R_C(di5,wa4[i]) + MUL_R_C(dr5,wa4[i+1])*isign;
             }
         }
     }
@@ -355,7 +355,7 @@
         for (ik = 0; ik < idl1; ik++)
         {
             cc[ik+l*idl1] = ch[ik] + MUL_R_C(ch[ik+idl1],wa[idl-2]);
-            cc[ik+lc*idl1] = isign * MUL_R_C(ch[ik+(ip-1)*idl1],wa[idl-1]);
+            cc[ik+lc*idl1] = MUL_R_C(ch[ik+(ip-1)*idl1],wa[idl-1])*isign;
         }
 
         idlj = idl;
@@ -375,7 +375,7 @@
             for (ik = 0; ik < idl1; ik++)
             {
                 cc[ik+l*idl1] += MUL_R_C(ch[ik+j*idl1],war);
-                cc[ik+lc*idl1] += isign * MUL_R_C(ch[ik+jc*idl1],wai);
+                cc[ik+lc*idl1] += MUL_R_C(ch[ik+jc*idl1],wai)*isign;
             }
         }
     }
@@ -433,9 +433,9 @@
                 for (k = 0; k < l1; k++)
                 {
                     cc[i-1+(k+j*l1)*ido] = MUL_R_C(ch[i-1+(k+j*l1)*ido],wa[idij-2]) -
-                        isign * MUL_R_C(ch[i+(k+j*l1)*ido],wa[idij-1]);
+                        MUL_R_C(ch[i+(k+j*l1)*ido],wa[idij-1])*isign;
                     cc[i+(k+j*l1)*ido] = MUL_R_C(ch[i+(k+j*l1)*ido],wa[idij-2]) +
-                        isign * MUL_R_C(ch[i-1+(k+j*l1)*ido],wa[idij-1]);
+                        MUL_R_C(ch[i-1+(k+j*l1)*ido],wa[idij-1])*isign;
                 }
             }
         }
@@ -454,9 +454,9 @@
                 {
                     idij += 2;
                     cc[i-1+(k+j*l1)*ido] = MUL_R_C(ch[i-1+(k+j*l1)*ido],wa[idij-2]) -
-                        isign * MUL_R_C(ch[i+(k+j*l1)*ido],wa[idij-1]);
+                        MUL_R_C(ch[i+(k+j*l1)*ido],wa[idij-1])*isign;
                     cc[i+(k+j*l1)*ido] = MUL_R_C(ch[i+(k+j*l1)*ido],wa[idij-2]) +
-                        isign * MUL_R_C(ch[i-1+(k+j*l1)*ido],wa[idij-1]);
+                        MUL_R_C(ch[i-1+(k+j*l1)*ido],wa[idij-1])*isign;
                 }
             }
         }
@@ -626,8 +626,8 @@
         for (j = 1; j <= ipm; j++)
         {
             i1 = i;
-            wa[i-1] = 1;
-            wa[i] = 0;
+            wa[i-1] = COEF_CONST(1.0);
+            wa[i] = COEF_CONST(0.0);
             ld += l1;
             fi = 0;
             argld = ld*argh;
@@ -653,11 +653,11 @@
 
 cfft_info *cffti(uint16_t n)
 {
-    cfft_info *cfft = malloc(sizeof(cfft_info));
+    cfft_info *cfft = (cfft_info*)malloc(sizeof(cfft_info));
 
     cfft->n = n;
-    cfft->work = malloc(2*n*sizeof(real_t));
-    cfft->tab = malloc(2*n*sizeof(real_t));
+    cfft->work = (real_t*)malloc(2*n*sizeof(real_t));
+    cfft->tab = (real_t*)malloc(2*n*sizeof(real_t));
 
     cffti1(n, cfft->tab, cfft->ifac);
 
--- a/libfaad/common.c
+++ b/libfaad/common.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: common.c,v 1.1 2002/04/20 14:45:13 menno Exp $
+** $Id: common.c,v 1.2 2002/08/27 10:24:54 menno Exp $
 **/
 
 /* just some common functions that could be used anywhere */
@@ -25,8 +25,10 @@
 
 #define LOG2 0.30102999566398
 
-
+#if 0
 uint32_t int_log2(uint32_t val)
 {
     return (uint32_t)(log((real_t)val)/LOG2 + 0.5);
 }
+#endif
+
--- a/libfaad/common.h
+++ b/libfaad/common.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: common.h,v 1.17 2002/08/26 18:41:47 menno Exp $
+** $Id: common.h,v 1.18 2002/08/27 10:24:54 menno Exp $
 **/
 
 #ifndef __COMMON_H__
@@ -137,8 +137,6 @@
 
 
 #if defined(FIXED_POINT)
-
-  typedef int32_t real_t;
 
   #include <math.h>
 
--- a/libfaad/decoder.c
+++ b/libfaad/decoder.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: decoder.c,v 1.22 2002/08/26 19:08:39 menno Exp $
+** $Id: decoder.c,v 1.23 2002/08/27 10:24:54 menno Exp $
 **/
 
 #include <stdlib.h>
@@ -42,7 +42,7 @@
 uint16_t dbg_count;
 #endif
 
-uint8_t* FAADAPI faacDecGetErrorMessage(uint8_t errcode)
+int8_t* FAADAPI faacDecGetErrorMessage(uint8_t errcode)
 {
     return err_msg[errcode];
 }
@@ -432,7 +432,7 @@
     uint8_t id_syn_ele, ele, ch;
     adts_header adts;
     uint8_t channels, ch_ele;
-    bitfile *ld = malloc(sizeof(bitfile));
+    bitfile *ld = (bitfile*)malloc(sizeof(bitfile));
 
     /* local copys of globals */
     uint8_t sf_index       =  hDecoder->sf_index;
@@ -682,7 +682,7 @@
             /* allocate the state only when needed */
             if (pred_stat[ch] == NULL)
             {
-                pred_stat[ch] = malloc(frame_len * sizeof(pred_state));
+                pred_stat[ch] = (real_t*)malloc(frame_len * sizeof(pred_state));
                 reset_all_predictors(pred_stat[ch], frame_len);
             }
 
@@ -722,7 +722,7 @@
             /* allocate the state only when needed */
             if (lt_pred_stat[ch] == NULL)
             {
-                lt_pred_stat[ch] = malloc(frame_len*4 * sizeof(real_t));
+                lt_pred_stat[ch] = (real_t*)malloc(frame_len*4 * sizeof(real_t));
                 memset(lt_pred_stat[ch], 0, frame_len*4 * sizeof(real_t));
             }
 
@@ -749,9 +749,9 @@
         if (time_out[ch] == NULL)
         {
             uint16_t r;
-            time_out[ch] = malloc(frame_len*2*sizeof(real_t));
+            time_out[ch] = (real_t*)malloc(frame_len*2*sizeof(real_t));
 			for (r = 0; r < frame_len*2; r++)
-				time_out[ch][r] = 0;
+				time_out[ch][r] = REAL_CONST(0.0);
         }
 
         /* filter bank */
--- a/libfaad/decoder.h
+++ b/libfaad/decoder.h
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: decoder.h,v 1.11 2002/08/26 19:08:39 menno Exp $
+** $Id: decoder.h,v 1.12 2002/08/27 10:24:55 menno Exp $
 **/
 
 #ifndef __DECODER_H__
@@ -110,7 +110,7 @@
 } faacDecStruct, *faacDecHandle;
 
 
-uint8_t* FAADAPI faacDecGetErrorMessage(uint8_t errcode);
+int8_t* FAADAPI faacDecGetErrorMessage(uint8_t errcode);
 
 faacDecHandle FAADAPI faacDecOpen();
 
--- a/libfaad/dither.c
+++ b/libfaad/dither.c
@@ -8,6 +8,7 @@
  * last modified: $ID:$
  */
 #include "common.h"
+#include <memory.h>
 #include "dither.h"
 
 static const  uint8_t    Parity [256] = {  // parity
--- a/libfaad/dither.h
+++ b/libfaad/dither.h
@@ -29,7 +29,7 @@
 
 extern dither_t            Dither;
 extern double              doubletmp;
-static const uint8_t       Parity [256];
+//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 );
--- a/libfaad/drc.c
+++ b/libfaad/drc.c
@@ -16,18 +16,19 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: drc.c,v 1.8 2002/08/26 18:41:47 menno Exp $
+** $Id: drc.c,v 1.9 2002/08/27 10:24:55 menno Exp $
 **/
 
 #include "common.h"
 
 #include <stdlib.h>
+#include <memory.h>
 #include "syntax.h"
 #include "drc.h"
 
 drc_info *drc_init(real_t cut, real_t boost)
 {
-    drc_info *drc = malloc(sizeof(drc_info));
+    drc_info *drc = (drc_info*)malloc(sizeof(drc_info));
     memset(drc, 0, sizeof(drc_info));
 
     drc->ctrl1 = cut;
--- a/libfaad/error.c
+++ b/libfaad/error.c
@@ -16,13 +16,13 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: error.c,v 1.5 2002/06/15 15:38:22 menno Exp $
+** $Id: error.c,v 1.6 2002/08/27 10:24:55 menno Exp $
 **/
 
 #include "common.h"
 #include "error.h"
 
-extern uint8_t *err_msg[] = {
+extern int8_t *err_msg[] = {
     "No error",
     "Gain control not yet implemented",
     "Pulse coding not allowed in short blocks",
--- a/libfaad/error.h
+++ b/libfaad/error.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: error.h,v 1.2 2002/02/18 10:01:05 menno Exp $
+** $Id: error.h,v 1.3 2002/08/27 10:24:55 menno Exp $
 **/
 
 #ifndef __ERROR_H__
@@ -26,7 +26,7 @@
 extern "C" {
 #endif
 
-extern uint8_t *err_msg[];
+extern int8_t *err_msg[];
 
 #ifdef __cplusplus
 }
--- a/libfaad/filtbank.c
+++ b/libfaad/filtbank.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: filtbank.c,v 1.15 2002/08/26 18:41:47 menno Exp $
+** $Id: filtbank.c,v 1.16 2002/08/27 10:24:55 menno Exp $
 **/
 
 #include "common.h"
@@ -38,7 +38,7 @@
     uint16_t frame_len_ld = frame_len/2;
 #endif
 
-    fb_info *fb = malloc(sizeof(fb_info));
+    fb_info *fb = (fb_info*)malloc(sizeof(fb_info));
     memset(fb, 0, sizeof(fb_info));
 
     /* normal */
@@ -45,14 +45,14 @@
     fb->mdct256 = faad_mdct_init(2*nshort);
     fb->mdct2048 = faad_mdct_init(2*frame_len);
 
-    fb->long_window[0]  = malloc(frame_len*sizeof(real_t));
-    fb->short_window[0] = malloc(nshort*sizeof(real_t));
+    fb->long_window[0]  = (real_t*)malloc(frame_len*sizeof(real_t));
+    fb->short_window[0] = (real_t*)malloc(nshort*sizeof(real_t));
 #ifndef FIXED_POINT
     fb->long_window[1]  = kbd_long;
     fb->short_window[1] = kbd_short;
 #else
-    fb->long_window[1]  = malloc(frame_len*sizeof(real_t));
-    fb->short_window[1] = malloc(nshort*sizeof(real_t));
+    fb->long_window[1]  = (real_t*)malloc(frame_len*sizeof(real_t));
+    fb->short_window[1] = (real_t*)malloc(nshort*sizeof(real_t));
 
     for (i = 0; i < frame_len; i++)
         fb->long_window[1][i] = COEF_CONST(kbd_long[i]);
@@ -70,8 +70,8 @@
     /* LD */
     fb->mdct1024 = faad_mdct_init(frame_len_ld);
 
-    fb->ld_window[0] = malloc(frame_len_ld*sizeof(real_t));
-    fb->ld_window[1] = malloc(frame_len_ld*sizeof(real_t));
+    fb->ld_window[0] = (real_t*)malloc(frame_len_ld*sizeof(real_t));
+    fb->ld_window[1] = (real_t*)malloc(frame_len_ld*sizeof(real_t));
 
     /* calculate the sine windows */
     for (i = 0; i < frame_len_ld; i++)
@@ -181,7 +181,7 @@
 
     uint16_t nflat_ls = (nlong-nshort)/2;
 
-    transf_buf = malloc(2*nlong*sizeof(real_t));
+    transf_buf = (real_t*)malloc(2*nlong*sizeof(real_t));
 
 #ifdef LD_DEC
     if (object_type == LD)
@@ -211,7 +211,7 @@
 
     case LONG_START_SEQUENCE:
         imdct(fb, freq_in, transf_buf, 2*nlong);
-        for (i = nlong-1; i >= 0; i--)
+        for (i = 0; i < 0; i++)
             time_out[i] = time_out[nlong+i] + MUL_R_C(transf_buf[i],window_long_prev[i]);
         for (i = 0; i < nflat_ls; i++)
             time_out[nlong+i] = transf_buf[nlong+i];
@@ -218,7 +218,7 @@
         for (i = 0; i < nshort; i++)
             time_out[nlong+nflat_ls+i] = MUL_R_C(transf_buf[nlong+nflat_ls+i],window_short[nshort-i-1]);
         for (i = 0; i < nflat_ls; i++)
-            time_out[nlong+nflat_ls+nshort+i] = 0;
+            time_out[nlong+nflat_ls+nshort+i] = REAL_CONST(0.0);
         break;
 
     case EIGHT_SHORT_SEQUENCE:
@@ -248,7 +248,7 @@
             time_out[nflat_ls+8*nshort+i] = MUL_R_C(transf_buf[nshort*15+i],window_short[nshort-1-i]);
         }
         for (i = 0; i < nflat_ls; i++)
-            time_out[nlong+nflat_ls+nshort+i] = 0;
+            time_out[nlong+nflat_ls+nshort+i] = REAL_CONST(0.0);
         break;
 
     case LONG_STOP_SEQUENCE:
@@ -259,7 +259,7 @@
             time_out[nflat_ls+i] = time_out[nlong+nflat_ls+i] + MUL_R_C(transf_buf[nflat_ls+i],window_short_prev[i]);
         for (i = 0; i < nflat_ls; i++)
             time_out[nflat_ls+nshort+i] = time_out[nlong+nflat_ls+nshort+i] + transf_buf[nflat_ls+nshort+i];
-        for (i = nlong-1; i >= 0; i--)
+        for (i = 0; i < nlong; i++)
             time_out[nlong+i] = MUL_R_C(transf_buf[nlong+i],window_long[nlong-1-i]);
 		break;
     }
@@ -287,7 +287,7 @@
 
     assert(window_sequence != EIGHT_SHORT_SEQUENCE);
 
-    windowed_buf = malloc(nlong*2*sizeof(real_t));
+    windowed_buf = (real_t*)malloc(nlong*2*sizeof(real_t));
 
 #ifdef LD_DEC
     if (object_type == LD)
--- a/libfaad/fixed.h
+++ b/libfaad/fixed.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: fixed.h,v 1.1 2002/08/26 19:08:39 menno Exp $
+** $Id: fixed.h,v 1.2 2002/08/27 10:24:55 menno Exp $
 **/
 
 #ifndef __FIXED_H__
@@ -26,6 +26,7 @@
 extern "C" {
 #endif
 
+
 #define COEF_1_BITS 31
 #define COEF_1_PRECISION (1 << COEF_1_BITS)
 #define COEF_BITS 28
@@ -32,6 +33,10 @@
 #define COEF_PRECISION (1 << COEF_BITS)
 #define REAL_BITS 7
 #define REAL_PRECISION (1 << REAL_BITS)
+
+
+typedef int32_t real_t;
+
 
 #define COEF_CONST_1(A) ((real_t)(A*(COEF_1_PRECISION)))
 #define REAL_CONST(A) ((real_t)(A*(REAL_PRECISION)))
--- a/libfaad/libfaad.vcproj
+++ b/libfaad/libfaad.vcproj
@@ -265,10 +265,10 @@
 				RelativePath=".\error.h">
 			</File>
 			<File
-				RelativePath=".\fftw\f77_func.h">
+				RelativePath=".\filtbank.h">
 			</File>
 			<File
-				RelativePath=".\filtbank.h">
+				RelativePath="fixed.h">
 			</File>
 			<File
 				RelativePath=".\codebook\hcb.h">
--- a/libfaad/lt_predict.c
+++ b/libfaad/lt_predict.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: lt_predict.c,v 1.7 2002/08/17 12:27:33 menno Exp $
+** $Id: lt_predict.c,v 1.8 2002/08/27 10:24:55 menno Exp $
 **/
 
 
@@ -58,8 +58,8 @@
         {
             num_samples = frame_len << 1;
 
-            x_est = malloc(num_samples*sizeof(real_t));
-            X_est = malloc(num_samples*sizeof(real_t));
+            x_est = (real_t*)malloc(num_samples*sizeof(real_t));
+            X_est = (real_t*)malloc(num_samples*sizeof(real_t));
 
             for(i = 0; i < num_samples; i++)
             {
--- a/libfaad/mdct.c
+++ b/libfaad/mdct.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: mdct.c,v 1.16 2002/08/26 18:41:47 menno Exp $
+** $Id: mdct.c,v 1.17 2002/08/27 10:24:55 menno Exp $
 **/
 
 /*
@@ -56,7 +56,7 @@
     uint16_t k;
 	float32_t scale = sqrt(2.0/(float32_t)N);
 
-    mdct_info *mdct = malloc(sizeof(mdct_info));
+    mdct_info *mdct = (mdct_info*)malloc(sizeof(mdct_info));
 
     assert(N % 8 == 0);
 
--- a/libfaad/reordered_spectral_data.c
+++ b/libfaad/reordered_spectral_data.c
@@ -230,7 +230,8 @@
             if ((sp[k] == 16) || (sp[k] == -16))
             {
                 uint8_t neg, i;
-                int32_t j, off;
+                int32_t j;
+                uint32_t off;
 
                 neg = (sp[k] < 0) ? 1 : 0; 
 
--- a/libfaad/specrec.c
+++ b/libfaad/specrec.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: specrec.c,v 1.11 2002/08/26 18:41:47 menno Exp $
+** $Id: specrec.c,v 1.12 2002/08/27 10:24:57 menno Exp $
 **/
 
 /*
@@ -177,14 +177,14 @@
     tmp_spec_ptr = tmp_spec;
     for (i = frame_len/16-1; i >= 0; --i)
     {
-        *tmp_spec_ptr++ = 0; *tmp_spec_ptr++ = 0;
-        *tmp_spec_ptr++ = 0; *tmp_spec_ptr++ = 0;
-        *tmp_spec_ptr++ = 0; *tmp_spec_ptr++ = 0;
-        *tmp_spec_ptr++ = 0; *tmp_spec_ptr++ = 0;
-        *tmp_spec_ptr++ = 0; *tmp_spec_ptr++ = 0;
-        *tmp_spec_ptr++ = 0; *tmp_spec_ptr++ = 0;
-        *tmp_spec_ptr++ = 0; *tmp_spec_ptr++ = 0;
-        *tmp_spec_ptr++ = 0; *tmp_spec_ptr++ = 0;
+        *tmp_spec_ptr++ = REAL_CONST(0.0); *tmp_spec_ptr++ = REAL_CONST(0.0);
+        *tmp_spec_ptr++ = REAL_CONST(0.0); *tmp_spec_ptr++ = REAL_CONST(0.0);
+        *tmp_spec_ptr++ = REAL_CONST(0.0); *tmp_spec_ptr++ = REAL_CONST(0.0);
+        *tmp_spec_ptr++ = REAL_CONST(0.0); *tmp_spec_ptr++ = REAL_CONST(0.0);
+        *tmp_spec_ptr++ = REAL_CONST(0.0); *tmp_spec_ptr++ = REAL_CONST(0.0);
+        *tmp_spec_ptr++ = REAL_CONST(0.0); *tmp_spec_ptr++ = REAL_CONST(0.0);
+        *tmp_spec_ptr++ = REAL_CONST(0.0); *tmp_spec_ptr++ = REAL_CONST(0.0);
+        *tmp_spec_ptr++ = REAL_CONST(0.0); *tmp_spec_ptr++ = REAL_CONST(0.0);
     }
 
     spec_ptr = spec_data;
@@ -268,7 +268,7 @@
     uint16_t nshort = frame_len/8;
 
     for (i = 0; i < frame_len; i++)
-        x_invquant[i] = 0;
+        x_invquant[i] = REAL_CONST(0.0);
 
     for (g = 0; g < ics->num_window_groups; g++)
     {
@@ -304,7 +304,7 @@
                 else if (shift >= -31)
                     dequant *= (1 >> -shift);
                 else
-                    dequant = 0;
+                    dequant = REAL_CONST(0.0);
 
                 dequant = MUL_R_C(dequant, newpow2_table[scalefactor & 3]);
 
--- a/libfaad/tns.c
+++ b/libfaad/tns.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: tns.c,v 1.14 2002/08/26 18:41:47 menno Exp $
+** $Id: tns.c,v 1.15 2002/08/27 10:24:57 menno Exp $
 **/
 
 #include "common.h"
@@ -160,7 +160,7 @@
     }
 
     /* Conversion to LPC coefficients */
-    a[0] = 1;
+    a[0] = COEF_CONST(1.0);
     for (m = 1; m <= order; m++)
     {
         for (i = 1; i < m; i++) /* loop only while i<m */
@@ -190,7 +190,7 @@
     real_t y, state[TNS_MAX_ORDER];
 
     for (i = 0; i < order; i++)
-        state[i] = 0;
+        state[i] = REAL_CONST(0.0);
 
     for (i = 0; i < size; i++)
     {
@@ -225,7 +225,7 @@
     real_t y, state[TNS_MAX_ORDER];
 
     for (i = 0; i < order; i++)
-        state[i] = 0;
+        state[i] = REAL_CONST(0.0);
 
     for (i = 0; i < size; i++)
     {