Bug 500254 - Update libvorbis - rs=roc
authorChris Double <chris.double@double.co.nz>
Tue, 07 Jul 2009 10:10:04 +1200
changeset 30043 f46e6aee13358520ea32ab998a74a304c870e630
parent 30042 475b8583efe4629f01df7ed048caa21f364bf52b
child 30044 a13eed3a20e7fa58718c290580a66f219b56a3cf
push idunknown
push userunknown
push dateunknown
reviewersroc
bugs500254
milestone1.9.2a1pre
Bug 500254 - Update libvorbis - rs=roc
media/libvorbis/COPYING
media/libvorbis/README
media/libvorbis/README_MOZILLA
media/libvorbis/bug498827.patch
media/libvorbis/bug498853.patch
media/libvorbis/include/vorbis/codec.h
media/libvorbis/lib/backends.h
media/libvorbis/lib/bitrate.h
media/libvorbis/lib/codebook.h
media/libvorbis/lib/codec_internal.h
media/libvorbis/lib/envelope.h
media/libvorbis/lib/highlevel.h
media/libvorbis/lib/lookup.h
media/libvorbis/lib/lookup_data.h
media/libvorbis/lib/lpc.h
media/libvorbis/lib/lsp.h
media/libvorbis/lib/masking.h
media/libvorbis/lib/mdct.h
media/libvorbis/lib/misc.h
media/libvorbis/lib/os.h
media/libvorbis/lib/psy.h
media/libvorbis/lib/registry.h
media/libvorbis/lib/scales.h
media/libvorbis/lib/smallft.h
media/libvorbis/lib/vorbis_analysis.c
media/libvorbis/lib/vorbis_bitrate.c
media/libvorbis/lib/vorbis_block.c
media/libvorbis/lib/vorbis_codebook.c
media/libvorbis/lib/vorbis_envelope.c
media/libvorbis/lib/vorbis_floor0.c
media/libvorbis/lib/vorbis_floor1.c
media/libvorbis/lib/vorbis_info.c
media/libvorbis/lib/vorbis_lookup.c
media/libvorbis/lib/vorbis_lpc.c
media/libvorbis/lib/vorbis_lsp.c
media/libvorbis/lib/vorbis_mapping0.c
media/libvorbis/lib/vorbis_mdct.c
media/libvorbis/lib/vorbis_psy.c
media/libvorbis/lib/vorbis_registry.c
media/libvorbis/lib/vorbis_res0.c
media/libvorbis/lib/vorbis_sharedbook.c
media/libvorbis/lib/vorbis_smallft.c
media/libvorbis/lib/vorbis_synthesis.c
media/libvorbis/lib/vorbis_window.c
media/libvorbis/lib/window.h
media/libvorbis/update.sh
--- a/media/libvorbis/COPYING
+++ b/media/libvorbis/COPYING
@@ -1,9 +1,9 @@
-Copyright (c) 2002-2004 Xiph.org Foundation
+Copyright (c) 2002-2008 Xiph.org Foundation
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions
 are met:
 
 - Redistributions of source code must retain the above copyright
 notice, this list of conditions and the following disclaimer.
 
--- a/media/libvorbis/README
+++ b/media/libvorbis/README
@@ -74,33 +74,35 @@ Vorbis's homepage is located at 'http://
 Up to date technical documents, contact information, source code and
 pre-built utilities may be found there.
 
 The user website for Ogg Vorbis software and audio is http://vorbis.com/
 
 BUILDING FROM TRUNK:
 
 Development source is under subversion revision control at 
-http://svn.xiph.org/trunk/vorbis/. You will also need the 
-newest versions of autoconf, automake, and libtool in order
-to compile vorbis from development source. A configure script
+https://svn.xiph.org/trunk/vorbis/. You will also need the 
+newest versions of autoconf, automake, libtool and pkg-config in
+order to compile Vorbis from development source. A configure script
 is provided for you in the source tarball distributions.
 
   [update or checkout latest source]
   ./autogen.sh
-  make 
+  make
 
 and as root if desired:
 
   make install
 
-This will install the vorbis libraries (static and shared) into
+This will install the Vorbis libraries (static and shared) into
 /usr/local/lib, includes into /usr/local/include and API manpages
 (once we write some) into /usr/local/man.
 
+Documentation building requires xsltproc and pdfxmltex.
+
 BUILDING FROM TARBALL DISTRIBUTIONS:
 
   ./configure
   make
 
 and optionally (as root):
   make install
 
--- a/media/libvorbis/README_MOZILLA
+++ b/media/libvorbis/README_MOZILLA
@@ -1,17 +1,14 @@
-The source from this directory was copied from the libvorbis-1.2.0
-source distribution using the update.sh script. The only changes made
-were those applied by update.sh and the addition/upate of Makefile.in
-files for the Mozilla build system.
+The source from this directory was copied from the libvorbis
+subversion repository using the update.sh script. The only changes
+made were those applied by update.sh and the addition/upate of
+Makefile.in files for the Mozilla build system.
+
+The svn revision number used was r16183.
 
 Some files are renamed during the copy to prevent clashes with object
 file names with other Mozilla libraries.
 
-BUG 455372 - WinCE LibVorbis No FPU Support on WinMobile, removed FPU
-support for builds with WINCE defined.
-
-BUG 469639 - Failed to build firefox trunk on OpenSolaris
+alloca.diff - Bug 469639 - Failed to build firefox trunk on OpenSolaris
 bug481601.patch is appled to fix bug 481601.
 bug487519.patch: fix for bug 487519.
-bug498827.patch: fix for bug 498827
 bug498855.patch: fix for bug 498855
-bug498853.patch: fix for bug 498853
\ No newline at end of file
deleted file mode 100644
--- a/media/libvorbis/bug498827.patch
+++ /dev/null
@@ -1,53 +0,0 @@
-diff --git a/media/libvorbis/lib/vorbis_info.c b/media/libvorbis/lib/vorbis_info.c
-index 5a9d209..1d50526 100644
---- a/media/libvorbis/lib/vorbis_info.c
-+++ b/media/libvorbis/lib/vorbis_info.c
-@@ -16,16 +16,17 @@
-  ********************************************************************/
- 
- /* general handling of the header and the vorbis_info structure (and
-    substructures) */
- 
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
-+#include <limits.h>
- #include <ogg/ogg.h>
- #include "vorbis/codec.h"
- #include "codec_internal.h"
- #include "codebook.h"
- #include "registry.h"
- #include "window.h"
- #include "psy.h"
- #include "misc.h"
-@@ -230,27 +231,27 @@ static int _vorbis_unpack_info(vorbis_info *vi,oggpack_buffer *opb){
-  err_out:
-   vorbis_info_clear(vi);
-   return(OV_EBADHEADER);
- }
- 
- static int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb){
-   int i;
-   int vendorlen=oggpack_read(opb,32);
--  if(vendorlen<0)goto err_out;
-+  if(vendorlen<0||vendorlen>opb->storage)goto err_out;
-   vc->vendor=_ogg_calloc(vendorlen+1,1);
-   _v_readstring(opb,vc->vendor,vendorlen);
-   vc->comments=oggpack_read(opb,32);
--  if(vc->comments<0)goto err_out;
-+  if(vc->comments<0||vc->comments>(LONG_MAX>>2)||vc->comments<<2>opb->storage)goto err_out;
-   vc->user_comments=_ogg_calloc(vc->comments+1,sizeof(*vc->user_comments));
-   vc->comment_lengths=_ogg_calloc(vc->comments+1, sizeof(*vc->comment_lengths));
- 	    
-   for(i=0;i<vc->comments;i++){
-     int len=oggpack_read(opb,32);
--    if(len<0)goto err_out;
-+    if(len<0||len>opb->storage)goto err_out;
- 	vc->comment_lengths[i]=len;
-     vc->user_comments[i]=_ogg_calloc(len+1,1);
-     _v_readstring(opb,vc->user_comments[i],len);
-   }	  
-   if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */
- 
-   return(0);
-  err_out:
deleted file mode 100644
--- a/media/libvorbis/bug498853.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-diff --git a/media/libvorbis/lib/vorbis_info.c b/media/libvorbis/lib/vorbis_info.c
-index 1d50526..1356cb4 100644
---- a/media/libvorbis/lib/vorbis_info.c
-+++ b/media/libvorbis/lib/vorbis_info.c
-@@ -126,20 +126,22 @@ int vorbis_comment_query_count(vorbis_comment *vc, char *tag){
-   }
- 
-   return count;
- }
- 
- void vorbis_comment_clear(vorbis_comment *vc){
-   if(vc){
-     long i;
--    for(i=0;i<vc->comments;i++)
--      if(vc->user_comments[i])_ogg_free(vc->user_comments[i]);
--    if(vc->user_comments)_ogg_free(vc->user_comments);
--	if(vc->comment_lengths)_ogg_free(vc->comment_lengths);
-+    if (vc->user_comments) {
-+      for(i=0;i<vc->comments;i++)
-+	if(vc->user_comments[i])_ogg_free(vc->user_comments[i]);
-+      _ogg_free(vc->user_comments);
-+    }
-+    if(vc->comment_lengths)_ogg_free(vc->comment_lengths);
-     if(vc->vendor)_ogg_free(vc->vendor);
-     memset(vc,0,sizeof(*vc));
-   }
- }
- 
- /* blocksize 0 is guaranteed to be short, 1 is guaranteed to be long.
-    They may be equal, but short will never ge greater than long */
- int vorbis_info_blocksize(vorbis_info *vi,int zo){
--- a/media/libvorbis/include/vorbis/codec.h
+++ b/media/libvorbis/include/vorbis/codec.h
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
 
  ********************************************************************
 
  function: libvorbis codec headers
- last mod: $Id: codec.h 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #ifndef _vorbis_codec_h_
 #define _vorbis_codec_h_
 
 #ifdef __cplusplus
 extern "C"
@@ -161,52 +161,54 @@ typedef struct vorbis_comment{
    and the streaming layer is not used */
 
 /* Vorbis PRIMITIVES: general ***************************************/
 
 extern void     vorbis_info_init(vorbis_info *vi);
 extern void     vorbis_info_clear(vorbis_info *vi);
 extern int      vorbis_info_blocksize(vorbis_info *vi,int zo);
 extern void     vorbis_comment_init(vorbis_comment *vc);
-extern void     vorbis_comment_add(vorbis_comment *vc, char *comment);
+extern void     vorbis_comment_add(vorbis_comment *vc, const char *comment);
 extern void     vorbis_comment_add_tag(vorbis_comment *vc,
-				       char *tag, char *contents);
-extern char    *vorbis_comment_query(vorbis_comment *vc, char *tag, int count);
-extern int      vorbis_comment_query_count(vorbis_comment *vc, char *tag);
+                                       const char *tag, const char *contents);
+extern char    *vorbis_comment_query(vorbis_comment *vc, const char *tag, int count);
+extern int      vorbis_comment_query_count(vorbis_comment *vc, const char *tag);
 extern void     vorbis_comment_clear(vorbis_comment *vc);
 
 extern int      vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);
 extern int      vorbis_block_clear(vorbis_block *vb);
 extern void     vorbis_dsp_init(vorbis_dsp_state *v);
 extern void     vorbis_dsp_clear(vorbis_dsp_state *v);
 extern double   vorbis_granule_time(vorbis_dsp_state *v,
-				    ogg_int64_t granulepos);
+                                    ogg_int64_t granulepos);
+
+extern const char *vorbis_version_string(void);
 
 /* Vorbis PRIMITIVES: analysis/DSP layer ****************************/
 
 extern int      vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi);
 extern int      vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op);
 extern int      vorbis_analysis_headerout(vorbis_dsp_state *v,
-					  vorbis_comment *vc,
-					  ogg_packet *op,
-					  ogg_packet *op_comm,
-					  ogg_packet *op_code);
+                                          vorbis_comment *vc,
+                                          ogg_packet *op,
+                                          ogg_packet *op_comm,
+                                          ogg_packet *op_code);
 extern float  **vorbis_analysis_buffer(vorbis_dsp_state *v,int vals);
 extern int      vorbis_analysis_wrote(vorbis_dsp_state *v,int vals);
 extern int      vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb);
 extern int      vorbis_analysis(vorbis_block *vb,ogg_packet *op);
 
 extern int      vorbis_bitrate_addblock(vorbis_block *vb);
 extern int      vorbis_bitrate_flushpacket(vorbis_dsp_state *vd,
-					   ogg_packet *op);
+                                           ogg_packet *op);
 
 /* Vorbis PRIMITIVES: synthesis layer *******************************/
 extern int      vorbis_synthesis_idheader(ogg_packet *op);
 extern int      vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,
-					  ogg_packet *op);
+                                          ogg_packet *op);
 
 extern int      vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi);
 extern int      vorbis_synthesis_restart(vorbis_dsp_state *v);
 extern int      vorbis_synthesis(vorbis_block *vb,ogg_packet *op);
 extern int      vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op);
 extern int      vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb);
 extern int      vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm);
 extern int      vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm);
--- a/media/libvorbis/lib/backends.h
+++ b/media/libvorbis/lib/backends.h
@@ -7,17 +7,17 @@
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: libvorbis backend and mapping structures; needed for 
            static mode headers
- last mod: $Id: backends.h 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 /* this is exposed up here because we need it for static modes.
    Lookups for each backend aren't exposed because there's no reason
    to do so */
 
 #ifndef _vorbis_backend_h_
@@ -30,17 +30,17 @@
 typedef struct{
   void                   (*pack)  (vorbis_info_floor *,oggpack_buffer *);
   vorbis_info_floor     *(*unpack)(vorbis_info *,oggpack_buffer *);
   vorbis_look_floor     *(*look)  (vorbis_dsp_state *,vorbis_info_floor *);
   void (*free_info) (vorbis_info_floor *);
   void (*free_look) (vorbis_look_floor *);
   void *(*inverse1)  (struct vorbis_block *,vorbis_look_floor *);
   int   (*inverse2)  (struct vorbis_block *,vorbis_look_floor *,
-		     void *buffer,float *);
+                     void *buffer,float *);
 } vorbis_func_floor;
 
 typedef struct{
   int   order;
   long  rate;
   long  barkmap;
 
   int   ampbits;
@@ -84,49 +84,48 @@ typedef struct{
 
 } vorbis_info_floor1;
 
 /* Residue backend generic *****************************************/
 typedef struct{
   void                 (*pack)  (vorbis_info_residue *,oggpack_buffer *);
   vorbis_info_residue *(*unpack)(vorbis_info *,oggpack_buffer *);
   vorbis_look_residue *(*look)  (vorbis_dsp_state *,
-				 vorbis_info_residue *);
+                                 vorbis_info_residue *);
   void (*free_info)    (vorbis_info_residue *);
   void (*free_look)    (vorbis_look_residue *);
   long **(*class)      (struct vorbis_block *,vorbis_look_residue *,
-			float **,int *,int);
+                        float **,int *,int);
   int  (*forward)      (oggpack_buffer *,struct vorbis_block *,
-			vorbis_look_residue *,
-			float **,float **,int *,int,long **);
+                        vorbis_look_residue *,
+                        float **,float **,int *,int,long **);
   int  (*inverse)      (struct vorbis_block *,vorbis_look_residue *,
-			float **,int *,int);
+                        float **,int *,int);
 } vorbis_func_residue;
 
 typedef struct vorbis_info_residue0{
 /* block-partitioned VQ coded straight residue */
   long  begin;
   long  end;
 
   /* first stage (lossless partitioning) */
   int    grouping;         /* group n vectors per partition */
   int    partitions;       /* possible codebooks for a partition */
   int    groupbook;        /* huffbook for partitioning */
   int    secondstages[64]; /* expanded out to pointers in lookup */
   int    booklist[256];    /* list of second stage books */
 
-  float  classmetric1[64];  
-  float  classmetric2[64];  
-
+  const float classmetric1[64];  
+  const float classmetric2[64];  
 } vorbis_info_residue0;
 
 /* Mapping backend generic *****************************************/
 typedef struct{
   void                 (*pack)  (vorbis_info *,vorbis_info_mapping *,
-				 oggpack_buffer *);
+                                 oggpack_buffer *);
   vorbis_info_mapping *(*unpack)(vorbis_info *,oggpack_buffer *);
   void (*free_info)    (vorbis_info_mapping *);
   int  (*forward)      (struct vorbis_block *vb);
   int  (*inverse)      (struct vorbis_block *vb,vorbis_info_mapping *);
 } vorbis_func_mapping;
 
 typedef struct vorbis_info_mapping0{
   int   submaps;  /* <= 16 */
--- a/media/libvorbis/lib/bitrate.h
+++ b/media/libvorbis/lib/bitrate.h
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: bitrate tracking and management
- last mod: $Id: bitrate.h 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #ifndef _V_BITRATE_H_
 #define _V_BITRATE_H_
 
 #include "vorbis/codec.h"
 #include "codec_internal.h"
--- a/media/libvorbis/lib/codebook.h
+++ b/media/libvorbis/lib/codebook.h
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: basic shared codebook operations
- last mod: $Id: codebook.h 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #ifndef _V_CODEBOOK_H_
 #define _V_CODEBOOK_H_
 
 #include <ogg/ogg.h>
 
@@ -35,28 +35,28 @@
 
 typedef struct static_codebook{
   long   dim;            /* codebook dimensions (elements per vector) */
   long   entries;        /* codebook entries */
   long  *lengthlist;     /* codeword lengths in bits */
 
   /* mapping ***************************************************************/
   int    maptype;        /* 0=none
-			    1=implicitly populated values from map column 
-			    2=listed arbitrary values */
+                            1=implicitly populated values from map column 
+                            2=listed arbitrary values */
 
   /* The below does a linear, single monotonic sequence mapping. */
   long     q_min;       /* packed 32 bit float; quant value 0 maps to minval */
   long     q_delta;     /* packed 32 bit float; val 1 - val 0 == delta */
   int      q_quant;     /* bits: 0 < quant <= 16 */
   int      q_sequencep; /* bitflag */
 
   long     *quantlist;  /* map == 1: (int)(entries^(1/dim)) element column map
-			   map == 2: list of dim*entries quantized entry vals
-			*/
+                           map == 2: list of dim*entries quantized entry vals
+                        */
 
   /* encode helpers ********************************************************/
   struct encode_aux_nearestmatch *nearest_tree;
   struct encode_aux_threshmatch  *thresh_tree;
   struct encode_aux_pigeonhole  *pigeon_tree;
 
   int allocedp;
 } static_codebook;
@@ -137,24 +137,24 @@ extern long vorbis_book_codelen(codebook
 
 
 extern int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *b);
 extern int vorbis_staticbook_unpack(oggpack_buffer *b,static_codebook *c);
 
 extern int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b);
 extern int vorbis_book_errorv(codebook *book, float *a);
 extern int vorbis_book_encodev(codebook *book, int best,float *a, 
-			       oggpack_buffer *b);
+                               oggpack_buffer *b);
 
 extern long vorbis_book_decode(codebook *book, oggpack_buffer *b);
 extern long vorbis_book_decodevs_add(codebook *book, float *a, 
-				     oggpack_buffer *b,int n);
+                                     oggpack_buffer *b,int n);
 extern long vorbis_book_decodev_set(codebook *book, float *a, 
-				    oggpack_buffer *b,int n);
+                                    oggpack_buffer *b,int n);
 extern long vorbis_book_decodev_add(codebook *book, float *a, 
-				    oggpack_buffer *b,int n);
+                                    oggpack_buffer *b,int n);
 extern long vorbis_book_decodevv_add(codebook *book, float **a,
-				     long off,int ch, 
-				    oggpack_buffer *b,int n);
+                                     long off,int ch, 
+                                    oggpack_buffer *b,int n);
 
 
 
 #endif
--- a/media/libvorbis/lib/codec_internal.h
+++ b/media/libvorbis/lib/codec_internal.h
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: libvorbis codec headers
- last mod: $Id: codec_internal.h 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #ifndef _V_CODECI_H_
 #define _V_CODECI_H_
 
 #include "envelope.h"
 #include "codebook.h"
@@ -29,19 +29,19 @@
 #define PACKETBLOBS 15
 
 typedef struct vorbis_block_internal{
   float  **pcmdelay;  /* this is a pointer into local storage */ 
   float  ampmax;
   int    blocktype;
 
   oggpack_buffer *packetblob[PACKETBLOBS]; /* initialized, must be freed; 
-					      blob [PACKETBLOBS/2] points to
-					      the oggpack_buffer in the 
-					      main vorbis_block */
+                                              blob [PACKETBLOBS/2] points to
+                                              the oggpack_buffer in the 
+                                              main vorbis_block */
 } vorbis_block_internal;
 
 typedef void vorbis_look_floor;
 typedef void vorbis_look_residue;
 typedef void vorbis_look_transform;
 
 /* mode ************************************************************/
 typedef struct {
@@ -128,10 +128,41 @@ typedef struct codec_setup_info {
                                 highly redundant structure, but
                                 improves clarity of program flow. */
   int         halfrate_flag; /* painless downsample for decode */  
 } codec_setup_info;
 
 extern vorbis_look_psy_global *_vp_global_look(vorbis_info *vi);
 extern void _vp_global_free(vorbis_look_psy_global *look);
 
+
+
+typedef struct {
+  int sorted_index[VIF_POSIT+2];
+  int forward_index[VIF_POSIT+2];
+  int reverse_index[VIF_POSIT+2];
+  
+  int hineighbor[VIF_POSIT];
+  int loneighbor[VIF_POSIT];
+  int posts;
+
+  int n;
+  int quant_q;
+  vorbis_info_floor1 *vi;
+
+  long phrasebits;
+  long postbits;
+  long frames;
+} vorbis_look_floor1;
+
+
+
+extern int *floor1_fit(vorbis_block *vb,vorbis_look_floor1 *look,
+                          const float *logmdct,   /* in */
+                          const float *logmask);
+extern int *floor1_interpolate_fit(vorbis_block *vb,vorbis_look_floor1 *look,
+                          int *A,int *B,
+                          int del);
+extern int floor1_encode(oggpack_buffer *opb,vorbis_block *vb,
+                  vorbis_look_floor1 *look,
+                  int *post,int *ilogmask);
 #endif
 
--- a/media/libvorbis/lib/envelope.h
+++ b/media/libvorbis/lib/envelope.h
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: PCM data envelope analysis and manipulation
- last mod: $Id: envelope.h 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #ifndef _V_ENVELOPE_
 #define _V_ENVELOPE_
 
 #include "mdct.h"
 
--- a/media/libvorbis/lib/highlevel.h
+++ b/media/libvorbis/lib/highlevel.h
@@ -6,29 +6,29 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: highlevel encoder setup struct seperated out for vorbisenc clarity
- last mod: $Id: highlevel.h 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 typedef struct highlevel_byblocktype {
   double tone_mask_setting;
   double tone_peaklimit_setting;
   double noise_bias_setting;
   double noise_compand_setting;
 } highlevel_byblocktype;
   
 typedef struct highlevel_encode_setup {
-  void *setup;
+  const void *setup;
   int   set_in_stone;
 
   double base_setting;
   double long_setting;
   double short_setting;
   double impulse_noisetune;
 
   int    managed;
--- a/media/libvorbis/lib/lookup.h
+++ b/media/libvorbis/lib/lookup.h
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
   function: lookup based functions
-  last mod: $Id: lookup.h 13293 2007-07-24 00:09:47Z xiphmont $
+  last mod: $Id$
 
  ********************************************************************/
 
 #ifndef _V_LOOKUP_H_
 
 #ifdef FLOAT_LOOKUP
 extern float vorbis_coslook(float a);
 extern float vorbis_invsqlook(float a);
--- a/media/libvorbis/lib/lookup_data.h
+++ b/media/libvorbis/lib/lookup_data.h
@@ -6,184 +6,187 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
   function: lookup data; generated by lookups.pl; edit there
-  last mod: $Id: lookup_data.h 13293 2007-07-24 00:09:47Z xiphmont $
+  last mod: $Id$
 
  ********************************************************************/
 
 #ifndef _V_LOOKUP_DATA_H_
 
 #ifdef FLOAT_LOOKUP
 #define COS_LOOKUP_SZ 128
-static float COS_LOOKUP[COS_LOOKUP_SZ+1]={
-	+1.0000000000000f,+0.9996988186962f,+0.9987954562052f,+0.9972904566787f,
-	+0.9951847266722f,+0.9924795345987f,+0.9891765099648f,+0.9852776423889f,
-	+0.9807852804032f,+0.9757021300385f,+0.9700312531945f,+0.9637760657954f,
-	+0.9569403357322f,+0.9495281805930f,+0.9415440651830f,+0.9329927988347f,
-	+0.9238795325113f,+0.9142097557035f,+0.9039892931234f,+0.8932243011955f,
-	+0.8819212643484f,+0.8700869911087f,+0.8577286100003f,+0.8448535652497f,
-	+0.8314696123025f,+0.8175848131516f,+0.8032075314806f,+0.7883464276266f,
-	+0.7730104533627f,+0.7572088465065f,+0.7409511253550f,+0.7242470829515f,
-	+0.7071067811865f,+0.6895405447371f,+0.6715589548470f,+0.6531728429538f,
-	+0.6343932841636f,+0.6152315905806f,+0.5956993044924f,+0.5758081914178f,
-	+0.5555702330196f,+0.5349976198871f,+0.5141027441932f,+0.4928981922298f,
-	+0.4713967368260f,+0.4496113296546f,+0.4275550934303f,+0.4052413140050f,
-	+0.3826834323651f,+0.3598950365350f,+0.3368898533922f,+0.3136817403989f,
-	+0.2902846772545f,+0.2667127574749f,+0.2429801799033f,+0.2191012401569f,
-	+0.1950903220161f,+0.1709618887603f,+0.1467304744554f,+0.1224106751992f,
-	+0.0980171403296f,+0.0735645635997f,+0.0490676743274f,+0.0245412285229f,
-	+0.0000000000000f,-0.0245412285229f,-0.0490676743274f,-0.0735645635997f,
-	-0.0980171403296f,-0.1224106751992f,-0.1467304744554f,-0.1709618887603f,
-	-0.1950903220161f,-0.2191012401569f,-0.2429801799033f,-0.2667127574749f,
-	-0.2902846772545f,-0.3136817403989f,-0.3368898533922f,-0.3598950365350f,
-	-0.3826834323651f,-0.4052413140050f,-0.4275550934303f,-0.4496113296546f,
-	-0.4713967368260f,-0.4928981922298f,-0.5141027441932f,-0.5349976198871f,
-	-0.5555702330196f,-0.5758081914178f,-0.5956993044924f,-0.6152315905806f,
-	-0.6343932841636f,-0.6531728429538f,-0.6715589548470f,-0.6895405447371f,
-	-0.7071067811865f,-0.7242470829515f,-0.7409511253550f,-0.7572088465065f,
-	-0.7730104533627f,-0.7883464276266f,-0.8032075314806f,-0.8175848131516f,
-	-0.8314696123025f,-0.8448535652497f,-0.8577286100003f,-0.8700869911087f,
-	-0.8819212643484f,-0.8932243011955f,-0.9039892931234f,-0.9142097557035f,
-	-0.9238795325113f,-0.9329927988347f,-0.9415440651830f,-0.9495281805930f,
-	-0.9569403357322f,-0.9637760657954f,-0.9700312531945f,-0.9757021300385f,
-	-0.9807852804032f,-0.9852776423889f,-0.9891765099648f,-0.9924795345987f,
-	-0.9951847266722f,-0.9972904566787f,-0.9987954562052f,-0.9996988186962f,
-	-1.0000000000000f,
+static const float COS_LOOKUP[COS_LOOKUP_SZ+1]={
+        +1.0000000000000f,+0.9996988186962f,+0.9987954562052f,+0.9972904566787f,
+        +0.9951847266722f,+0.9924795345987f,+0.9891765099648f,+0.9852776423889f,
+        +0.9807852804032f,+0.9757021300385f,+0.9700312531945f,+0.9637760657954f,
+        +0.9569403357322f,+0.9495281805930f,+0.9415440651830f,+0.9329927988347f,
+        +0.9238795325113f,+0.9142097557035f,+0.9039892931234f,+0.8932243011955f,
+        +0.8819212643484f,+0.8700869911087f,+0.8577286100003f,+0.8448535652497f,
+        +0.8314696123025f,+0.8175848131516f,+0.8032075314806f,+0.7883464276266f,
+        +0.7730104533627f,+0.7572088465065f,+0.7409511253550f,+0.7242470829515f,
+        +0.7071067811865f,+0.6895405447371f,+0.6715589548470f,+0.6531728429538f,
+        +0.6343932841636f,+0.6152315905806f,+0.5956993044924f,+0.5758081914178f,
+        +0.5555702330196f,+0.5349976198871f,+0.5141027441932f,+0.4928981922298f,
+        +0.4713967368260f,+0.4496113296546f,+0.4275550934303f,+0.4052413140050f,
+        +0.3826834323651f,+0.3598950365350f,+0.3368898533922f,+0.3136817403989f,
+        +0.2902846772545f,+0.2667127574749f,+0.2429801799033f,+0.2191012401569f,
+        +0.1950903220161f,+0.1709618887603f,+0.1467304744554f,+0.1224106751992f,
+        +0.0980171403296f,+0.0735645635997f,+0.0490676743274f,+0.0245412285229f,
+        +0.0000000000000f,-0.0245412285229f,-0.0490676743274f,-0.0735645635997f,
+        -0.0980171403296f,-0.1224106751992f,-0.1467304744554f,-0.1709618887603f,
+        -0.1950903220161f,-0.2191012401569f,-0.2429801799033f,-0.2667127574749f,
+        -0.2902846772545f,-0.3136817403989f,-0.3368898533922f,-0.3598950365350f,
+        -0.3826834323651f,-0.4052413140050f,-0.4275550934303f,-0.4496113296546f,
+        -0.4713967368260f,-0.4928981922298f,-0.5141027441932f,-0.5349976198871f,
+        -0.5555702330196f,-0.5758081914178f,-0.5956993044924f,-0.6152315905806f,
+        -0.6343932841636f,-0.6531728429538f,-0.6715589548470f,-0.6895405447371f,
+        -0.7071067811865f,-0.7242470829515f,-0.7409511253550f,-0.7572088465065f,
+        -0.7730104533627f,-0.7883464276266f,-0.8032075314806f,-0.8175848131516f,
+        -0.8314696123025f,-0.8448535652497f,-0.8577286100003f,-0.8700869911087f,
+        -0.8819212643484f,-0.8932243011955f,-0.9039892931234f,-0.9142097557035f,
+        -0.9238795325113f,-0.9329927988347f,-0.9415440651830f,-0.9495281805930f,
+        -0.9569403357322f,-0.9637760657954f,-0.9700312531945f,-0.9757021300385f,
+        -0.9807852804032f,-0.9852776423889f,-0.9891765099648f,-0.9924795345987f,
+        -0.9951847266722f,-0.9972904566787f,-0.9987954562052f,-0.9996988186962f,
+        -1.0000000000000f,
 };
 
 #define INVSQ_LOOKUP_SZ 32
-static float INVSQ_LOOKUP[INVSQ_LOOKUP_SZ+1]={
-	1.414213562373f,1.392621247646f,1.371988681140f,1.352246807566f,
-	1.333333333333f,1.315191898443f,1.297771369046f,1.281025230441f,
-	1.264911064067f,1.249390095109f,1.234426799697f,1.219988562661f,
-	1.206045378311f,1.192569588000f,1.179535649239f,1.166919931983f,
-	1.154700538379f,1.142857142857f,1.131370849898f,1.120224067222f,
-	1.109400392450f,1.098884511590f,1.088662107904f,1.078719779941f,
-	1.069044967650f,1.059625885652f,1.050451462878f,1.041511287847f,
-	1.032795558989f,1.024295039463f,1.016001016002f,1.007905261358f,
-	1.000000000000f,
+static const float INVSQ_LOOKUP[INVSQ_LOOKUP_SZ+1]={
+        1.414213562373f,1.392621247646f,1.371988681140f,1.352246807566f,
+        1.333333333333f,1.315191898443f,1.297771369046f,1.281025230441f,
+        1.264911064067f,1.249390095109f,1.234426799697f,1.219988562661f,
+        1.206045378311f,1.192569588000f,1.179535649239f,1.166919931983f,
+        1.154700538379f,1.142857142857f,1.131370849898f,1.120224067222f,
+        1.109400392450f,1.098884511590f,1.088662107904f,1.078719779941f,
+        1.069044967650f,1.059625885652f,1.050451462878f,1.041511287847f,
+        1.032795558989f,1.024295039463f,1.016001016002f,1.007905261358f,
+        1.000000000000f,
 };
 
 #define INVSQ2EXP_LOOKUP_MIN (-32)
 #define INVSQ2EXP_LOOKUP_MAX 32
-static float INVSQ2EXP_LOOKUP[INVSQ2EXP_LOOKUP_MAX-\
+static const float INVSQ2EXP_LOOKUP[INVSQ2EXP_LOOKUP_MAX-\
                               INVSQ2EXP_LOOKUP_MIN+1]={
-	         65536.f,    46340.95001f,         32768.f,    23170.47501f,
-	         16384.f,     11585.2375f,          8192.f,    5792.618751f,
-	          4096.f,    2896.309376f,          2048.f,    1448.154688f,
-	          1024.f,    724.0773439f,           512.f,     362.038672f,
-	           256.f,     181.019336f,           128.f,    90.50966799f,
-	            64.f,      45.254834f,            32.f,      22.627417f,
-	            16.f,     11.3137085f,             8.f,    5.656854249f,
-	             4.f,    2.828427125f,             2.f,    1.414213562f,
-	             1.f,   0.7071067812f,            0.5f,   0.3535533906f,
-	           0.25f,   0.1767766953f,          0.125f,  0.08838834765f,
-	         0.0625f,  0.04419417382f,        0.03125f,  0.02209708691f,
-	       0.015625f,  0.01104854346f,      0.0078125f, 0.005524271728f,
-	     0.00390625f, 0.002762135864f,    0.001953125f, 0.001381067932f,
-	   0.0009765625f, 0.000690533966f,  0.00048828125f, 0.000345266983f,
-	 0.000244140625f,0.0001726334915f,0.0001220703125f,8.631674575e-05f,
-	6.103515625e-05f,4.315837288e-05f,3.051757812e-05f,2.157918644e-05f,
-	1.525878906e-05f,
+                 65536.f,    46340.95001f,         32768.f,    23170.47501f,
+                 16384.f,     11585.2375f,          8192.f,    5792.618751f,
+                  4096.f,    2896.309376f,          2048.f,    1448.154688f,
+                  1024.f,    724.0773439f,           512.f,     362.038672f,
+                   256.f,     181.019336f,           128.f,    90.50966799f,
+                    64.f,      45.254834f,            32.f,      22.627417f,
+                    16.f,     11.3137085f,             8.f,    5.656854249f,
+                     4.f,    2.828427125f,             2.f,    1.414213562f,
+                     1.f,   0.7071067812f,            0.5f,   0.3535533906f,
+                   0.25f,   0.1767766953f,          0.125f,  0.08838834765f,
+                 0.0625f,  0.04419417382f,        0.03125f,  0.02209708691f,
+               0.015625f,  0.01104854346f,      0.0078125f, 0.005524271728f,
+             0.00390625f, 0.002762135864f,    0.001953125f, 0.001381067932f,
+           0.0009765625f, 0.000690533966f,  0.00048828125f, 0.000345266983f,
+         0.000244140625f,0.0001726334915f,0.0001220703125f,8.631674575e-05f,
+        6.103515625e-05f,4.315837288e-05f,3.051757812e-05f,2.157918644e-05f,
+        1.525878906e-05f,
 };
 
 #endif
 
 #define FROMdB_LOOKUP_SZ 35
 #define FROMdB2_LOOKUP_SZ 32
 #define FROMdB_SHIFT 5
 #define FROMdB2_SHIFT 3
 #define FROMdB2_MASK 31
-static float FROMdB_LOOKUP[FROMdB_LOOKUP_SZ]={
-	             1.f,   0.6309573445f,   0.3981071706f,   0.2511886432f,
-	   0.1584893192f,            0.1f,  0.06309573445f,  0.03981071706f,
-	  0.02511886432f,  0.01584893192f,           0.01f, 0.006309573445f,
-	 0.003981071706f, 0.002511886432f, 0.001584893192f,          0.001f,
-	0.0006309573445f,0.0003981071706f,0.0002511886432f,0.0001584893192f,
-	         0.0001f,6.309573445e-05f,3.981071706e-05f,2.511886432e-05f,
-	1.584893192e-05f,          1e-05f,6.309573445e-06f,3.981071706e-06f,
-	2.511886432e-06f,1.584893192e-06f,          1e-06f,6.309573445e-07f,
-	3.981071706e-07f,2.511886432e-07f,1.584893192e-07f,
+
+#ifdef FLOAT_LOOKUP
+static const float FROMdB_LOOKUP[FROMdB_LOOKUP_SZ]={
+                     1.f,   0.6309573445f,   0.3981071706f,   0.2511886432f,
+           0.1584893192f,            0.1f,  0.06309573445f,  0.03981071706f,
+          0.02511886432f,  0.01584893192f,           0.01f, 0.006309573445f,
+         0.003981071706f, 0.002511886432f, 0.001584893192f,          0.001f,
+        0.0006309573445f,0.0003981071706f,0.0002511886432f,0.0001584893192f,
+                 0.0001f,6.309573445e-05f,3.981071706e-05f,2.511886432e-05f,
+        1.584893192e-05f,          1e-05f,6.309573445e-06f,3.981071706e-06f,
+        2.511886432e-06f,1.584893192e-06f,          1e-06f,6.309573445e-07f,
+        3.981071706e-07f,2.511886432e-07f,1.584893192e-07f,
 };
 
-static float FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ]={
-	   0.9928302478f,   0.9786445908f,   0.9646616199f,   0.9508784391f,
-	   0.9372921937f,     0.92390007f,   0.9106992942f,   0.8976871324f,
-	   0.8848608897f,   0.8722179097f,   0.8597555737f,   0.8474713009f,
-	    0.835362547f,   0.8234268041f,   0.8116616003f,   0.8000644989f,
-	   0.7886330981f,   0.7773650302f,   0.7662579617f,    0.755309592f,
-	   0.7445176537f,   0.7338799116f,   0.7233941627f,   0.7130582353f,
-	   0.7028699885f,   0.6928273125f,   0.6829281272f,   0.6731703824f,
-	   0.6635520573f,   0.6540711597f,   0.6447257262f,   0.6355138211f,
+static const float FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ]={
+           0.9928302478f,   0.9786445908f,   0.9646616199f,   0.9508784391f,
+           0.9372921937f,     0.92390007f,   0.9106992942f,   0.8976871324f,
+           0.8848608897f,   0.8722179097f,   0.8597555737f,   0.8474713009f,
+            0.835362547f,   0.8234268041f,   0.8116616003f,   0.8000644989f,
+           0.7886330981f,   0.7773650302f,   0.7662579617f,    0.755309592f,
+           0.7445176537f,   0.7338799116f,   0.7233941627f,   0.7130582353f,
+           0.7028699885f,   0.6928273125f,   0.6829281272f,   0.6731703824f,
+           0.6635520573f,   0.6540711597f,   0.6447257262f,   0.6355138211f,
 };
+#endif
 
 #ifdef INT_LOOKUP
 
 #define INVSQ_LOOKUP_I_SHIFT 10
 #define INVSQ_LOOKUP_I_MASK 1023
-static long INVSQ_LOOKUP_I[64+1]={
-	   92682l,   91966l,   91267l,   90583l,
-	   89915l,   89261l,   88621l,   87995l,
-	   87381l,   86781l,   86192l,   85616l,
-	   85051l,   84497l,   83953l,   83420l,
-	   82897l,   82384l,   81880l,   81385l,
-	   80899l,   80422l,   79953l,   79492l,
-	   79039l,   78594l,   78156l,   77726l,
-	   77302l,   76885l,   76475l,   76072l,
-	   75674l,   75283l,   74898l,   74519l,
-	   74146l,   73778l,   73415l,   73058l,
-	   72706l,   72359l,   72016l,   71679l,
-	   71347l,   71019l,   70695l,   70376l,
-	   70061l,   69750l,   69444l,   69141l,
-	   68842l,   68548l,   68256l,   67969l,
-	   67685l,   67405l,   67128l,   66855l,
-	   66585l,   66318l,   66054l,   65794l,
-	   65536l,
+static const long INVSQ_LOOKUP_I[64+1]={
+           92682l,   91966l,   91267l,   90583l,
+           89915l,   89261l,   88621l,   87995l,
+           87381l,   86781l,   86192l,   85616l,
+           85051l,   84497l,   83953l,   83420l,
+           82897l,   82384l,   81880l,   81385l,
+           80899l,   80422l,   79953l,   79492l,
+           79039l,   78594l,   78156l,   77726l,
+           77302l,   76885l,   76475l,   76072l,
+           75674l,   75283l,   74898l,   74519l,
+           74146l,   73778l,   73415l,   73058l,
+           72706l,   72359l,   72016l,   71679l,
+           71347l,   71019l,   70695l,   70376l,
+           70061l,   69750l,   69444l,   69141l,
+           68842l,   68548l,   68256l,   67969l,
+           67685l,   67405l,   67128l,   66855l,
+           66585l,   66318l,   66054l,   65794l,
+           65536l,
 };
 
 #define COS_LOOKUP_I_SHIFT 9
 #define COS_LOOKUP_I_MASK 511
 #define COS_LOOKUP_I_SZ 128
-static long COS_LOOKUP_I[COS_LOOKUP_I_SZ+1]={
-	   16384l,   16379l,   16364l,   16340l,
-	   16305l,   16261l,   16207l,   16143l,
-	   16069l,   15986l,   15893l,   15791l,
-	   15679l,   15557l,   15426l,   15286l,
-	   15137l,   14978l,   14811l,   14635l,
-	   14449l,   14256l,   14053l,   13842l,
-	   13623l,   13395l,   13160l,   12916l,
-	   12665l,   12406l,   12140l,   11866l,
-	   11585l,   11297l,   11003l,   10702l,
-	   10394l,   10080l,    9760l,    9434l,
-	    9102l,    8765l,    8423l,    8076l,
-	    7723l,    7366l,    7005l,    6639l,
-	    6270l,    5897l,    5520l,    5139l,
-	    4756l,    4370l,    3981l,    3590l,
-	    3196l,    2801l,    2404l,    2006l,
-	    1606l,    1205l,     804l,     402l,
-	       0l,    -401l,    -803l,   -1204l,
-	   -1605l,   -2005l,   -2403l,   -2800l,
-	   -3195l,   -3589l,   -3980l,   -4369l,
-	   -4755l,   -5138l,   -5519l,   -5896l,
-	   -6269l,   -6638l,   -7004l,   -7365l,
-	   -7722l,   -8075l,   -8422l,   -8764l,
-	   -9101l,   -9433l,   -9759l,  -10079l,
-	  -10393l,  -10701l,  -11002l,  -11296l,
-	  -11584l,  -11865l,  -12139l,  -12405l,
-	  -12664l,  -12915l,  -13159l,  -13394l,
-	  -13622l,  -13841l,  -14052l,  -14255l,
-	  -14448l,  -14634l,  -14810l,  -14977l,
-	  -15136l,  -15285l,  -15425l,  -15556l,
-	  -15678l,  -15790l,  -15892l,  -15985l,
-	  -16068l,  -16142l,  -16206l,  -16260l,
-	  -16304l,  -16339l,  -16363l,  -16378l,
-	  -16383l,
+static const long COS_LOOKUP_I[COS_LOOKUP_I_SZ+1]={
+           16384l,   16379l,   16364l,   16340l,
+           16305l,   16261l,   16207l,   16143l,
+           16069l,   15986l,   15893l,   15791l,
+           15679l,   15557l,   15426l,   15286l,
+           15137l,   14978l,   14811l,   14635l,
+           14449l,   14256l,   14053l,   13842l,
+           13623l,   13395l,   13160l,   12916l,
+           12665l,   12406l,   12140l,   11866l,
+           11585l,   11297l,   11003l,   10702l,
+           10394l,   10080l,    9760l,    9434l,
+            9102l,    8765l,    8423l,    8076l,
+            7723l,    7366l,    7005l,    6639l,
+            6270l,    5897l,    5520l,    5139l,
+            4756l,    4370l,    3981l,    3590l,
+            3196l,    2801l,    2404l,    2006l,
+            1606l,    1205l,     804l,     402l,
+               0l,    -401l,    -803l,   -1204l,
+           -1605l,   -2005l,   -2403l,   -2800l,
+           -3195l,   -3589l,   -3980l,   -4369l,
+           -4755l,   -5138l,   -5519l,   -5896l,
+           -6269l,   -6638l,   -7004l,   -7365l,
+           -7722l,   -8075l,   -8422l,   -8764l,
+           -9101l,   -9433l,   -9759l,  -10079l,
+          -10393l,  -10701l,  -11002l,  -11296l,
+          -11584l,  -11865l,  -12139l,  -12405l,
+          -12664l,  -12915l,  -13159l,  -13394l,
+          -13622l,  -13841l,  -14052l,  -14255l,
+          -14448l,  -14634l,  -14810l,  -14977l,
+          -15136l,  -15285l,  -15425l,  -15556l,
+          -15678l,  -15790l,  -15892l,  -15985l,
+          -16068l,  -16142l,  -16206l,  -16260l,
+          -16304l,  -16339l,  -16363l,  -16378l,
+          -16383l,
 };
 
 #endif
 
 #endif
--- a/media/libvorbis/lib/lpc.h
+++ b/media/libvorbis/lib/lpc.h
@@ -6,24 +6,24 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
   function: LPC low level routines
-  last mod: $Id: lpc.h 13293 2007-07-24 00:09:47Z xiphmont $
+  last mod: $Id$
 
  ********************************************************************/
 
 #ifndef _V_LPC_H_
 #define _V_LPC_H_
 
 #include "vorbis/codec.h"
 
 /* simple linear scale LPC code */
 extern float vorbis_lpc_from_data(float *data,float *lpc,int n,int m);
 
 extern void vorbis_lpc_predict(float *coeff,float *prime,int m,
-			       float *data,long n);
+                               float *data,long n);
 
 #endif
--- a/media/libvorbis/lib/lsp.h
+++ b/media/libvorbis/lib/lsp.h
@@ -6,23 +6,23 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
   function: LSP (also called LSF) conversion routines
-  last mod: $Id: lsp.h 13293 2007-07-24 00:09:47Z xiphmont $
+  last mod: $Id$
 
  ********************************************************************/
 
 
 #ifndef _V_LSP_H_
 #define _V_LSP_H_
 
 extern int vorbis_lpc_to_lsp(float *lpc,float *lsp,int m);
 
 extern void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,
-				float *lsp,int m,
-				float amp,float ampoffset);
+                                float *lsp,int m,
+                                float amp,float ampoffset);
   
 #endif
--- a/media/libvorbis/lib/masking.h
+++ b/media/libvorbis/lib/masking.h
@@ -6,28 +6,28 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: masking curve data for psychoacoustics
- last mod: $Id: masking.h 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #ifndef _V_MASKING_H_
 #define _V_MASKING_H_
 
 /* more detailed ATH; the bass if flat to save stressing the floor
    overly for only a bin or two of savings. */
 
 #define MAX_ATH 88
-static float ATH[]={
+static const float ATH[]={
   /*15*/  -51, -52, -53, -54, -55, -56, -57, -58,  
   /*31*/  -59, -60, -61, -62, -63, -64, -65, -66,
   /*63*/  -67, -68, -69, -70, -71, -72, -73, -74, 
   /*125*/ -75, -76, -77, -78, -80, -81, -82, -83,
   /*250*/ -84, -85, -86, -87, -88, -88, -89, -89, 
   /*500*/ -90, -91, -91, -92, -93, -94, -95, -96,
   /*1k*/  -96, -97, -98, -98, -99, -99,-100,-100,
   /*2k*/ -101,-102,-103,-104,-106,-107,-107,-107,
@@ -43,17 +43,17 @@ static float ATH[]={
 #define EHMER_OFFSET 16
 #define EHMER_MAX 56
 
 /* masking tones from -50 to 0dB, 62.5 through 16kHz at half octaves
    test tones from -2 octaves to +5 octaves sampled at eighth octaves */
 /* (Vorbis 0dB, the loudest possible tone, is assumed to be ~100dB SPL
    for collection of these curves) */
 
-static float tonemasks[P_BANDS][6][EHMER_MAX]={
+static const float tonemasks[P_BANDS][6][EHMER_MAX]={
   /* 62.5 Hz */
   {{ -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60, 
      -60,  -60,  -60,  -60,  -62,  -62,  -65,  -73, 
      -69,  -68,  -68,  -67,  -70,  -70,  -72,  -74, 
      -75,  -79,  -79,  -80,  -83,  -88,  -93, -100, 
      -110, -999, -999, -999, -999, -999, -999, -999, 
      -999, -999, -999, -999, -999, -999, -999, -999, 
      -999, -999, -999, -999, -999, -999, -999, -999},
--- a/media/libvorbis/lib/mdct.h
+++ b/media/libvorbis/lib/mdct.h
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: modified discrete cosine transform prototypes
- last mod: $Id: mdct.h 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #ifndef _OGG_mdct_H_
 #define _OGG_mdct_H_
 
 #include "vorbis/codec.h"
 
--- a/media/libvorbis/lib/misc.h
+++ b/media/libvorbis/lib/misc.h
@@ -6,34 +6,35 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: miscellaneous prototypes
- last mod: $Id: misc.h 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #ifndef _V_RANDOM_H_
 #define _V_RANDOM_H_
 #include "vorbis/codec.h"
 
 extern int analysis_noisy;
 
 extern void *_vorbis_block_alloc(vorbis_block *vb,long bytes);
 extern void _vorbis_block_ripcord(vorbis_block *vb);
 extern void _analysis_output(char *base,int i,float *v,int n,int bark,int dB,
-			     ogg_int64_t off);
+                             ogg_int64_t off);
 
 #ifdef DEBUG_MALLOC
 
 #define _VDBG_GRAPHFILE "malloc.m"
+#undef _VDBG_GRAPHFILE
 extern void *_VDBG_malloc(void *ptr,long bytes,char *file,long line); 
 extern void _VDBG_free(void *ptr,char *file,long line); 
 
 #ifndef MISC_C 
 #undef _ogg_malloc
 #undef _ogg_calloc
 #undef _ogg_realloc
 #undef _ogg_free
--- a/media/libvorbis/lib/os.h
+++ b/media/libvorbis/lib/os.h
@@ -8,17 +8,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: #ifdef jail to whip a few platforms into the UNIX ideal.
- last mod: $Id: os.h 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <math.h>
@@ -78,83 +78,113 @@ void *_alloca(size_t size);
 #ifndef min
 #  define min(x,y)  ((x)>(y)?(y):(x))
 #endif
 
 #ifndef max
 #  define max(x,y)  ((x)<(y)?(y):(x))
 #endif
 
-#if defined(__i386__) && defined(__GNUC__) && !defined(__BEOS__) && !defined(WINCE)
+
+/* Special i386 GCC implementation */
+#if defined(__i386__) && defined(__GNUC__) && !defined(__BEOS__)
 #  define VORBIS_FPU_CONTROL
 /* both GCC and MSVC are kinda stupid about rounding/casting to int.
    Because of encapsulation constraints (GCC can't see inside the asm
    block and so we end up doing stupid things like a store/load that
    is collectively a noop), we do it this way */
 
 /* we must set up the fpu before this works!! */
 
 typedef ogg_int16_t vorbis_fpu_control;
 
 static inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){
   ogg_int16_t ret;
   ogg_int16_t temp;
   __asm__ __volatile__("fnstcw %0\n\t"
-	  "movw %0,%%dx\n\t"
-	  "orw $62463,%%dx\n\t"
-	  "movw %%dx,%1\n\t"
-	  "fldcw %1\n\t":"=m"(ret):"m"(temp): "dx");
+          "movw %0,%%dx\n\t"
+          "orw $62463,%%dx\n\t"
+          "movw %%dx,%1\n\t"
+          "fldcw %1\n\t":"=m"(ret):"m"(temp): "dx");
   *fpu=ret;
 }
 
 static inline void vorbis_fpu_restore(vorbis_fpu_control fpu){
   __asm__ __volatile__("fldcw %0":: "m"(fpu));
 }
 
 /* assumes the FPU is in round mode! */
 static inline int vorbis_ftoi(double f){  /* yes, double!  Otherwise,
                                              we get extra fst/fld to
                                              truncate precision */
   int i;
   __asm__("fistl %0": "=m"(i) : "t"(f));
   return(i);
 }
-#endif
+#endif /* Special i386 GCC implementation */
 
 
-#if defined(_WIN32) && !defined(__GNUC__) && !defined(__BORLANDC__) && !defined(WINCE)
+/* MSVC inline assembly. 32 bit only; inline ASM isn't implemented in the
+ * 64 bit compiler */
+#if defined(_MSC_VER) && !defined(_WIN64) && !defined(_WIN32_WCE)
 #  define VORBIS_FPU_CONTROL
 
 typedef ogg_int16_t vorbis_fpu_control;
 
 static __inline int vorbis_ftoi(double f){
-	int i;
-	__asm{
-		fld f
-		fistp i
-	}
-	return i;
+        int i;
+        __asm{
+                fld f
+                fistp i
+        }
+        return i;
 }
 
 static __inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){
 }
 
 static __inline void vorbis_fpu_restore(vorbis_fpu_control fpu){
 }
 
-#endif
+#endif /* Special MSVC 32 bit implementation */
 
 
+/* Optimized code path for x86_64 builds. Uses SSE2 intrinsics. This can be
+   done safely because all x86_64 CPUs supports SSE2. */
+#if (defined(_MSC_VER) && defined(_WIN64)) || (defined(__GNUC__) && defined (__x86_64__))
+#  define VORBIS_FPU_CONTROL
+
+typedef ogg_int16_t vorbis_fpu_control;
+
+#include <emmintrin.h>
+static __inline int vorbis_ftoi(double f){
+        return _mm_cvtsd_si32(_mm_load_sd(&f));
+}
+
+static __inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){
+}
+
+static __inline void vorbis_fpu_restore(vorbis_fpu_control fpu){
+}
+
+#endif /* Special MSVC x64 implementation */
+
+
+/* If no special implementation was found for the current compiler / platform,
+   use the default implementation here: */
 #ifndef VORBIS_FPU_CONTROL
 
 typedef int vorbis_fpu_control;
 
 static int vorbis_ftoi(double f){
-  return (int)(f+.5);
+        /* Note: MSVC and GCC (at least on some systems) round towards zero, thus,
+           the floor() call is required to ensure correct roudning of
+           negative numbers */
+        return (int)floor(f+.5);
 }
 
 /* We don't have special code for this compiler/arch, so do it the slow way */
 #  define vorbis_fpu_setround(vorbis_fpu_control) {}
 #  define vorbis_fpu_restore(vorbis_fpu_control) {}
 
-#endif
+#endif /* default implementation */
 
 #endif /* _OS_H */
--- a/media/libvorbis/lib/psy.h
+++ b/media/libvorbis/lib/psy.h
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: random psychoacoustics (not including preecho)
- last mod: $Id: psy.h 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #ifndef _V_PSY_H_
 #define _V_PSY_H_
 #include "smallft.h"
 
 #include "backends.h"
@@ -110,77 +110,77 @@ typedef struct {
   int   total_octave_lines;  
   long  rate; /* cache it */
 
   float m_val; /* Masking compensation value */
 
 } vorbis_look_psy;
 
 extern void   _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,
-			   vorbis_info_psy_global *gi,int n,long rate);
+                           vorbis_info_psy_global *gi,int n,long rate);
 extern void   _vp_psy_clear(vorbis_look_psy *p);
 extern void  *_vi_psy_dup(void *source);
 
 extern void   _vi_psy_free(vorbis_info_psy *i);
 extern vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i);
 
 extern void _vp_remove_floor(vorbis_look_psy *p,
-			     float *mdct,
-			     int *icodedflr,
-			     float *residue,
-			     int sliding_lowpass);
+                             float *mdct,
+                             int *icodedflr,
+                             float *residue,
+                             int sliding_lowpass);
 
 extern void _vp_noisemask(vorbis_look_psy *p,
-			  float *logmdct, 
-			  float *logmask);
+                          float *logmdct, 
+                          float *logmask);
 
 extern void _vp_tonemask(vorbis_look_psy *p,
-			 float *logfft,
-			 float *logmask,
-			 float global_specmax,
-			 float local_specmax);
+                         float *logfft,
+                         float *logmask,
+                         float global_specmax,
+                         float local_specmax);
 
 extern void _vp_offset_and_mix(vorbis_look_psy *p,
-			       float *noise,
-			       float *tone,
-			       int offset_select,
-			       float *logmask,
-			       float *mdct,
-			       float *logmdct);
+                               float *noise,
+                               float *tone,
+                               int offset_select,
+                               float *logmask,
+                               float *mdct,
+                               float *logmdct);
 
 extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd);
 
 extern float **_vp_quantize_couple_memo(vorbis_block *vb,
-					vorbis_info_psy_global *g,
-					vorbis_look_psy *p,
-					vorbis_info_mapping0 *vi,
-					float **mdct);
+                                        vorbis_info_psy_global *g,
+                                        vorbis_look_psy *p,
+                                        vorbis_info_mapping0 *vi,
+                                        float **mdct);
 
 extern void _vp_couple(int blobno,
-		       vorbis_info_psy_global *g,
-		       vorbis_look_psy *p,
-		       vorbis_info_mapping0 *vi,
-		       float **res,
-		       float **mag_memo,
-		       int   **mag_sort,
-		       int   **ifloor,
-		       int   *nonzero,
-		       int   sliding_lowpass);
+                       vorbis_info_psy_global *g,
+                       vorbis_look_psy *p,
+                       vorbis_info_mapping0 *vi,
+                       float **res,
+                       float **mag_memo,
+                       int   **mag_sort,
+                       int   **ifloor,
+                       int   *nonzero,
+                       int   sliding_lowpass);
 
 extern void _vp_noise_normalize(vorbis_look_psy *p,
-				float *in,float *out,int *sortedindex);
+                                float *in,float *out,int *sortedindex);
 
 extern void _vp_noise_normalize_sort(vorbis_look_psy *p,
-				     float *magnitudes,int *sortedindex);
+                                     float *magnitudes,int *sortedindex);
 
 extern int **_vp_quantize_couple_sort(vorbis_block *vb,
-				      vorbis_look_psy *p,
-				      vorbis_info_mapping0 *vi,
-				      float **mags);
+                                      vorbis_look_psy *p,
+                                      vorbis_info_mapping0 *vi,
+                                      float **mags);
 
 extern void hf_reduction(vorbis_info_psy_global *g,
-			 vorbis_look_psy *p,
-			 vorbis_info_mapping0 *vi,
-			 float **mdct);
+                         vorbis_look_psy *p,
+                         vorbis_info_mapping0 *vi,
+                         float **mdct);
 
 
 #endif
 
--- a/media/libvorbis/lib/registry.h
+++ b/media/libvorbis/lib/registry.h
@@ -6,27 +6,27 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: registry for time, floor, res backends and channel mappings
- last mod: $Id: registry.h 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #ifndef _V_REG_H_
 #define _V_REG_H_
 
 #define VI_TRANSFORMB 1
 #define VI_WINDOWB 1
 #define VI_TIMEB 1
 #define VI_FLOORB 2
 #define VI_RESB 3
 #define VI_MAPB 1
 
-extern vorbis_func_floor     *_floor_P[];
-extern vorbis_func_residue   *_residue_P[];
-extern vorbis_func_mapping   *_mapping_P[];
+extern const vorbis_func_floor     *const _floor_P[];
+extern const vorbis_func_residue   *const _residue_P[];
+extern const vorbis_func_mapping   *const _mapping_P[];
 
 #endif
--- a/media/libvorbis/lib/scales.h
+++ b/media/libvorbis/lib/scales.h
@@ -6,42 +6,47 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: linear scale -> dB, Bark and Mel scales
- last mod: $Id: scales.h 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #ifndef _V_SCALES_H_
 #define _V_SCALES_H_
 
 #include <math.h>
 #include "os.h"
 
+#ifdef _MSC_VER
+/* MS Visual Studio doesn't have C99 inline keyword. */
+#define inline __inline
+#endif
+
 /* 20log10(x) */
 #define VORBIS_IEEE_FLOAT32 1
 #ifdef VORBIS_IEEE_FLOAT32
 
-static float unitnorm(float x){
+static inline float unitnorm(float x){
   union {
     ogg_uint32_t i;
     float f;
   } ix;
   ix.f = x;
   ix.i = (ix.i & 0x80000000U) | (0x3f800000U);
   return ix.f;
 }
 
 /* Segher was off (too high) by ~ .3 decibel.  Center the conversion correctly. */
-static float todB(const float *x){
+static inline float todB(const float *x){
   union {
     ogg_uint32_t i;
     float f;
   } ix;
   ix.f = *x;
   ix.i = ix.i&0x7fffffff;
   return (float)(ix.i * 7.17711438e-7f -764.6161886f);
 }
--- a/media/libvorbis/lib/smallft.h
+++ b/media/libvorbis/lib/smallft.h
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: fft transform
- last mod: $Id: smallft.h 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #ifndef _V_SMFT_H_
 #define _V_SMFT_H_
 
 #include "vorbis/codec.h"
 
--- a/media/libvorbis/lib/vorbis_analysis.c
+++ b/media/libvorbis/lib/vorbis_analysis.c
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: single-block PCM analysis mode dispatch
- last mod: $Id: analysis.c 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #include <stdio.h>
 #include <string.h>
 #include <math.h>
 #include <ogg/ogg.h>
 #include "vorbis/codec.h"
@@ -62,53 +62,55 @@ int vorbis_analysis(vorbis_block *vb, og
     op->granulepos=vb->granulepos;
     op->packetno=vb->sequence; /* for sake of completeness */
   }
   return(0);
 }
 
 /* there was no great place to put this.... */
 void _analysis_output_always(char *base,int i,float *v,int n,int bark,int dB,ogg_int64_t off){
+#if 0
   int j;
   FILE *of;
   char buffer[80];
 
   /*  if(i==5870){*/
     sprintf(buffer,"%s_%d.m",base,i);
     of=fopen(buffer,"w");
     
     if(!of)perror("failed to open data dump file");
     
     for(j=0;j<n;j++){
       if(bark){
-	float b=toBARK((4000.f*j/n)+.25);
-	fprintf(of,"%f ",b);
+        float b=toBARK((4000.f*j/n)+.25);
+        fprintf(of,"%f ",b);
       }else
-	if(off!=0)
-	  fprintf(of,"%f ",(double)(j+off)/8000.);
-	else
-	  fprintf(of,"%f ",(double)j);
+        if(off!=0)
+          fprintf(of,"%f ",(double)(j+off)/8000.);
+        else
+          fprintf(of,"%f ",(double)j);
       
       if(dB){
-	float val;
-	if(v[j]==0.)
-	  val=-140.;
-	else
-	  val=todB(v+j);
-	fprintf(of,"%f\n",val);
+        float val;
+        if(v[j]==0.)
+          val=-140.;
+        else
+          val=todB(v+j);
+        fprintf(of,"%f\n",val);
       }else{
-	fprintf(of,"%f\n",v[j]);
+        fprintf(of,"%f\n",v[j]);
       }
     }
     fclose(of);
     /*  } */
+#endif
 }
 
 void _analysis_output(char *base,int i,float *v,int n,int bark,int dB,
-		      ogg_int64_t off){
+                      ogg_int64_t off){
   if(analysis_noisy)_analysis_output_always(base,i,v,n,bark,dB,off);
 }
 
 
 
 
 
 
--- a/media/libvorbis/lib/vorbis_bitrate.c
+++ b/media/libvorbis/lib/vorbis_bitrate.c
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: bitrate tracking and management
- last mod: $Id: bitrate.c 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #include <stdlib.h>
 #include <string.h>
 #include <math.h>
 #include <ogg/ogg.h>
 #include "vorbis/codec.h"
@@ -86,17 +86,17 @@ int vorbis_bitrate_addblock(vorbis_block
   long max_target_bits=(vb->W?bm->max_bitsper*bm->short_per_long:bm->max_bitsper);
   int  samples=ci->blocksizes[vb->W]>>1;
   long desired_fill=bi->reservoir_bits*bi->reservoir_bias;
   if(!bm->managed){
     /* not a bitrate managed stream, but for API simplicity, we'll
        buffer the packet to keep the code path clean */
     
     if(bm->vb)return(-1); /* one has been submitted without
-			     being claimed */
+                             being claimed */
     bm->vb=vb;
     return(0);
   }
 
   bm->vb=vb;
   
   /* look ahead for avg floater */
   if(bm->avg_bitsper>0){
@@ -112,25 +112,25 @@ int vorbis_bitrate_addblock(vorbis_block
        and set slew as the first in the appropriate direction that
        gives us the slew we want.  This may mean no slew if delta is
        already favorable.
 
        Then limit slew to slew max */
 
     if(bm->avg_reservoir+(this_bits-avg_target_bits)>desired_fill){
       while(choice>0 && this_bits>avg_target_bits &&
-	    bm->avg_reservoir+(this_bits-avg_target_bits)>desired_fill){
-	choice--;
-	this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
+            bm->avg_reservoir+(this_bits-avg_target_bits)>desired_fill){
+        choice--;
+        this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
       }
     }else if(bm->avg_reservoir+(this_bits-avg_target_bits)<desired_fill){
       while(choice+1<PACKETBLOBS && this_bits<avg_target_bits &&
-	    bm->avg_reservoir+(this_bits-avg_target_bits)<desired_fill){
-	choice++;
-	this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
+            bm->avg_reservoir+(this_bits-avg_target_bits)<desired_fill){
+        choice++;
+        this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
       }
     }
 
     slew=rint(choice-bm->avgfloat)/samples*vi->rate;
     if(slew<-slewlimit)slew=-slewlimit;
     if(slew>slewlimit)slew=slewlimit;
     choice=rint(bm->avgfloat+= slew/vi->rate*samples);
     this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
@@ -138,31 +138,31 @@ int vorbis_bitrate_addblock(vorbis_block
 
 
 
   /* enforce min(if used) on the current floater (if used) */
   if(bm->min_bitsper>0){
     /* do we need to force the bitrate up? */
     if(this_bits<min_target_bits){
       while(bm->minmax_reservoir-(min_target_bits-this_bits)<0){
-	choice++;
-	if(choice>=PACKETBLOBS)break;
-	this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
+        choice++;
+        if(choice>=PACKETBLOBS)break;
+        this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
       }
     }
   }
   
   /* enforce max (if used) on the current floater (if used) */
   if(bm->max_bitsper>0){
     /* do we need to force the bitrate down? */
     if(this_bits>max_target_bits){
       while(bm->minmax_reservoir+(this_bits-max_target_bits)>bi->reservoir_bits){
-	choice--;
-	if(choice<0)break;
-	this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
+        choice--;
+        if(choice<0)break;
+        this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
       }
     }
   }
 
   /* Choice of packetblobs now made based on floater, and min/max
      requirements. Now boundary check extreme choices */
 
   if(choice<0){
@@ -196,29 +196,29 @@ int vorbis_bitrate_addblock(vorbis_block
 
     if(max_target_bits>0 && this_bits>max_target_bits){
       bm->minmax_reservoir+=(this_bits-max_target_bits);
     }else if(min_target_bits>0 && this_bits<min_target_bits){
       bm->minmax_reservoir+=(this_bits-min_target_bits);
     }else{
       /* inbetween; we want to take reservoir toward but not past desired_fill */
       if(bm->minmax_reservoir>desired_fill){
-	if(max_target_bits>0){ /* logical bulletproofing against initialization state */
-	  bm->minmax_reservoir+=(this_bits-max_target_bits);
-	  if(bm->minmax_reservoir<desired_fill)bm->minmax_reservoir=desired_fill;
-	}else{
-	  bm->minmax_reservoir=desired_fill;
-	}
+        if(max_target_bits>0){ /* logical bulletproofing against initialization state */
+          bm->minmax_reservoir+=(this_bits-max_target_bits);
+          if(bm->minmax_reservoir<desired_fill)bm->minmax_reservoir=desired_fill;
+        }else{
+          bm->minmax_reservoir=desired_fill;
+        }
       }else{
-	if(min_target_bits>0){ /* logical bulletproofing against initialization state */
-	  bm->minmax_reservoir+=(this_bits-min_target_bits);
-	  if(bm->minmax_reservoir>desired_fill)bm->minmax_reservoir=desired_fill;
-	}else{
-	  bm->minmax_reservoir=desired_fill;
-	}
+        if(min_target_bits>0){ /* logical bulletproofing against initialization state */
+          bm->minmax_reservoir+=(this_bits-min_target_bits);
+          if(bm->minmax_reservoir>desired_fill)bm->minmax_reservoir=desired_fill;
+        }else{
+          bm->minmax_reservoir=desired_fill;
+        }
       }
     }
   }
 
   /* avg reservoir */
   if(bm->avg_bitsper>0){
     long avg_target_bits=(vb->W?bm->avg_bitsper*bm->short_per_long:bm->avg_bitsper);    
     bm->avg_reservoir+=this_bits-avg_target_bits;
--- a/media/libvorbis/lib/vorbis_block.c
+++ b/media/libvorbis/lib/vorbis_block.c
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: PCM data vector blocking, windowing and dis/reassembly
- last mod: $Id: block.c 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  Handle windowing, overlap-add, etc of the PCM vectors.  This is made
  more amusing by Vorbis' current two allowed block sizes.
  
  ********************************************************************/
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -70,18 +70,18 @@ static int ilog2(unsigned int v){
 :            ..............  ___  |   |                    
 :        .'''             |`/   \ |   |                       
 :.....'''                 |/`....\|...|                    
 :.........................|___|___|___|                  
                           |Sl |Sr |endW    
                           |   |   |endSr
                           |   |beginSr
                           |   |endSl
-			  |beginSl
-			  |beginW
+                          |beginSl
+                          |beginW
 */
 
 /* block abstraction setup *********************************************/
 
 #ifndef WORD_ALIGN
 #define WORD_ALIGN 8
 #endif
 
@@ -91,20 +91,20 @@ int vorbis_block_init(vorbis_dsp_state *
   vb->vd=v;
   if(v->analysisp){
     vorbis_block_internal *vbi=
       vb->internal=_ogg_calloc(1,sizeof(vorbis_block_internal));
     vbi->ampmax=-9999;
 
     for(i=0;i<PACKETBLOBS;i++){
       if(i==PACKETBLOBS/2){
-	vbi->packetblob[i]=&vb->opb;
+        vbi->packetblob[i]=&vb->opb;
       }else{
-	vbi->packetblob[i]=
-	  _ogg_calloc(1,sizeof(oggpack_buffer));
+        vbi->packetblob[i]=
+          _ogg_calloc(1,sizeof(oggpack_buffer));
       }
       oggpack_writeinit(vbi->packetblob[i]);
     }    
   }
 
   return(0);
 }
 
@@ -210,38 +210,39 @@ static int _vds_shared_init(vorbis_dsp_s
     /* analysis always needs an fft */
     drft_init(&b->fft_look[0],ci->blocksizes[0]);
     drft_init(&b->fft_look[1],ci->blocksizes[1]);
 
     /* finish the codebooks */
     if(!ci->fullbooks){
       ci->fullbooks=_ogg_calloc(ci->books,sizeof(*ci->fullbooks));
       for(i=0;i<ci->books;i++)
-	vorbis_book_init_encode(ci->fullbooks+i,ci->book_param[i]);
+        vorbis_book_init_encode(ci->fullbooks+i,ci->book_param[i]);
     }
 
     b->psy=_ogg_calloc(ci->psys,sizeof(*b->psy));
     for(i=0;i<ci->psys;i++){
       _vp_psy_init(b->psy+i,
-		   ci->psy_param[i],
-		   &ci->psy_g_param,
-		   ci->blocksizes[ci->psy_param[i]->blockflag]/2,
-		   vi->rate);
+                   ci->psy_param[i],
+                   &ci->psy_g_param,
+                   ci->blocksizes[ci->psy_param[i]->blockflag]/2,
+                   vi->rate);
     }
 
     v->analysisp=1;
   }else{
     /* finish the codebooks */
     if(!ci->fullbooks){
       ci->fullbooks=_ogg_calloc(ci->books,sizeof(*ci->fullbooks));
       for(i=0;i<ci->books;i++){
-	vorbis_book_init_decode(ci->fullbooks+i,ci->book_param[i]);
-	/* decode codebooks are now standalone after init */
-	vorbis_staticbook_destroy(ci->book_param[i]);
-	ci->book_param[i]=NULL;
+        if(vorbis_book_init_decode(ci->fullbooks+i,ci->book_param[i]))
+          return -1;
+        /* decode codebooks are now standalone after init */
+        vorbis_staticbook_destroy(ci->book_param[i]);
+        ci->book_param[i]=NULL;
       }
     }
   }
 
   /* initialize the storage vectors. blocksize[1] is small for encode,
      but the correct size for decode */
   v->pcm_storage=ci->blocksizes[1];
   v->pcm=_ogg_malloc(vi->channels*sizeof(*v->pcm));
@@ -305,66 +306,66 @@ void vorbis_dsp_init(vorbis_dsp_state *v
 void vorbis_dsp_clear(vorbis_dsp_state *v){
   int i;
   if(v){
     vorbis_info *vi=v->vi;
     codec_setup_info *ci=(vi?vi->codec_setup:NULL);
     private_state *b=v->backend_state;
 
     if(b){
-	
+        
       if(b->ve){
-	_ve_envelope_clear(b->ve);
-	_ogg_free(b->ve);
+        _ve_envelope_clear(b->ve);
+        _ogg_free(b->ve);
       }
 
       if(b->transform[0]){
-	mdct_clear(b->transform[0][0]);
-	_ogg_free(b->transform[0][0]);
-	_ogg_free(b->transform[0]);
+        mdct_clear(b->transform[0][0]);
+        _ogg_free(b->transform[0][0]);
+        _ogg_free(b->transform[0]);
       }
       if(b->transform[1]){
-	mdct_clear(b->transform[1][0]);
-	_ogg_free(b->transform[1][0]);
-	_ogg_free(b->transform[1]);
+        mdct_clear(b->transform[1][0]);
+        _ogg_free(b->transform[1][0]);
+        _ogg_free(b->transform[1]);
       }
 
       if(b->flr){
-	if(ci)
-	  for(i=0;i<ci->floors;i++)
-	    _floor_P[ci->floor_type[i]]->
-	      free_look(b->flr[i]);
-	_ogg_free(b->flr);
+        if(ci)
+          for(i=0;i<ci->floors;i++)
+            _floor_P[ci->floor_type[i]]->
+              free_look(b->flr[i]);
+        _ogg_free(b->flr);
       }
       if(b->residue){
-	if(ci)
-	  for(i=0;i<ci->residues;i++)
-	    _residue_P[ci->residue_type[i]]->
-	      free_look(b->residue[i]);
-	_ogg_free(b->residue);
+        if(ci)
+          for(i=0;i<ci->residues;i++)
+            _residue_P[ci->residue_type[i]]->
+              free_look(b->residue[i]);
+        _ogg_free(b->residue);
       }
       if(b->psy){
-	if(ci)
-	  for(i=0;i<ci->psys;i++)
-	    _vp_psy_clear(b->psy+i);
-	_ogg_free(b->psy);
+        if(ci)
+          for(i=0;i<ci->psys;i++)
+            _vp_psy_clear(b->psy+i);
+        _ogg_free(b->psy);
       }
 
       if(b->psy_g_look)_vp_global_free(b->psy_g_look);
       vorbis_bitrate_clear(&b->bms);
 
       drft_clear(&b->fft_look[0]);
       drft_clear(&b->fft_look[1]);
 
     }
     
     if(v->pcm){
       if(vi)
-	for(i=0;i<vi->channels;i++)
-	  if(v->pcm[i])_ogg_free(v->pcm[i]);
+        for(i=0;i<vi->channels;i++)
+          if(v->pcm[i])_ogg_free(v->pcm[i]);
       _ogg_free(v->pcm);
       if(v->pcmret)_ogg_free(v->pcmret);
     }
 
     if(b){
       /* free header, header1, header2 */
       if(b->header)_ogg_free(b->header);
       if(b->header1)_ogg_free(b->header1);
@@ -400,39 +401,50 @@ float **vorbis_analysis_buffer(vorbis_ds
   for(i=0;i<vi->channels;i++)
     v->pcmret[i]=v->pcm[i]+v->pcm_current;
     
   return(v->pcmret);
 }
 
 static void _preextrapolate_helper(vorbis_dsp_state *v){
   int i;
-  int order=32;
+  int order=16;
   float *lpc=alloca(order*sizeof(*lpc));
   float *work=alloca(v->pcm_current*sizeof(*work));
   long j;
   v->preextrapolate=1;
 
   if(v->pcm_current-v->centerW>order*2){ /* safety */
     for(i=0;i<v->vi->channels;i++){
       /* need to run the extrapolation in reverse! */
       for(j=0;j<v->pcm_current;j++)
-	work[j]=v->pcm[i][v->pcm_current-j-1];
+        work[j]=v->pcm[i][v->pcm_current-j-1];
       
       /* prime as above */
       vorbis_lpc_from_data(work,lpc,v->pcm_current-v->centerW,order);
-      
+
+#if 0
+      if(v->vi->channels==2){
+        if(i==0)
+          _analysis_output("predataL",0,work,v->pcm_current-v->centerW,0,0,0);
+        else
+          _analysis_output("predataR",0,work,v->pcm_current-v->centerW,0,0,0);
+      }else{
+        _analysis_output("predata",0,work,v->pcm_current-v->centerW,0,0,0);
+      }
+#endif 
+ 
       /* run the predictor filter */
       vorbis_lpc_predict(lpc,work+v->pcm_current-v->centerW-order,
-			 order,
-			 work+v->pcm_current-v->centerW,
-			 v->centerW);
+                         order,
+                         work+v->pcm_current-v->centerW,
+                         v->centerW);
 
       for(j=0;j<v->pcm_current;j++)
-	v->pcm[i][v->pcm_current-j-1]=work[j];
+        v->pcm[i][v->pcm_current-j-1]=work[j];
 
     }
   }
 }
 
 
 /* call with val<=0 to set eof */
 
@@ -456,33 +468,33 @@ int vorbis_analysis_wrote(vorbis_dsp_sta
        suck to encode.  Extrapolate for the sake of cleanliness. */
 
     vorbis_analysis_buffer(v,ci->blocksizes[1]*3); 
     v->eofflag=v->pcm_current;
     v->pcm_current+=ci->blocksizes[1]*3;
 
     for(i=0;i<vi->channels;i++){
       if(v->eofflag>order*2){
-	/* extrapolate with LPC to fill in */
-	long n;
+        /* extrapolate with LPC to fill in */
+        long n;
 
-	/* make a predictor filter */
-	n=v->eofflag;
-	if(n>ci->blocksizes[1])n=ci->blocksizes[1];
-	vorbis_lpc_from_data(v->pcm[i]+v->eofflag-n,lpc,n,order);
+        /* make a predictor filter */
+        n=v->eofflag;
+        if(n>ci->blocksizes[1])n=ci->blocksizes[1];
+        vorbis_lpc_from_data(v->pcm[i]+v->eofflag-n,lpc,n,order);
 
-	/* run the predictor filter */
-	vorbis_lpc_predict(lpc,v->pcm[i]+v->eofflag-order,order,
-			   v->pcm[i]+v->eofflag,v->pcm_current-v->eofflag);
+        /* run the predictor filter */
+        vorbis_lpc_predict(lpc,v->pcm[i]+v->eofflag-order,order,
+                           v->pcm[i]+v->eofflag,v->pcm_current-v->eofflag);
       }else{
-	/* not enough data to extrapolate (unlikely to happen due to
+        /* not enough data to extrapolate (unlikely to happen due to
            guarding the overlap, but bulletproof in case that
            assumtion goes away). zeroes will do. */
-	memset(v->pcm[i]+v->eofflag,0,
-	       (v->pcm_current-v->eofflag)*sizeof(*v->pcm[i]));
+        memset(v->pcm[i]+v->eofflag,0,
+               (v->pcm_current-v->eofflag)*sizeof(*v->pcm[i]));
 
       }
     }
   }else{
 
     if(v->pcm_current+vals>v->pcm_storage)
       return(OV_EINVAL);
 
@@ -522,24 +534,24 @@ int vorbis_analysis_blockout(vorbis_dsp_
   /* we do an envelope search even on a single blocksize; we may still
      be throwing more bits at impulses, and envelope search handles
      marking impulses too. */
   {  
     long bp=_ve_envelope_search(v);
     if(bp==-1){
 
       if(v->eofflag==0)return(0); /* not enough data currently to search for a
-				     full long block */
+                                     full long block */
       v->nW=0;
     }else{
 
       if(ci->blocksizes[0]==ci->blocksizes[1])
-	v->nW=0;
+        v->nW=0;
       else
-	v->nW=bp;
+        v->nW=bp;
     }
   }
 
   centerNext=v->centerW+ci->blocksizes[v->W]/4+ci->blocksizes[v->nW]/4;
 
   {
     /* center of next block + next block maximum right side. */
 
@@ -629,35 +641,35 @@ int vorbis_analysis_blockout(vorbis_dsp_
     int movementW=centerNext-new_centerNext;
 
     if(movementW>0){
 
       _ve_envelope_shift(b->ve,movementW);
       v->pcm_current-=movementW;
       
       for(i=0;i<vi->channels;i++)
-	memmove(v->pcm[i],v->pcm[i]+movementW,
-		v->pcm_current*sizeof(*v->pcm[i]));
+        memmove(v->pcm[i],v->pcm[i]+movementW,
+                v->pcm_current*sizeof(*v->pcm[i]));
       
       
       v->lW=v->W;
       v->W=v->nW;
       v->centerW=new_centerNext;
       
       if(v->eofflag){
-	v->eofflag-=movementW;
-	if(v->eofflag<=0)v->eofflag=-1;
-	/* do not add padding to end of stream! */
-	if(v->centerW>=v->eofflag){
-	  v->granulepos+=movementW-(v->centerW-v->eofflag);
-	}else{
-	  v->granulepos+=movementW;
-	}
+        v->eofflag-=movementW;
+        if(v->eofflag<=0)v->eofflag=-1;
+        /* do not add padding to end of stream! */
+        if(v->centerW>=v->eofflag){
+          v->granulepos+=movementW-(v->centerW-v->eofflag);
+        }else{
+          v->granulepos+=movementW;
+        }
       }else{
-	v->granulepos+=movementW;
+        v->granulepos+=movementW;
       }
     }
   }
 
   /* done */
   return(1);
 }
 
@@ -680,19 +692,21 @@ int vorbis_synthesis_restart(vorbis_dsp_
   v->sequence=-1;
   v->eofflag=0;
   ((private_state *)(v->backend_state))->sample_count=-1;
 
   return(0);
 }
 
 int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi){
-  if(_vds_shared_init(v,vi,0)) return 1;
+  if(_vds_shared_init(v,vi,0)){
+    vorbis_dsp_clear(v);
+    return 1;
+  }
   vorbis_synthesis_restart(v);
-
   return 0;
 }
 
 /* Unlike in analysis, the window is only partially applied for each
    block.  The time domain envelope is not yet handled at the point of
    calling (as it relies on the previous block). */
 
 int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
@@ -713,17 +727,17 @@ int vorbis_synthesis_blockin(vorbis_dsp_
      (v->sequence+1 != vb->sequence)){
     v->granulepos=-1; /* out of sequence; lose count */
     b->sample_count=-1;
   }
 
   v->sequence=vb->sequence;
   
   if(vb->pcm){  /* no pcm to process if vorbis_synthesis_trackonly 
-		   was called on block */
+                   was called on block */
     int n=ci->blocksizes[v->W]>>(hs+1);
     int n0=ci->blocksizes[0]>>(hs+1);
     int n1=ci->blocksizes[1]>>(hs+1);
 
     int thisCenter;
     int prevCenter;
     
     v->glue_bits+=vb->glue_bits;
@@ -741,57 +755,57 @@ int vorbis_synthesis_blockin(vorbis_dsp_
     
     /* v->pcm is now used like a two-stage double buffer.  We don't want
        to have to constantly shift *or* adjust memory usage.  Don't
        accept a new block until the old is shifted out */
     
     for(j=0;j<vi->channels;j++){
       /* the overlap/add section */
       if(v->lW){
-	if(v->W){
-	  /* large/large */
-	  float *w=_vorbis_window_get(b->window[1]-hs);
-	  float *pcm=v->pcm[j]+prevCenter;
-	  float *p=vb->pcm[j];
-	  for(i=0;i<n1;i++)
-	    pcm[i]=pcm[i]*w[n1-i-1] + p[i]*w[i];
-	}else{
-	  /* large/small */
-	  float *w=_vorbis_window_get(b->window[0]-hs);
-	  float *pcm=v->pcm[j]+prevCenter+n1/2-n0/2;
-	  float *p=vb->pcm[j];
-	  for(i=0;i<n0;i++)
-	    pcm[i]=pcm[i]*w[n0-i-1] +p[i]*w[i];
-	}
+        if(v->W){
+          /* large/large */
+          float *w=_vorbis_window_get(b->window[1]-hs);
+          float *pcm=v->pcm[j]+prevCenter;
+          float *p=vb->pcm[j];
+          for(i=0;i<n1;i++)
+            pcm[i]=pcm[i]*w[n1-i-1] + p[i]*w[i];
+        }else{
+          /* large/small */
+          float *w=_vorbis_window_get(b->window[0]-hs);
+          float *pcm=v->pcm[j]+prevCenter+n1/2-n0/2;
+          float *p=vb->pcm[j];
+          for(i=0;i<n0;i++)
+            pcm[i]=pcm[i]*w[n0-i-1] +p[i]*w[i];
+        }
       }else{
-	if(v->W){
-	  /* small/large */
-	  float *w=_vorbis_window_get(b->window[0]-hs);
-	  float *pcm=v->pcm[j]+prevCenter;
-	  float *p=vb->pcm[j]+n1/2-n0/2;
-	  for(i=0;i<n0;i++)
-	    pcm[i]=pcm[i]*w[n0-i-1] +p[i]*w[i];
-	  for(;i<n1/2+n0/2;i++)
-	    pcm[i]=p[i];
-	}else{
-	  /* small/small */
-	  float *w=_vorbis_window_get(b->window[0]-hs);
-	  float *pcm=v->pcm[j]+prevCenter;
-	  float *p=vb->pcm[j];
-	  for(i=0;i<n0;i++)
-	    pcm[i]=pcm[i]*w[n0-i-1] +p[i]*w[i];
-	}
+        if(v->W){
+          /* small/large */
+          float *w=_vorbis_window_get(b->window[0]-hs);
+          float *pcm=v->pcm[j]+prevCenter;
+          float *p=vb->pcm[j]+n1/2-n0/2;
+          for(i=0;i<n0;i++)
+            pcm[i]=pcm[i]*w[n0-i-1] +p[i]*w[i];
+          for(;i<n1/2+n0/2;i++)
+            pcm[i]=p[i];
+        }else{
+          /* small/small */
+          float *w=_vorbis_window_get(b->window[0]-hs);
+          float *pcm=v->pcm[j]+prevCenter;
+          float *p=vb->pcm[j];
+          for(i=0;i<n0;i++)
+            pcm[i]=pcm[i]*w[n0-i-1] +p[i]*w[i];
+        }
       }
       
       /* the copy section */
       {
-	float *pcm=v->pcm[j]+thisCenter;
-	float *p=vb->pcm[j]+n;
-	for(i=0;i<n;i++)
-	  pcm[i]=p[i];
+        float *pcm=v->pcm[j]+thisCenter;
+        float *p=vb->pcm[j]+n;
+        for(i=0;i<n;i++)
+          pcm[i]=p[i];
       }
     }
     
     if(v->centerW)
       v->centerW=0;
     else
       v->centerW=n1;
     
@@ -800,18 +814,18 @@ int vorbis_synthesis_blockin(vorbis_dsp_
        being short or long */
     
     if(v->pcm_returned==-1){
       v->pcm_returned=thisCenter;
       v->pcm_current=thisCenter;
     }else{
       v->pcm_returned=prevCenter;
       v->pcm_current=prevCenter+
-	((ci->blocksizes[v->lW]/4+
-	ci->blocksizes[v->W]/4)>>hs);
+        ((ci->blocksizes[v->lW]/4+
+        ci->blocksizes[v->W]/4)>>hs);
     }
     
   }
 
   /* track the frame number... This is for convenience, but also
      making sure our last packet doesn't end with added padding.  If
      the last packet is partial, the number of samples we'll have to
      return will be past the vb->granulepos.
@@ -830,51 +844,51 @@ int vorbis_synthesis_blockin(vorbis_dsp_
   
   if(v->granulepos==-1){
     if(vb->granulepos!=-1){ /* only set if we have a position to set to */
 
       v->granulepos=vb->granulepos;
 
       /* is this a short page? */
       if(b->sample_count>v->granulepos){
-	/* corner case; if this is both the first and last audio page,
-	   then spec says the end is cut, not beginning */
-	if(vb->eofflag){
-	  /* trim the end */
-	  /* no preceeding granulepos; assume we started at zero (we'd
-	     have to in a short single-page stream) */
-	  /* granulepos could be -1 due to a seek, but that would result
-	     in a long count, not short count */
-	  
-	  v->pcm_current-=(b->sample_count-v->granulepos)>>hs;
-	}else{
-	  /* trim the beginning */
-	  v->pcm_returned+=(b->sample_count-v->granulepos)>>hs;
-	  if(v->pcm_returned>v->pcm_current)
-	    v->pcm_returned=v->pcm_current;
-	}
+        /* corner case; if this is both the first and last audio page,
+           then spec says the end is cut, not beginning */
+        if(vb->eofflag){
+          /* trim the end */
+          /* no preceeding granulepos; assume we started at zero (we'd
+             have to in a short single-page stream) */
+          /* granulepos could be -1 due to a seek, but that would result
+             in a long count, not short count */
+          
+          v->pcm_current-=(b->sample_count-v->granulepos)>>hs;
+        }else{
+          /* trim the beginning */
+          v->pcm_returned+=(b->sample_count-v->granulepos)>>hs;
+          if(v->pcm_returned>v->pcm_current)
+            v->pcm_returned=v->pcm_current;
+        }
 
       }
 
     }
   }else{
     v->granulepos+=ci->blocksizes[v->lW]/4+ci->blocksizes[v->W]/4;
     if(vb->granulepos!=-1 && v->granulepos!=vb->granulepos){
       
       if(v->granulepos>vb->granulepos){
-	long extra=v->granulepos-vb->granulepos;
+        long extra=v->granulepos-vb->granulepos;
 
-	if(extra)
-	  if(vb->eofflag){
-	    /* partial last frame.  Strip the extra samples off */
-	    v->pcm_current-=extra>>hs;
-	  } /* else {Shouldn't happen *unless* the bitstream is out of
-	       spec.  Either way, believe the bitstream } */
+        if(extra)
+          if(vb->eofflag){
+            /* partial last frame.  Strip the extra samples off */
+            v->pcm_current-=extra>>hs;
+          } /* else {Shouldn't happen *unless* the bitstream is out of
+               spec.  Either way, believe the bitstream } */
       } /* else {Shouldn't happen *unless* the bitstream is out of
-	   spec.  Either way, believe the bitstream } */
+           spec.  Either way, believe the bitstream } */
       v->granulepos=vb->granulepos;
     }
   }
   
   /* Update, cleanup */
   
   if(vb->eofflag)v->eofflag=1;
   return(0);
@@ -884,17 +898,17 @@ int vorbis_synthesis_blockin(vorbis_dsp_
 /* pcm==NULL indicates we just want the pending samples, no more */
 int vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm){
   vorbis_info *vi=v->vi;
 
   if(v->pcm_returned>-1 && v->pcm_returned<v->pcm_current){
     if(pcm){
       int i;
       for(i=0;i<vi->channels;i++)
-	v->pcmret[i]=v->pcm[i]+v->pcm_returned;
+        v->pcmret[i]=v->pcm[i]+v->pcm_returned;
       *pcm=v->pcmret;
     }
     return(v->pcm_current-v->pcm_returned);
   }
   return(0);
 }
 
 int vorbis_synthesis_read(vorbis_dsp_state *v,int n){
@@ -931,46 +945,46 @@ int vorbis_synthesis_lapout(vorbis_dsp_s
   /* centerW was advanced by blockin; it would be the center of the
      *next* block */
   if(v->centerW==n1){
     /* the data buffer wraps; swap the halves */
     /* slow, sure, small */
     for(j=0;j<vi->channels;j++){
       float *p=v->pcm[j];
       for(i=0;i<n1;i++){
-	float temp=p[i];
-	p[i]=p[i+n1];
-	p[i+n1]=temp;
+        float temp=p[i];
+        p[i]=p[i+n1];
+        p[i+n1]=temp;
       }
     }
 
     v->pcm_current-=n1;
     v->pcm_returned-=n1;
     v->centerW=0;
   }
   
   /* solidify buffer into contiguous space */
   if((v->lW^v->W)==1){
     /* long/short or short/long */
     for(j=0;j<vi->channels;j++){
       float *s=v->pcm[j];
       float *d=v->pcm[j]+(n1-n0)/2;
       for(i=(n1+n0)/2-1;i>=0;--i)
-	d[i]=s[i];
+        d[i]=s[i];
     }
     v->pcm_returned+=(n1-n0)/2;
     v->pcm_current+=(n1-n0)/2;
   }else{
     if(v->lW==0){
       /* short/short */
       for(j=0;j<vi->channels;j++){
-	float *s=v->pcm[j];
-	float *d=v->pcm[j]+n1-n0;
-	for(i=n0-1;i>=0;--i)
-	  d[i]=s[i];
+        float *s=v->pcm[j];
+        float *d=v->pcm[j]+n1-n0;
+        for(i=n0-1;i>=0;--i)
+          d[i]=s[i];
       }
       v->pcm_returned+=n1-n0;
       v->pcm_current+=n1-n0;
     }
   }
     
   if(pcm){
     int i;
@@ -987,9 +1001,9 @@ float *vorbis_window(vorbis_dsp_state *v
   vorbis_info *vi=v->vi;
   codec_setup_info *ci=vi->codec_setup;
   int hs=ci->halfrate_flag; 
   private_state *b=v->backend_state;
 
   if(b->window[W]-1<0)return NULL;
   return _vorbis_window_get(b->window[W]-hs);
 }
-	
+        
--- a/media/libvorbis/lib/vorbis_codebook.c
+++ b/media/libvorbis/lib/vorbis_codebook.c
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: basic codebook pack/unpack/code/decode operations
- last mod: $Id: codebook.c 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #include <stdlib.h>
 #include <string.h>
 #include <math.h>
 #include <ogg/ogg.h>
 #include "vorbis/codec.h"
@@ -51,20 +51,20 @@ int vorbis_staticbook_pack(const static_
     long count=0;
     oggpack_write(opb,1,1);  /* ordered */
     oggpack_write(opb,c->lengthlist[0]-1,5); /* 1 to 32 */
 
     for(i=1;i<c->entries;i++){
       long this=c->lengthlist[i];
       long last=c->lengthlist[i-1];
       if(this>last){
-	for(j=last;j<this;j++){
-	  oggpack_write(opb,i-count,_ilog(c->entries-count));
-	  count=i;
-	}
+        for(j=last;j<this;j++){
+          oggpack_write(opb,i-count,_ilog(c->entries-count));
+          count=i;
+        }
       }
     }
     oggpack_write(opb,i-count,_ilog(c->entries-count));
     
   }else{
     /* length random.  Again, we don't code the codeword itself, just
        the length.  This time, though, we have to encode each length */
     oggpack_write(opb,0,1);   /* unordered */
@@ -73,26 +73,26 @@ int vorbis_staticbook_pack(const static_
        here.  The algorithmic mapping happens as usual, but the unused
        entry has no codeword. */
     for(i=0;i<c->entries;i++)
       if(c->lengthlist[i]==0)break;
 
     if(i==c->entries){
       oggpack_write(opb,0,1); /* no unused entries */
       for(i=0;i<c->entries;i++)
-	oggpack_write(opb,c->lengthlist[i]-1,5);
+        oggpack_write(opb,c->lengthlist[i]-1,5);
     }else{
       oggpack_write(opb,1,1); /* we have unused entries; thus we tag */
       for(i=0;i<c->entries;i++){
-	if(c->lengthlist[i]==0){
-	  oggpack_write(opb,0,1);
-	}else{
-	  oggpack_write(opb,1,1);
-	  oggpack_write(opb,c->lengthlist[i]-1,5);
-	}
+        if(c->lengthlist[i]==0){
+          oggpack_write(opb,0,1);
+        }else{
+          oggpack_write(opb,1,1);
+          oggpack_write(opb,c->lengthlist[i]-1,5);
+        }
       }
     }
   }
 
   /* is the entry number the desired return value, or do we have a
      mapping? If we have a mapping, what type? */
   oggpack_write(opb,c->maptype,4);
   switch(c->maptype){
@@ -113,31 +113,31 @@ int vorbis_staticbook_pack(const static_
     oggpack_write(opb,c->q_delta,32);
     oggpack_write(opb,c->q_quant-1,4);
     oggpack_write(opb,c->q_sequencep,1);
     
     {
       int quantvals;
       switch(c->maptype){
       case 1:
-	/* a single column of (c->entries/c->dim) quantized values for
-	   building a full value list algorithmically (square lattice) */
-	quantvals=_book_maptype1_quantvals(c);
-	break;
+        /* a single column of (c->entries/c->dim) quantized values for
+           building a full value list algorithmically (square lattice) */
+        quantvals=_book_maptype1_quantvals(c);
+        break;
       case 2:
-	/* every value (c->entries*c->dim total) specified explicitly */
-	quantvals=c->entries*c->dim;
-	break;
+        /* every value (c->entries*c->dim total) specified explicitly */
+        quantvals=c->entries*c->dim;
+        break;
       default: /* NOT_REACHABLE */
-	quantvals=-1;
+        quantvals=-1;
       }
 
       /* quantized values */
       for(i=0;i<quantvals;i++)
-	oggpack_write(opb,labs(c->quantlist[i]),c->q_quant);
+        oggpack_write(opb,labs(c->quantlist[i]),c->q_quant);
 
     }
     break;
   default:
     /* error case; we don't have any other map types now */
     return(-1);
   }
 
@@ -154,56 +154,58 @@ int vorbis_staticbook_unpack(oggpack_buf
   /* make sure alignment is correct */
   if(oggpack_read(opb,24)!=0x564342)goto _eofout;
 
   /* first the basic parameters */
   s->dim=oggpack_read(opb,16);
   s->entries=oggpack_read(opb,24);
   if(s->entries==-1)goto _eofout;
 
+  if(_ilog(s->dim)+_ilog(s->entries)>24)goto _eofout;
+
   /* codeword ordering.... length ordered or unordered? */
   switch((int)oggpack_read(opb,1)){
   case 0:
     /* unordered */
     s->lengthlist=_ogg_malloc(sizeof(*s->lengthlist)*s->entries);
 
     /* allocated but unused entries? */
     if(oggpack_read(opb,1)){
       /* yes, unused entries */
 
       for(i=0;i<s->entries;i++){
-	if(oggpack_read(opb,1)){
-	  long num=oggpack_read(opb,5);
-	  if(num==-1)goto _eofout;
-	  s->lengthlist[i]=num+1;
-	}else
-	  s->lengthlist[i]=0;
+        if(oggpack_read(opb,1)){
+          long num=oggpack_read(opb,5);
+          if(num==-1)goto _eofout;
+          s->lengthlist[i]=num+1;
+        }else
+          s->lengthlist[i]=0;
       }
     }else{
       /* all entries used; no tagging */
       for(i=0;i<s->entries;i++){
-	long num=oggpack_read(opb,5);
-	if(num==-1)goto _eofout;
-	s->lengthlist[i]=num+1;
+        long num=oggpack_read(opb,5);
+        if(num==-1)goto _eofout;
+        s->lengthlist[i]=num+1;
       }
     }
     
     break;
   case 1:
     /* ordered */
     {
       long length=oggpack_read(opb,5)+1;
       s->lengthlist=_ogg_malloc(sizeof(*s->lengthlist)*s->entries);
 
       for(i=0;i<s->entries;){
-	long num=oggpack_read(opb,_ilog(s->entries-i));
-	if(num==-1)goto _eofout;
-	for(j=0;j<num && i<s->entries;j++,i++)
-	  s->lengthlist[i]=length;
-	length++;
+        long num=oggpack_read(opb,_ilog(s->entries-i));
+        if(num==-1)goto _eofout;
+        for(j=0;j<num && i<s->entries;j++,i++)
+          s->lengthlist[i]=length;
+        length++;
       }
     }
     break;
   default:
     /* EOF */
     return(-1);
   }
   
@@ -220,27 +222,27 @@ int vorbis_staticbook_unpack(oggpack_buf
     s->q_delta=oggpack_read(opb,32);
     s->q_quant=oggpack_read(opb,4)+1;
     s->q_sequencep=oggpack_read(opb,1);
 
     {
       int quantvals=0;
       switch(s->maptype){
       case 1:
-	quantvals=_book_maptype1_quantvals(s);
-	break;
+        quantvals=(s->dim==0?0:_book_maptype1_quantvals(s));
+        break;
       case 2:
-	quantvals=s->entries*s->dim;
-	break;
+        quantvals=s->entries*s->dim;
+        break;
       }
       
       /* quantized values */
       s->quantlist=_ogg_malloc(sizeof(*s->quantlist)*quantvals);
       for(i=0;i<quantvals;i++)
-	s->quantlist[i]=oggpack_read(opb,s->q_quant);
+        s->quantlist[i]=oggpack_read(opb,s->q_quant);
       
       if(quantvals&&s->quantlist[quantvals-1]==-1)goto _eofout;
     }
     break;
   default:
     goto _errout;
   }
 
@@ -390,107 +392,107 @@ long vorbis_book_decodevs_add(codebook *
     
     for (i = 0; i < step; i++) {
       entry[i]=decode_packed_entry_number(book,b);
       if(entry[i]==-1)return(-1);
       t[i] = book->valuelist+entry[i]*book->dim;
     }
     for(i=0,o=0;i<book->dim;i++,o+=step)
       for (j=0;j<step;j++)
-	a[o+j]+=t[j][i];
+        a[o+j]+=t[j][i];
   }
   return(0);
 }
 
 long vorbis_book_decodev_add(codebook *book,float *a,oggpack_buffer *b,int n){
   if(book->used_entries>0){
     int i,j,entry;
     float *t;
     
     if(book->dim>8){
       for(i=0;i<n;){
-	entry = decode_packed_entry_number(book,b);
-	if(entry==-1)return(-1);
-	t     = book->valuelist+entry*book->dim;
-	for (j=0;j<book->dim;)
-	  a[i++]+=t[j++];
+        entry = decode_packed_entry_number(book,b);
+        if(entry==-1)return(-1);
+        t     = book->valuelist+entry*book->dim;
+        for (j=0;j<book->dim;)
+          a[i++]+=t[j++];
       }
     }else{
       for(i=0;i<n;){
-	entry = decode_packed_entry_number(book,b);
-	if(entry==-1)return(-1);
-	t     = book->valuelist+entry*book->dim;
-	j=0;
-	switch((int)book->dim){
-	case 8:
-	  a[i++]+=t[j++];
-	case 7:
-	  a[i++]+=t[j++];
-	case 6:
-	  a[i++]+=t[j++];
-	case 5:
-	  a[i++]+=t[j++];
-	case 4:
-	  a[i++]+=t[j++];
-	case 3:
-	  a[i++]+=t[j++];
-	case 2:
-	  a[i++]+=t[j++];
-	case 1:
-	  a[i++]+=t[j++];
-	case 0:
-	  break;
-	}
+        entry = decode_packed_entry_number(book,b);
+        if(entry==-1)return(-1);
+        t     = book->valuelist+entry*book->dim;
+        j=0;
+        switch((int)book->dim){
+        case 8:
+          a[i++]+=t[j++];
+        case 7:
+          a[i++]+=t[j++];
+        case 6:
+          a[i++]+=t[j++];
+        case 5:
+          a[i++]+=t[j++];
+        case 4:
+          a[i++]+=t[j++];
+        case 3:
+          a[i++]+=t[j++];
+        case 2:
+          a[i++]+=t[j++];
+        case 1:
+          a[i++]+=t[j++];
+        case 0:
+          break;
+        }
       }
     }    
   }
   return(0);
 }
 
 long vorbis_book_decodev_set(codebook *book,float *a,oggpack_buffer *b,int n){
   if(book->used_entries>0){
     int i,j,entry;
     float *t;
     
     for(i=0;i<n;){
       entry = decode_packed_entry_number(book,b);
       if(entry==-1)return(-1);
       t     = book->valuelist+entry*book->dim;
       for (j=0;j<book->dim;)
-	a[i++]=t[j++];
+        a[i++]=t[j++];
     }
   }else{
     int i,j;
     
     for(i=0;i<n;){
       for (j=0;j<book->dim;)
-	a[i++]=0.f;
+        a[i++]=0.f;
     }
   }
   return(0);
 }
 
 long vorbis_book_decodevv_add(codebook *book,float **a,long offset,int ch,
-			      oggpack_buffer *b,int n){
+                              oggpack_buffer *b,int n){
 
   long i,j,entry;
   int chptr=0;
   if(book->used_entries>0){
     for(i=offset/ch;i<(offset+n)/ch;){
       entry = decode_packed_entry_number(book,b);
       if(entry==-1)return(-1);
       {
-	const float *t = book->valuelist+entry*book->dim;
-	for (j=0;j<book->dim;j++){
-	  a[chptr++][i]+=t[j];
-	  if(chptr==ch){
-	    chptr=0;
-	    i++;
-	  }
-	}
+        const float *t = book->valuelist+entry*book->dim;
+        for (j=0;j<book->dim;j++){
+          a[chptr++][i]+=t[j];
+          if(chptr==ch){
+            chptr=0;
+            i++;
+          }
+        }
       }
     }
   }
   return(0);
 }
 
 #ifdef _V_SELFTEST
 /* Simple enough; pack a few candidate codebooks, unpack them.  Code a
@@ -558,17 +560,17 @@ float test1[TESTSIZE]={
 
 float test3[TESTSIZE]={
   0,1,-2,3,4,-5,6,7,8,9,
   8,-2,7,-1,4,6,8,3,1,-9,
   10,11,12,13,14,15,26,17,18,19,
   30,-25,-30,-1,-5,-32,4,3,-2,0};
 
 static_codebook *testlist[]={&_vq_book_lsp20_0,
-			     &_vq_book_res0a_13,NULL};
+                             &_vq_book_res0a_13,NULL};
 float   *testvec[]={test1,test3};
 
 int main(){
   oggpack_buffer write;
   oggpack_buffer read;
   long ptr=0,i;
   oggpack_writeinit(&write);
   
@@ -607,26 +609,26 @@ int main(){
     }
     if(vorbis_book_init_decode(&c,&s)){
       fprintf(stderr,"Error initializing codebook.\n");
       exit(1);
     }
 
     for(i=0;i<TESTSIZE;i+=c.dim)
       if(vorbis_book_decodev_set(&c,iv+i,&read,c.dim)==-1){
-	fprintf(stderr,"Error reading codebook test data (EOP).\n");
-	exit(1);
+        fprintf(stderr,"Error reading codebook test data (EOP).\n");
+        exit(1);
       }
     for(i=0;i<TESTSIZE;i++)
       if(fabs(qv[i]-iv[i])>.000001){
-	fprintf(stderr,"read (%g) != written (%g) at position (%ld)\n",
-		iv[i],qv[i],i);
-	exit(1);
+        fprintf(stderr,"read (%g) != written (%g) at position (%ld)\n",
+                iv[i],qv[i],i);
+        exit(1);
       }
-	  
+          
     fprintf(stderr,"OK\n");
     ptr++;
   }
 
   /* The above is the trivial stuff; now try unquantizing a log scale codebook */
 
   exit(0);
 }
--- a/media/libvorbis/lib/vorbis_envelope.c
+++ b/media/libvorbis/lib/vorbis_envelope.c
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: PCM data envelope analysis 
- last mod: $Id: envelope.c 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <math.h>
 #include <ogg/ogg.h>
@@ -83,21 +83,20 @@ void _ve_envelope_clear(envelope_lookup 
   _ogg_free(e->mark);
   memset(e,0,sizeof(*e));
 }
 
 /* fairly straight threshhold-by-band based until we find something
    that works better and isn't patented. */
 
 static int _ve_amp(envelope_lookup *ve,
-		   vorbis_info_psy_global *gi,
-		   float *data,
-		   envelope_band *bands,
-		   envelope_filter_state *filters,
-		   long pos){
+                   vorbis_info_psy_global *gi,
+                   float *data,
+                   envelope_band *bands,
+                   envelope_filter_state *filters){
   long n=ve->winlength;
   int ret=0;
   long i,j;
   float decay;
 
   /* we want to have a 'minimum bar' for energy, else we're just
      basing blocks on quantization noise that outweighs the signal
      itself (for low power signals) */
@@ -178,20 +177,20 @@ static int _ve_amp(envelope_lookup *ve,
       
       p=this;
       p--;
       if(p<0)p+=VE_AMP;
       postmax=max(acc,filters[j].ampbuf[p]);
       postmin=min(acc,filters[j].ampbuf[p]);
       
       for(i=0;i<stretch;i++){
-	p--;
-	if(p<0)p+=VE_AMP;
-	premax=max(premax,filters[j].ampbuf[p]);
-	premin=min(premin,filters[j].ampbuf[p]);
+        p--;
+        if(p<0)p+=VE_AMP;
+        premax=max(premax,filters[j].ampbuf[p]);
+        premin=min(premin,filters[j].ampbuf[p]);
       }
       
       valmin=postmin-premin;
       valmax=postmax-premax;
 
       /*filters[j].markers[pos]=valmax;*/
       filters[j].ampbuf[this]=acc;
       filters[j].ampptr++;
@@ -235,17 +234,17 @@ long _ve_envelope_search(vorbis_dsp_stat
     int ret=0;
 
     ve->stretch++;
     if(ve->stretch>VE_MAXSTRETCH*2)
       ve->stretch=VE_MAXSTRETCH*2;
     
     for(i=0;i<ve->ch;i++){
       float *pcm=v->pcm[i]+ve->searchstep*(j);
-      ret|=_ve_amp(ve,gi,pcm,ve->band,ve->filter+i*VE_BANDS,j);
+      ret|=_ve_amp(ve,gi,pcm,ve->band,ve->filter+i*VE_BANDS);
     }
 
     ve->mark[j+VE_POST]=0;
     if(ret&1){
       ve->mark[j]=1;
       ve->mark[j+1]=1;
     }
 
@@ -271,60 +270,60 @@ long _ve_envelope_search(vorbis_dsp_stat
     
     while(j<ve->current-(ve->searchstep)){/* account for postecho
                                              working back one window */
       if(j>=testW)return(1);
  
       ve->cursor=j;
 
       if(ve->mark[j/ve->searchstep]){
-	if(j>centerW){
+        if(j>centerW){
 
 #if 0
-	  if(j>ve->curmark){
-	    float *marker=alloca(v->pcm_current*sizeof(*marker));
-	    int l,m;
-	    memset(marker,0,sizeof(*marker)*v->pcm_current);
-	    fprintf(stderr,"mark! seq=%d, cursor:%fs time:%fs\n",
-		    seq,
-		    (totalshift+ve->cursor)/44100.,
-		    (totalshift+j)/44100.);
-	    _analysis_output_always("pcmL",seq,v->pcm[0],v->pcm_current,0,0,totalshift);
-	    _analysis_output_always("pcmR",seq,v->pcm[1],v->pcm_current,0,0,totalshift);
+          if(j>ve->curmark){
+            float *marker=alloca(v->pcm_current*sizeof(*marker));
+            int l,m;
+            memset(marker,0,sizeof(*marker)*v->pcm_current);
+            fprintf(stderr,"mark! seq=%d, cursor:%fs time:%fs\n",
+                    seq,
+                    (totalshift+ve->cursor)/44100.,
+                    (totalshift+j)/44100.);
+            _analysis_output_always("pcmL",seq,v->pcm[0],v->pcm_current,0,0,totalshift);
+            _analysis_output_always("pcmR",seq,v->pcm[1],v->pcm_current,0,0,totalshift);
 
-	    _analysis_output_always("markL",seq,v->pcm[0],j,0,0,totalshift);
-	    _analysis_output_always("markR",seq,v->pcm[1],j,0,0,totalshift);
-	    
-	    for(m=0;m<VE_BANDS;m++){
-	      char buf[80];
-	      sprintf(buf,"delL%d",m);
-	      for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[m].markers[l]*.1;
-	      _analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift);
-	    }
+            _analysis_output_always("markL",seq,v->pcm[0],j,0,0,totalshift);
+            _analysis_output_always("markR",seq,v->pcm[1],j,0,0,totalshift);
+            
+            for(m=0;m<VE_BANDS;m++){
+              char buf[80];
+              sprintf(buf,"delL%d",m);
+              for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[m].markers[l]*.1;
+              _analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift);
+            }
 
-	    for(m=0;m<VE_BANDS;m++){
-	      char buf[80];
-	      sprintf(buf,"delR%d",m);
-	      for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[m+VE_BANDS].markers[l]*.1;
-	      _analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift);
-	    }
+            for(m=0;m<VE_BANDS;m++){
+              char buf[80];
+              sprintf(buf,"delR%d",m);
+              for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[m+VE_BANDS].markers[l]*.1;
+              _analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift);
+            }
 
-	    for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->mark[l]*.4;
-	    _analysis_output_always("mark",seq,marker,v->pcm_current,0,0,totalshift);
-	   
-	    
-	    seq++;
-	    
-	  }
+            for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->mark[l]*.4;
+            _analysis_output_always("mark",seq,marker,v->pcm_current,0,0,totalshift);
+           
+            
+            seq++;
+            
+          }
 #endif
 
-	  ve->curmark=j;
-	  if(j>=testW)return(1);
-	  return(0);
-	}
+          ve->curmark=j;
+          if(j>=testW)return(1);
+          return(0);
+        }
       }
       j+=ve->searchstep;
     }
   }
   
   return(-1);
 }
 
@@ -351,26 +350,26 @@ int _ve_envelope_mark(vorbis_dsp_state *
     for(i=first;i<last;i++)
       if(ve->mark[i])return(1);
   }
   return(0);
 }
 
 void _ve_envelope_shift(envelope_lookup *e,long shift){
   int smallsize=e->current/e->searchstep+VE_POST; /* adjust for placing marks
-						     ahead of ve->current */
+                                                     ahead of ve->current */
   int smallshift=shift/e->searchstep;
 
   memmove(e->mark,e->mark+smallshift,(smallsize-smallshift)*sizeof(*e->mark));
   
 #if 0
   for(i=0;i<VE_BANDS*e->ch;i++)
     memmove(e->filter[i].markers,
-	    e->filter[i].markers+smallshift,
-	    (1024-smallshift)*sizeof(*(*e->filter).markers));
+            e->filter[i].markers+smallshift,
+            (1024-smallshift)*sizeof(*(*e->filter).markers));
   totalshift+=shift;
 #endif 
 
   e->current-=shift;
   if(e->curmark>=0)
     e->curmark-=shift;
   e->cursor-=shift;
 }
--- a/media/libvorbis/lib/vorbis_floor0.c
+++ b/media/libvorbis/lib/vorbis_floor0.c
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: floor backend 0 implementation
- last mod: $Id: floor0.c 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #include <stdlib.h>
 #include <string.h>
 #include <math.h>
 #include <ogg/ogg.h>
 #include "vorbis/codec.h"
@@ -103,18 +103,18 @@ static vorbis_info_floor *floor0_unpack 
    with static tables, but Vorbis allows a number of possible
    combinations, so it's best to do it computationally.
 
    The below is authoritative in terms of defining scale mapping.
    Note that the scale depends on the sampling rate as well as the
    linear block and mapping sizes */
 
 static void floor0_map_lazy_init(vorbis_block      *vb,
-				 vorbis_info_floor *infoX,
-				 vorbis_look_floor0 *look){
+                                 vorbis_info_floor *infoX,
+                                 vorbis_look_floor0 *look){
   if(!look->linearmap[vb->W]){
     vorbis_dsp_state   *vd=vb->vd;
     vorbis_info        *vi=vd->vi;
     codec_setup_info   *ci=vi->codec_setup;
     vorbis_info_floor0 *info=(vorbis_info_floor0 *)infoX;
     int W=vb->W;
     int n=ci->blocksizes[W]/2,j;
 
@@ -127,27 +127,27 @@ static void floor0_map_lazy_init(vorbis_
        straightforward.  We do *not* make sure that the linear mapping
        does not skip bark-scale bins; the decoder simply skips them and
        the encoder may do what it wishes in filling them.  They're
        necessary in some mapping combinations to keep the scale spacing
        accurate */
     look->linearmap[W]=_ogg_malloc((n+1)*sizeof(**look->linearmap));
     for(j=0;j<n;j++){
       int val=floor( toBARK((info->rate/2.f)/n*j) 
-		     *scale); /* bark numbers represent band edges */
+                     *scale); /* bark numbers represent band edges */
       if(val>=look->ln)val=look->ln-1; /* guard against the approximation */
       look->linearmap[W][j]=val;
     }
     look->linearmap[W][j]=-1;
     look->n[W]=n;
   }
 }
 
 static vorbis_look_floor *floor0_look(vorbis_dsp_state *vd,
-				      vorbis_info_floor *i){
+                                      vorbis_info_floor *i){
   vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
   vorbis_look_floor0 *look=_ogg_calloc(1,sizeof(*look));
   look->m=info->order;
   look->ln=info->barkmap;
   look->vi=info;
 
   look->linearmap=_ogg_calloc(2,sizeof(*look->linearmap));
 
@@ -171,53 +171,53 @@ static void *floor0_inverse1(vorbis_bloc
       float last=0.f;
 
       /* the additional b->dim is a guard against any possible stack
          smash; b->dim is provably more than we can overflow the
          vector */
       float *lsp=_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+b->dim+1));
             
       for(j=0;j<look->m;j+=b->dim)
-	if(vorbis_book_decodev_set(b,lsp+j,&vb->opb,b->dim)==-1)goto eop;
+        if(vorbis_book_decodev_set(b,lsp+j,&vb->opb,b->dim)==-1)goto eop;
       for(j=0;j<look->m;){
-	for(k=0;k<b->dim;k++,j++)lsp[j]+=last;
-	last=lsp[j-1];
+        for(k=0;k<b->dim;k++,j++)lsp[j]+=last;
+        last=lsp[j-1];
       }
       
       lsp[look->m]=amp;
       return(lsp);
     }
   }
  eop:
   return(NULL);
 }
 
 static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i,
-			   void *memo,float *out){
+                           void *memo,float *out){
   vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
   vorbis_info_floor0 *info=look->vi;
   
   floor0_map_lazy_init(vb,info,look);
 
   if(memo){
     float *lsp=(float *)memo;
     float amp=lsp[look->m];
 
     /* take the coefficients back to a spectral envelope curve */
     vorbis_lsp_to_curve(out,
-			look->linearmap[vb->W],
-			look->n[vb->W],
-			look->ln,
-			lsp,look->m,amp,(float)info->ampdB);
+                        look->linearmap[vb->W],
+                        look->n[vb->W],
+                        look->ln,
+                        lsp,look->m,amp,(float)info->ampdB);
     return(1);
   }
   memset(out,0,sizeof(*out)*look->n[vb->W]);
   return(0);
 }
 
 /* export hooks */
-vorbis_func_floor floor0_exportbundle={
+const vorbis_func_floor floor0_exportbundle={
   NULL,&floor0_unpack,&floor0_look,&floor0_free_info,
   &floor0_free_look,&floor0_inverse1,&floor0_inverse2
 };
 
 
 
--- a/media/libvorbis/lib/vorbis_floor1.c
+++ b/media/libvorbis/lib/vorbis_floor1.c
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: floor backend 1 implementation
- last mod: $Id: floor1.c 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #include <stdlib.h>
 #include <string.h>
 #include <math.h>
 #include <ogg/ogg.h>
 #include "vorbis/codec.h"
@@ -25,34 +25,16 @@
 #include "codebook.h"
 #include "misc.h"
 #include "scales.h"
 
 #include <stdio.h>
 
 #define floor1_rangedB 140 /* floor 1 fixed at -140dB to 0dB range */
 
-typedef struct {
-  int sorted_index[VIF_POSIT+2];
-  int forward_index[VIF_POSIT+2];
-  int reverse_index[VIF_POSIT+2];
-  
-  int hineighbor[VIF_POSIT];
-  int loneighbor[VIF_POSIT];
-  int posts;
-
-  int n;
-  int quant_q;
-  vorbis_info_floor1 *vi;
-
-  long phrasebits;
-  long postbits;
-  long frames;
-} vorbis_look_floor1;
-
 typedef struct lsfit_acc{
   long x0;
   long x1;
 
   long xa;
   long ya;
   long x2a;
   long y2a;
@@ -69,19 +51,19 @@ static void floor1_free_info(vorbis_info
     _ogg_free(info);
   }
 }
 
 static void floor1_free_look(vorbis_look_floor *i){
   vorbis_look_floor1 *look=(vorbis_look_floor1 *)i;
   if(look){
     /*fprintf(stderr,"floor 1 bit usage %f:%f (%f total)\n",
-	    (float)look->phrasebits/look->frames,
-	    (float)look->postbits/look->frames,
-	    (float)(look->postbits+look->phrasebits)/look->frames);*/
+            (float)look->phrasebits/look->frames,
+            (float)look->postbits/look->frames,
+            (float)(look->postbits+look->phrasebits)/look->frames);*/
 
     memset(look,0,sizeof(*look));
     _ogg_free(look);
   }
 }
 
 static int ilog(unsigned int v){
   int ret=0;
@@ -133,16 +115,19 @@ static void floor1_pack (vorbis_info_flo
 
   for(j=0,k=0;j<info->partitions;j++){
     count+=info->class_dim[info->partitionclass[j]]; 
     for(;k<count;k++)
       oggpack_write(opb,info->postlist[k+2],rangebits);
   }
 }
 
+static int icomp(const void *a,const void *b){
+  return(**(int **)a-**(int **)b);
+}
 
 static vorbis_info_floor *floor1_unpack (vorbis_info *vi,oggpack_buffer *opb){
   codec_setup_info     *ci=vi->codec_setup;
   int j,k,count=0,maxclass=-1,rangebits;
 
   vorbis_info_floor1 *info=_ogg_calloc(1,sizeof(*info));
   /* read partitions */
   info->partitions=oggpack_read(opb,5); /* only 0 to 31 legal */
@@ -158,48 +143,55 @@ static vorbis_info_floor *floor1_unpack 
     if(info->class_subs[j]<0)
       goto err_out;
     if(info->class_subs[j])info->class_book[j]=oggpack_read(opb,8);
     if(info->class_book[j]<0 || info->class_book[j]>=ci->books)
       goto err_out;
     for(k=0;k<(1<<info->class_subs[j]);k++){
       info->class_subbook[j][k]=oggpack_read(opb,8)-1;
       if(info->class_subbook[j][k]<-1 || info->class_subbook[j][k]>=ci->books)
-	goto err_out;
+        goto err_out;
     }
   }
 
   /* read the post list */
   info->mult=oggpack_read(opb,2)+1;     /* only 1,2,3,4 legal now */ 
   rangebits=oggpack_read(opb,4);
 
   for(j=0,k=0;j<info->partitions;j++){
     count+=info->class_dim[info->partitionclass[j]]; 
     for(;k<count;k++){
       int t=info->postlist[k+2]=oggpack_read(opb,rangebits);
       if(t<0 || t>=(1<<rangebits))
-	goto err_out;
+        goto err_out;
     }
   }
   info->postlist[0]=0;
   info->postlist[1]=1<<rangebits;
 
+  /* don't allow repeated values in post list as they'd result in
+     zero-length segments */
+  {
+    int *sortpointer[VIF_POSIT+2];
+    for(j=0;j<count+2;j++)sortpointer[j]=info->postlist+j;
+    qsort(sortpointer,count+2,sizeof(*sortpointer),icomp);
+
+    for(j=1;j<count+2;j++)
+      if(*sortpointer[j-1]==*sortpointer[j])goto err_out;
+  }
+
   return(info);
-  
+
  err_out:
   floor1_free_info(info);
   return(NULL);
 }
 
-static int icomp(const void *a,const void *b){
-  return(**(int **)a-**(int **)b);
-}
-
 static vorbis_look_floor *floor1_look(vorbis_dsp_state *vd,
-				      vorbis_info_floor *in){
+                                      vorbis_info_floor *in){
 
   int *sortpointer[VIF_POSIT+2];
   vorbis_info_floor1 *info=(vorbis_info_floor1 *)in;
   vorbis_look_floor1 *look=_ogg_calloc(1,sizeof(*look));
   int i,j,n=0;
 
   look->vi=info;
   look->n=info->postlist[1];
@@ -220,17 +212,17 @@ static vorbis_look_floor *floor1_look(vo
   qsort(sortpointer,n,sizeof(*sortpointer),icomp);
 
   /* points from sort order back to range number */
   for(i=0;i<n;i++)look->forward_index[i]=sortpointer[i]-info->postlist;
   /* points from range order to sorted position */
   for(i=0;i<n;i++)look->reverse_index[look->forward_index[i]]=i;
   /* we actually need the post values too */
   for(i=0;i<n;i++)look->sorted_index[i]=info->postlist[look->forward_index[i]];
-  
+
   /* quantize values to multiplier spec */
   switch(info->mult){
   case 1: /* 1024 -> 256 */
     look->quant_q=256;
     break;
   case 2: /* 1024 -> 128 */
     look->quant_q=128;
     break;
@@ -248,55 +240,55 @@ static vorbis_look_floor *floor1_look(vo
     int lo=0;
     int hi=1;
     int lx=0;
     int hx=look->n;
     int currentx=info->postlist[i+2];
     for(j=0;j<i+2;j++){
       int x=info->postlist[j];
       if(x>lx && x<currentx){
-	lo=j;
-	lx=x;
+        lo=j;
+        lx=x;
       }
       if(x<hx && x>currentx){
-	hi=j;
-	hx=x;
+        hi=j;
+        hx=x;
       }
     }
     look->loneighbor[i]=lo;
     look->hineighbor[i]=hi;
   }
 
   return(look);
 }
 
 static int render_point(int x0,int x1,int y0,int y1,int x){
   y0&=0x7fff; /* mask off flag */
   y1&=0x7fff;
-    
+
   {
     int dy=y1-y0;
     int adx=x1-x0;
     int ady=abs(dy);
     int err=ady*(x-x0);
-    
+
     int off=err/adx;
     if(dy<0)return(y0-off);
     return(y0+off);
   }
 }
 
 static int vorbis_dBquant(const float *x){
   int i= *x*7.3142857f+1023.5f;
   if(i>1023)return(1023);
   if(i<0)return(0);
   return i;
 }
 
-static float FLOOR1_fromdB_LOOKUP[256]={
+static const float FLOOR1_fromdB_LOOKUP[256]={
   1.0649863e-07F, 1.1341951e-07F, 1.2079015e-07F, 1.2863978e-07F, 
   1.3699951e-07F, 1.4590251e-07F, 1.5538408e-07F, 1.6548181e-07F, 
   1.7623575e-07F, 1.8768855e-07F, 1.9988561e-07F, 2.128753e-07F, 
   2.2670913e-07F, 2.4144197e-07F, 2.5713223e-07F, 2.7384213e-07F, 
   2.9163793e-07F, 3.1059021e-07F, 3.3077411e-07F, 3.5226968e-07F, 
   3.7516214e-07F, 3.9954229e-07F, 4.2550680e-07F, 4.5315863e-07F, 
   4.8260743e-07F, 5.1396998e-07F, 5.4737065e-07F, 5.8294187e-07F, 
   6.2082472e-07F, 6.6116941e-07F, 7.0413592e-07F, 7.4989464e-07F, 
@@ -409,45 +401,44 @@ static void render_line0(int x0,int x1,i
       y+=base;
     }
     d[x]=y;
   }
 }
 
 /* the floor has already been filtered to only include relevant sections */
 static int accumulate_fit(const float *flr,const float *mdct,
-			  int x0, int x1,lsfit_acc *a,
-			  int n,vorbis_info_floor1 *info){
+                          int x0, int x1,lsfit_acc *a,
+                          int n,vorbis_info_floor1 *info){
   long i;
-  int quantized=vorbis_dBquant(flr+x0);
 
   long xa=0,ya=0,x2a=0,y2a=0,xya=0,na=0, xb=0,yb=0,x2b=0,y2b=0,xyb=0,nb=0;
 
   memset(a,0,sizeof(*a));
   a->x0=x0;
   a->x1=x1;
   if(x1>=n)x1=n-1;
 
   for(i=x0;i<=x1;i++){
     int quantized=vorbis_dBquant(flr+i);
     if(quantized){
       if(mdct[i]+info->twofitatten>=flr[i]){
-	xa  += i;
-	ya  += quantized;
-	x2a += i*i;
-	y2a += quantized*quantized;
-	xya += i*quantized;
-	na++;
+        xa  += i;
+        ya  += quantized;
+        x2a += i*i;
+        y2a += quantized*quantized;
+        xya += i*quantized;
+        na++;
       }else{
-	xb  += i;
-	yb  += quantized;
-	x2b += i*i;
-	y2b += quantized*quantized;
-	xyb += i*quantized;
-	nb++;
+        xb  += i;
+        yb  += quantized;
+        x2b += i*i;
+        y2b += quantized*quantized;
+        xyb += i*quantized;
+        nb++;
       }
     }
   }
 
   xb+=xa;
   yb+=ya;
   x2b+=x2a;
   y2b+=y2a;
@@ -464,17 +455,17 @@ static int accumulate_fit(const float *f
     a->y2a=y2a*weight+y2b;
     a->xya=xya*weight+xyb;
     a->an=na*weight+nb;
   }
 
   return(na);
 }
 
-static void fit_line(lsfit_acc *a,int fits,int *y0,int *y1){
+static int fit_line(lsfit_acc *a,int fits,int *y0,int *y1){
   long x=0,y=0,x2=0,y2=0,xy=0,an=0,i;
   long x0=a[0].x0;
   long x1=a[fits-1].x1;
 
   for(i=0;i<fits;i++){
     x+=a[i].xa;
     y+=a[i].ya;
     x2+=a[i].x2a;
@@ -495,68 +486,74 @@ static void fit_line(lsfit_acc *a,int fi
   if(*y1>=0){
     x+=   x1;
     y+=  *y1;
     x2+=  x1 *  x1;
     y2+= *y1 * *y1;
     xy+= *y1 *  x1;
     an++;
   }
-  
-  if(an){
+
+  {
     /* need 64 bit multiplies, which C doesn't give portably as int */
     double fx=x;
-    double fy=y;
     double fx2=x2;
-    double fxy=xy;
-    double denom=1./(an*fx2-fx*fx);
-    double a=(fy*fx2-fxy*fx)*denom;
-    double b=(an*fxy-fx*fy)*denom;
-    *y0=rint(a+b*x0);
-    *y1=rint(a+b*x1);
-    
-    /* limit to our range! */
-    if(*y0>1023)*y0=1023;
-    if(*y1>1023)*y1=1023;
-    if(*y0<0)*y0=0;
-    if(*y1<0)*y1=0;
-    
-  }else{
-    *y0=0;
-    *y1=0;
+    double denom=(an*fx2-fx*fx);
+
+    if(denom>0.){
+      double fy=y;
+      double fxy=xy;
+
+      double a=(fy*fx2-fxy*fx)/denom;
+      double b=(an*fxy-fx*fy)/denom;
+      *y0=rint(a+b*x0);
+      *y1=rint(a+b*x1);
+
+      /* limit to our range! */
+      if(*y0>1023)*y0=1023;
+      if(*y1>1023)*y1=1023;
+      if(*y0<0)*y0=0;
+      if(*y1<0)*y1=0;
+      
+      return 0;
+    }else{
+      *y0=0;
+      *y1=0;
+      return 1;
+    }
   }
 }
 
 /*static void fit_line_point(lsfit_acc *a,int fits,int *y0,int *y1){
   long y=0;
   int i;
 
   for(i=0;i<fits && y==0;i++)
     y+=a[i].ya;
-  
+
   *y0=*y1=y;
   }*/
 
 static int inspect_error(int x0,int x1,int y0,int y1,const float *mask,
-			 const float *mdct,
-			 vorbis_info_floor1 *info){
+                         const float *mdct,
+                         vorbis_info_floor1 *info){
   int dy=y1-y0;
   int adx=x1-x0;
   int ady=abs(dy);
   int base=dy/adx;
   int sy=(dy<0?base-1:base+1);
   int x=x0;
   int y=y0;
   int err=0;
   int val=vorbis_dBquant(mask+x);
   int mse=0;
   int n=0;
 
   ady-=abs(base*adx);
-  
+
   mse=(y-val);
   mse*=mse;
   n++;
   if(mdct[x]+info->twofitatten>=mask[x]){
     if(y+info->maxover<val)return(1);
     if(y-info->maxunder>val)return(1);
   }
 
@@ -569,42 +566,40 @@ static int inspect_error(int x0,int x1,i
       y+=base;
     }
 
     val=vorbis_dBquant(mask+x);
     mse+=((y-val)*(y-val));
     n++;
     if(mdct[x]+info->twofitatten>=mask[x]){
       if(val){
-	if(y+info->maxover<val)return(1);
-	if(y-info->maxunder>val)return(1);
+        if(y+info->maxover<val)return(1);
+        if(y-info->maxunder>val)return(1);
       }
     }
   }
-  
+
   if(info->maxover*info->maxover/n>info->maxerr)return(0);
   if(info->maxunder*info->maxunder/n>info->maxerr)return(0);
   if(mse/n>info->maxerr)return(1);
   return(0);
 }
 
 static int post_Y(int *A,int *B,int pos){
   if(A[pos]<0)
     return B[pos];
   if(B[pos]<0)
     return A[pos];
 
   return (A[pos]+B[pos])>>1;
 }
 
-static int seq=0;
-
 int *floor1_fit(vorbis_block *vb,vorbis_look_floor1 *look,
-			  const float *logmdct,   /* in */
-			  const float *logmask){
+                          const float *logmdct,   /* in */
+                          const float *logmask){
   long i,j;
   vorbis_info_floor1 *info=look->vi;
   long n=look->n;
   long posts=look->posts;
   long nonzero=0;
   lsfit_acc fits[VIF_POSIT+1];
   int fit_valueA[VIF_POSIT+2]; /* index by range list position */
   int fit_valueB[VIF_POSIT+2]; /* index by range list position */
@@ -622,18 +617,18 @@ int *floor1_fit(vorbis_block *vb,vorbis_
 
   /* quantize the relevant floor points and collect them into line fit
      structures (one per minimal division) at the same time */
   if(posts==0){
     nonzero+=accumulate_fit(logmask,logmdct,0,n,fits,n,info);
   }else{
     for(i=0;i<posts-1;i++)
       nonzero+=accumulate_fit(logmask,logmdct,look->sorted_index[i],
-			      look->sorted_index[i+1],fits+i,
-			      n,info);
+                              look->sorted_index[i+1],fits+i,
+                              n,info);
   }
   
   if(nonzero){
     /* start by fitting the implicit base case.... */
     int y0=-200;
     int y1=-200;
     fit_line(fits,posts-1,&y0,&y1);
 
@@ -645,336 +640,345 @@ int *floor1_fit(vorbis_block *vb,vorbis_
     /* Non degenerate case */
     /* start progressive splitting.  This is a greedy, non-optimal
        algorithm, but simple and close enough to the best
        answer. */
     for(i=2;i<posts;i++){
       int sortpos=look->reverse_index[i];
       int ln=loneighbor[sortpos];
       int hn=hineighbor[sortpos];
-      
+
       /* eliminate repeat searches of a particular range with a memo */
       if(memo[ln]!=hn){
-	/* haven't performed this error search yet */
-	int lsortpos=look->reverse_index[ln];
-	int hsortpos=look->reverse_index[hn];
-	memo[ln]=hn;
-		
-	{
-	  /* A note: we want to bound/minimize *local*, not global, error */
-	  int lx=info->postlist[ln];
-	  int hx=info->postlist[hn];	  
-	  int ly=post_Y(fit_valueA,fit_valueB,ln);
-	  int hy=post_Y(fit_valueA,fit_valueB,hn);
-	  
-	  if(ly==-1 || hy==-1){
-	    exit(1);
-	  }
+        /* haven't performed this error search yet */
+        int lsortpos=look->reverse_index[ln];
+        int hsortpos=look->reverse_index[hn];
+        memo[ln]=hn;
+                
+        {
+          /* A note: we want to bound/minimize *local*, not global, error */
+          int lx=info->postlist[ln];
+          int hx=info->postlist[hn];          
+          int ly=post_Y(fit_valueA,fit_valueB,ln);
+          int hy=post_Y(fit_valueA,fit_valueB,hn);
+
+          if(ly==-1 || hy==-1){
+            exit(1);
+          }
+
+          if(inspect_error(lx,hx,ly,hy,logmask,logmdct,info)){
+            /* outside error bounds/begin search area.  Split it. */
+            int ly0=-200;
+            int ly1=-200;
+            int hy0=-200;
+            int hy1=-200;
+            int ret0=fit_line(fits+lsortpos,sortpos-lsortpos,&ly0,&ly1);
+            int ret1=fit_line(fits+sortpos,hsortpos-sortpos,&hy0,&hy1);
 
-	  if(inspect_error(lx,hx,ly,hy,logmask,logmdct,info)){
-	    /* outside error bounds/begin search area.  Split it. */
-	    int ly0=-200;
-	    int ly1=-200;
-	    int hy0=-200;
-	    int hy1=-200;
-	    fit_line(fits+lsortpos,sortpos-lsortpos,&ly0,&ly1);
-	    fit_line(fits+sortpos,hsortpos-sortpos,&hy0,&hy1);
-	    
-	    /* store new edge values */
-	    fit_valueB[ln]=ly0;
-	    if(ln==0)fit_valueA[ln]=ly0;
-	    fit_valueA[i]=ly1;
-	    fit_valueB[i]=hy0;
-	    fit_valueA[hn]=hy1;
-	    if(hn==1)fit_valueB[hn]=hy1;
-	    
-	    if(ly1>=0 || hy0>=0){
-	      /* store new neighbor values */
-	      for(j=sortpos-1;j>=0;j--)
-		if(hineighbor[j]==hn)
-		  hineighbor[j]=i;
-		else
-		  break;
-	      for(j=sortpos+1;j<posts;j++)
-		if(loneighbor[j]==ln)
-		  loneighbor[j]=i;
-		else
-		  break;
-	      
-	    }
-	  }else{
-	    
-	    fit_valueA[i]=-200;
-	    fit_valueB[i]=-200;
-	  }
-	}
+            if(ret0){
+              ly0=ly;
+              ly1=hy0;
+            }
+            if(ret1){
+              hy0=ly1;
+              hy1=hy;
+            }
+
+            if(ret0 && ret1){
+              fit_valueA[i]=-200;
+              fit_valueB[i]=-200;
+            }else{
+              /* store new edge values */
+              fit_valueB[ln]=ly0;
+              if(ln==0)fit_valueA[ln]=ly0;
+              fit_valueA[i]=ly1;
+              fit_valueB[i]=hy0;
+              fit_valueA[hn]=hy1;
+              if(hn==1)fit_valueB[hn]=hy1;
+              
+              if(ly1>=0 || hy0>=0){
+                /* store new neighbor values */
+                for(j=sortpos-1;j>=0;j--)
+                  if(hineighbor[j]==hn)
+                    hineighbor[j]=i;
+                  else
+                    break;
+                for(j=sortpos+1;j<posts;j++)
+                  if(loneighbor[j]==ln)
+                    loneighbor[j]=i;
+                  else
+                    break;
+              }
+            }
+          }else{
+            fit_valueA[i]=-200;
+            fit_valueB[i]=-200;
+          }
+        }
       }
     }
-  
+
     output=_vorbis_block_alloc(vb,sizeof(*output)*posts);
-    
+
     output[0]=post_Y(fit_valueA,fit_valueB,0);
     output[1]=post_Y(fit_valueA,fit_valueB,1);
-    
+
     /* fill in posts marked as not using a fit; we will zero
        back out to 'unused' when encoding them so long as curve
        interpolation doesn't force them into use */
     for(i=2;i<posts;i++){
       int ln=look->loneighbor[i-2];
       int hn=look->hineighbor[i-2];
       int x0=info->postlist[ln];
       int x1=info->postlist[hn];
       int y0=output[ln];
       int y1=output[hn];
-      
+
       int predicted=render_point(x0,x1,y0,y1,info->postlist[i]);
       int vx=post_Y(fit_valueA,fit_valueB,i);
-      
+
       if(vx>=0 && predicted!=vx){ 
-	output[i]=vx;
+        output[i]=vx;
       }else{
-	output[i]= predicted|0x8000;
+        output[i]= predicted|0x8000;
       }
     }
   }
 
   return(output);
-  
+
 }
-		
+                
 int *floor1_interpolate_fit(vorbis_block *vb,vorbis_look_floor1 *look,
-			  int *A,int *B,
-			  int del){
+                          int *A,int *B,
+                          int del){
 
   long i;
   long posts=look->posts;
   int *output=NULL;
-  
+
   if(A && B){
     output=_vorbis_block_alloc(vb,sizeof(*output)*posts);
-    
+
+    /* overly simpleminded--- look again post 1.2 */
     for(i=0;i<posts;i++){
       output[i]=((65536-del)*(A[i]&0x7fff)+del*(B[i]&0x7fff)+32768)>>16;
       if(A[i]&0x8000 && B[i]&0x8000)output[i]|=0x8000;
     }
   }
 
   return(output);
 }
 
 
 int floor1_encode(oggpack_buffer *opb,vorbis_block *vb,
-		  vorbis_look_floor1 *look,
-		  int *post,int *ilogmask){
+                  vorbis_look_floor1 *look,
+                  int *post,int *ilogmask){
 
   long i,j;
   vorbis_info_floor1 *info=look->vi;
-  long n=look->n;
   long posts=look->posts;
   codec_setup_info *ci=vb->vd->vi->codec_setup;
   int out[VIF_POSIT+2];
   static_codebook **sbooks=ci->book_param;
   codebook *books=ci->fullbooks;
-  static long seq=0; 
 
   /* quantize values to multiplier spec */
   if(post){
     for(i=0;i<posts;i++){
       int val=post[i]&0x7fff;
       switch(info->mult){
       case 1: /* 1024 -> 256 */
-	val>>=2;
-	break;
+        val>>=2;
+        break;
       case 2: /* 1024 -> 128 */
-	val>>=3;
-	break;
+        val>>=3;
+        break;
       case 3: /* 1024 -> 86 */
-	val/=12;
-	break;
+        val/=12;
+        break;
       case 4: /* 1024 -> 64 */
-	val>>=4;
-	break;
+        val>>=4;
+        break;
       }
       post[i]=val | (post[i]&0x8000);
     }
 
     out[0]=post[0];
     out[1]=post[1];
 
     /* find prediction values for each post and subtract them */
     for(i=2;i<posts;i++){
       int ln=look->loneighbor[i-2];
       int hn=look->hineighbor[i-2];
       int x0=info->postlist[ln];
       int x1=info->postlist[hn];
       int y0=post[ln];
       int y1=post[hn];
-      
+
       int predicted=render_point(x0,x1,y0,y1,info->postlist[i]);
-      
+
       if((post[i]&0x8000) || (predicted==post[i])){
-	post[i]=predicted|0x8000; /* in case there was roundoff jitter
-				     in interpolation */
-	out[i]=0;
+        post[i]=predicted|0x8000; /* in case there was roundoff jitter
+                                     in interpolation */
+        out[i]=0;
       }else{
-	int headroom=(look->quant_q-predicted<predicted?
-		      look->quant_q-predicted:predicted);
-	
-	int val=post[i]-predicted;
-	
-	/* at this point the 'deviation' value is in the range +/- max
-	   range, but the real, unique range can always be mapped to
-	   only [0-maxrange).  So we want to wrap the deviation into
-	   this limited range, but do it in the way that least screws
-	   an essentially gaussian probability distribution. */
-	
-	if(val<0)
-	  if(val<-headroom)
-	    val=headroom-val-1;
-	  else
-	    val=-1-(val<<1);
-	else
-	  if(val>=headroom)
-	    val= val+headroom;
-	  else
-	    val<<=1;
-	
-	out[i]=val;
-	post[ln]&=0x7fff;
-	post[hn]&=0x7fff;
+        int headroom=(look->quant_q-predicted<predicted?
+                      look->quant_q-predicted:predicted);
+        
+        int val=post[i]-predicted;
+        
+        /* at this point the 'deviation' value is in the range +/- max
+           range, but the real, unique range can always be mapped to
+           only [0-maxrange).  So we want to wrap the deviation into
+           this limited range, but do it in the way that least screws
+           an essentially gaussian probability distribution. */
+        
+        if(val<0)
+          if(val<-headroom)
+            val=headroom-val-1;
+          else
+            val=-1-(val<<1);
+        else
+          if(val>=headroom)
+            val= val+headroom;
+          else
+            val<<=1;
+        
+        out[i]=val;
+        post[ln]&=0x7fff;
+        post[hn]&=0x7fff;
       }
     }
-    
+
     /* we have everything we need. pack it out */
     /* mark nontrivial floor */
     oggpack_write(opb,1,1);
-      
+
     /* beginning/end post */
     look->frames++;
     look->postbits+=ilog(look->quant_q-1)*2;
     oggpack_write(opb,out[0],ilog(look->quant_q-1));
     oggpack_write(opb,out[1],ilog(look->quant_q-1));
-      
-      
+
+
     /* partition by partition */
     for(i=0,j=2;i<info->partitions;i++){
       int class=info->partitionclass[i];
       int cdim=info->class_dim[class];
       int csubbits=info->class_subs[class];
       int csub=1<<csubbits;
       int bookas[8]={0,0,0,0,0,0,0,0};
       int cval=0;
       int cshift=0;
       int k,l;
 
       /* generate the partition's first stage cascade value */
       if(csubbits){
-	int maxval[8];
-	for(k=0;k<csub;k++){
-	  int booknum=info->class_subbook[class][k];
-	  if(booknum<0){
-	    maxval[k]=1;
-	  }else{
-	    maxval[k]=sbooks[info->class_subbook[class][k]]->entries;
-	  }
-	}
-	for(k=0;k<cdim;k++){
-	  for(l=0;l<csub;l++){
-	    int val=out[j+k];
-	    if(val<maxval[l]){
-	      bookas[k]=l;
-	      break;
-	    }
-	  }
-	  cval|= bookas[k]<<cshift;
-	  cshift+=csubbits;
-	}
-	/* write it */
-	look->phrasebits+=
-	  vorbis_book_encode(books+info->class_book[class],cval,opb);
-	
+        int maxval[8];
+        for(k=0;k<csub;k++){
+          int booknum=info->class_subbook[class][k];
+          if(booknum<0){
+            maxval[k]=1;
+          }else{
+            maxval[k]=sbooks[info->class_subbook[class][k]]->entries;
+          }
+        }
+        for(k=0;k<cdim;k++){
+          for(l=0;l<csub;l++){
+            int val=out[j+k];
+            if(val<maxval[l]){
+              bookas[k]=l;
+              break;
+            }
+          }
+          cval|= bookas[k]<<cshift;
+          cshift+=csubbits;
+        }
+        /* write it */
+        look->phrasebits+=
+          vorbis_book_encode(books+info->class_book[class],cval,opb);
+        
 #ifdef TRAIN_FLOOR1
-	{
-	  FILE *of;
-	  char buffer[80];
-	  sprintf(buffer,"line_%dx%ld_class%d.vqd",
-		  vb->pcmend/2,posts-2,class);
-	  of=fopen(buffer,"a");
-	  fprintf(of,"%d\n",cval);
-	  fclose(of);
-	}
+        {
+          FILE *of;
+          char buffer[80];
+          sprintf(buffer,"line_%dx%ld_class%d.vqd",
+                  vb->pcmend/2,posts-2,class);
+          of=fopen(buffer,"a");
+          fprintf(of,"%d\n",cval);
+          fclose(of);
+        }
 #endif
       }
-	
+        
       /* write post values */
       for(k=0;k<cdim;k++){
-	int book=info->class_subbook[class][bookas[k]];
-	if(book>=0){
-	  /* hack to allow training with 'bad' books */
-	  if(out[j+k]<(books+book)->entries)
-	    look->postbits+=vorbis_book_encode(books+book,
-					       out[j+k],opb);
-	  /*else
-	    fprintf(stderr,"+!");*/
-	  
+        int book=info->class_subbook[class][bookas[k]];
+        if(book>=0){
+          /* hack to allow training with 'bad' books */
+          if(out[j+k]<(books+book)->entries)
+            look->postbits+=vorbis_book_encode(books+book,
+                                               out[j+k],opb);
+          /*else
+            fprintf(stderr,"+!");*/
+
 #ifdef TRAIN_FLOOR1
-	  {
-	    FILE *of;
-	    char buffer[80];
-	    sprintf(buffer,"line_%dx%ld_%dsub%d.vqd",
-		    vb->pcmend/2,posts-2,class,bookas[k]);
-	    of=fopen(buffer,"a");
-	    fprintf(of,"%d\n",out[j+k]);
-	    fclose(of);
-	  }
+          {
+            FILE *of;
+            char buffer[80];
+            sprintf(buffer,"line_%dx%ld_%dsub%d.vqd",
+                    vb->pcmend/2,posts-2,class,bookas[k]);
+            of=fopen(buffer,"a");
+            fprintf(of,"%d\n",out[j+k]);
+            fclose(of);
+          }
 #endif
-	}
+        }
       }
       j+=cdim;
     }
-    
+
     {
       /* generate quantized floor equivalent to what we'd unpack in decode */
       /* render the lines */
       int hx=0;
       int lx=0;
       int ly=post[0]*info->mult;
       for(j=1;j<look->posts;j++){
-	int current=look->forward_index[j];
-	int hy=post[current]&0x7fff;
-	if(hy==post[current]){
-	  
-	  hy*=info->mult;
-	  hx=info->postlist[current];
-	
-	  render_line0(lx,hx,ly,hy,ilogmask);
-	
-	  lx=hx;
-	  ly=hy;
-	}
+        int current=look->forward_index[j];
+        int hy=post[current]&0x7fff;
+        if(hy==post[current]){
+
+          hy*=info->mult;
+          hx=info->postlist[current];
+        
+          render_line0(lx,hx,ly,hy,ilogmask);
+        
+          lx=hx;
+          ly=hy;
+        }
       }
-      for(j=hx;j<vb->pcmend/2;j++)ilogmask[j]=ly; /* be certain */    
-      seq++;
+      for(j=hx;j<vb->pcmend/2;j++)ilogmask[j]=ly; /* be certain */
       return(1);
     }
   }else{
     oggpack_write(opb,0,1);
     memset(ilogmask,0,vb->pcmend/2*sizeof(*ilogmask));
-    seq++;
     return(0);
   }
 }
 
 static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in){
   vorbis_look_floor1 *look=(vorbis_look_floor1 *)in;
   vorbis_info_floor1 *info=look->vi;
   codec_setup_info   *ci=vb->vd->vi->codec_setup;
-  
+
   int i,j,k;
-  codebook *books=ci->fullbooks;   
+  codebook *books=ci->fullbooks;
 
   /* unpack wrapped/predicted values from stream */
   if(oggpack_read(&vb->opb,1)==1){
     int *fit_value=_vorbis_block_alloc(vb,(look->posts)*sizeof(*fit_value));
 
     fit_value[0]=oggpack_read(&vb->opb,ilog(look->quant_q-1));
     fit_value[1]=oggpack_read(&vb->opb,ilog(look->quant_q-1));
 
@@ -983,79 +987,79 @@ static void *floor1_inverse1(vorbis_bloc
       int class=info->partitionclass[i];
       int cdim=info->class_dim[class];
       int csubbits=info->class_subs[class];
       int csub=1<<csubbits;
       int cval=0;
 
       /* decode the partition's first stage cascade value */
       if(csubbits){
-	cval=vorbis_book_decode(books+info->class_book[class],&vb->opb);
+        cval=vorbis_book_decode(books+info->class_book[class],&vb->opb);
 
-	if(cval==-1)goto eop;
+        if(cval==-1)goto eop;
       }
 
       for(k=0;k<cdim;k++){
-	int book=info->class_subbook[class][cval&(csub-1)];
-	cval>>=csubbits;
-	if(book>=0){
-	  if((fit_value[j+k]=vorbis_book_decode(books+book,&vb->opb))==-1)
-	    goto eop;
-	}else{
-	  fit_value[j+k]=0;
-	}
+        int book=info->class_subbook[class][cval&(csub-1)];
+        cval>>=csubbits;
+        if(book>=0){
+          if((fit_value[j+k]=vorbis_book_decode(books+book,&vb->opb))==-1)
+            goto eop;
+        }else{
+          fit_value[j+k]=0;
+        }
       }
       j+=cdim;
     }
 
     /* unwrap positive values and reconsitute via linear interpolation */
     for(i=2;i<look->posts;i++){
       int predicted=render_point(info->postlist[look->loneighbor[i-2]],
-				 info->postlist[look->hineighbor[i-2]],
-				 fit_value[look->loneighbor[i-2]],
-				 fit_value[look->hineighbor[i-2]],
-				 info->postlist[i]);
+                                 info->postlist[look->hineighbor[i-2]],
+                                 fit_value[look->loneighbor[i-2]],
+                                 fit_value[look->hineighbor[i-2]],
+                                 info->postlist[i]);
       int hiroom=look->quant_q-predicted;
       int loroom=predicted;
       int room=(hiroom<loroom?hiroom:loroom)<<1;
       int val=fit_value[i];
 
       if(val){
-	if(val>=room){
-	  if(hiroom>loroom){
-	    val = val-loroom;
-	  }else{
-	    val = -1-(val-hiroom);
-	  }
-	}else{
-	  if(val&1){
-	    val= -((val+1)>>1);
-	  }else{
-	    val>>=1;
-	  }
-	}
+        if(val>=room){
+          if(hiroom>loroom){
+            val = val-loroom;
+          }else{
+            val = -1-(val-hiroom);
+          }
+        }else{
+          if(val&1){
+            val= -((val+1)>>1);
+          }else{
+            val>>=1;
+          }
+        }
 
-	fit_value[i]=val+predicted;
-	fit_value[look->loneighbor[i-2]]&=0x7fff;
-	fit_value[look->hineighbor[i-2]]&=0x7fff;
+        fit_value[i]=val+predicted;
+        fit_value[look->loneighbor[i-2]]&=0x7fff;
+        fit_value[look->hineighbor[i-2]]&=0x7fff;
 
       }else{
-	fit_value[i]=predicted|0x8000;
+        fit_value[i]=predicted|0x8000;
       }
-	
+        
     }
 
     return(fit_value);
   }
  eop:
   return(NULL);
 }
 
 static int floor1_inverse2(vorbis_block *vb,vorbis_look_floor *in,void *memo,
-			  float *out){
+                          float *out){
   vorbis_look_floor1 *look=(vorbis_look_floor1 *)in;
   vorbis_info_floor1 *info=look->vi;
 
   codec_setup_info   *ci=vb->vd->vi->codec_setup;
   int                  n=ci->blocksizes[vb->W]/2;
   int j;
 
   if(memo){
@@ -1063,32 +1067,30 @@ static int floor1_inverse2(vorbis_block 
     int *fit_value=(int *)memo;
     int hx=0;
     int lx=0;
     int ly=fit_value[0]*info->mult;
     for(j=1;j<look->posts;j++){
       int current=look->forward_index[j];
       int hy=fit_value[current]&0x7fff;
       if(hy==fit_value[current]){
-	
-	hy*=info->mult;
-	hx=info->postlist[current];
-	
-	render_line(n,lx,hx,ly,hy,out);
-	
-	lx=hx;
-	ly=hy;
+        
+        hy*=info->mult;
+        hx=info->postlist[current];
+        
+        render_line(n,lx,hx,ly,hy,out);
+        
+        lx=hx;
+        ly=hy;
       }
     }
-    for(j=hx;j<n;j++)out[j]*=FLOOR1_fromdB_LOOKUP[ly]; /* be certain */    
+    for(j=hx;j<n;j++)out[j]*=FLOOR1_fromdB_LOOKUP[ly]; /* be certain */
     return(1);
   }
   memset(out,0,sizeof(*out)*n);
   return(0);
 }
 
 /* export hooks */
-vorbis_func_floor floor1_exportbundle={
+const vorbis_func_floor floor1_exportbundle={
   &floor1_pack,&floor1_unpack,&floor1_look,&floor1_free_info,
   &floor1_free_look,&floor1_inverse1,&floor1_inverse2
 };
-
-
--- a/media/libvorbis/lib/vorbis_info.c
+++ b/media/libvorbis/lib/vorbis_info.c
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: maintain the info structure, info <-> header packets
- last mod: $Id: info.c 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 /* general handling of the header and the vorbis_info structure (and
    substructures) */
 
 #include <stdlib.h>
 #include <string.h>
@@ -27,57 +27,60 @@
 #include "codec_internal.h"
 #include "codebook.h"
 #include "registry.h"
 #include "window.h"
 #include "psy.h"
 #include "misc.h"
 #include "os.h"
 
+#define GENERAL_VENDOR_STRING "Xiph.Org libVorbis 1.2.2"
+#define ENCODE_VENDOR_STRING "Xiph.Org libVorbis I 20090624"
+
 /* helpers */
 static int ilog2(unsigned int v){
   int ret=0;
   if(v)--v;
   while(v){
     ret++;
     v>>=1;
   }
   return(ret);
 }
 
-static void _v_writestring(oggpack_buffer *o,char *s, int bytes){
+static void _v_writestring(oggpack_buffer *o,const char *s, int bytes){
 
   while(bytes--){
     oggpack_write(o,*s++,8);
   }
 }
 
 static void _v_readstring(oggpack_buffer *o,char *buf,int bytes){
   while(bytes--){
     *buf++=oggpack_read(o,8);
   }
 }
 
 void vorbis_comment_init(vorbis_comment *vc){
   memset(vc,0,sizeof(*vc));
 }
 
-void vorbis_comment_add(vorbis_comment *vc,char *comment){
+void vorbis_comment_add(vorbis_comment *vc,const char *comment){
   vc->user_comments=_ogg_realloc(vc->user_comments,
-			    (vc->comments+2)*sizeof(*vc->user_comments));
+                            (vc->comments+2)*sizeof(*vc->user_comments));
   vc->comment_lengths=_ogg_realloc(vc->comment_lengths,
-      			    (vc->comments+2)*sizeof(*vc->comment_lengths));
+                                  (vc->comments+2)*sizeof(*vc->comment_lengths));
   vc->comment_lengths[vc->comments]=strlen(comment);
   vc->user_comments[vc->comments]=_ogg_malloc(vc->comment_lengths[vc->comments]+1);
   strcpy(vc->user_comments[vc->comments], comment);
   vc->comments++;
   vc->user_comments[vc->comments]=NULL;
 }
 
-void vorbis_comment_add_tag(vorbis_comment *vc, char *tag, char *contents){
+void vorbis_comment_add_tag(vorbis_comment *vc, const char *tag, const char *contents){
   char *comment=alloca(strlen(tag)+strlen(contents)+2); /* +2 for = and \0 */
   strcpy(comment, tag);
   strcat(comment, "=");
   strcat(comment, contents);
   vorbis_comment_add(vc, comment);
 }
 
 /* This is more or less the same as strncasecmp - but that doesn't exist
@@ -87,38 +90,38 @@ static int tagcompare(const char *s1, co
   while(c < n){
     if(toupper(s1[c]) != toupper(s2[c]))
       return !0;
     c++;
   }
   return 0;
 }
 
-char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count){
+char *vorbis_comment_query(vorbis_comment *vc, const char *tag, int count){
   long i;
   int found = 0;
   int taglen = strlen(tag)+1; /* +1 for the = we append */
   char *fulltag = alloca(taglen+ 1);
 
   strcpy(fulltag, tag);
   strcat(fulltag, "=");
   
   for(i=0;i<vc->comments;i++){
     if(!tagcompare(vc->user_comments[i], fulltag, taglen)){
       if(count == found)
-	/* We return a pointer to the data, not a copy */
-      	return vc->user_comments[i] + taglen;
+        /* We return a pointer to the data, not a copy */
+              return vc->user_comments[i] + taglen;
       else
-	found++;
+        found++;
     }
   }
   return NULL; /* didn't find anything */
 }
 
-int vorbis_comment_query_count(vorbis_comment *vc, char *tag){
+int vorbis_comment_query_count(vorbis_comment *vc, const char *tag){
   int i,count=0;
   int taglen = strlen(tag)+1; /* +1 for the = we append */
   char *fulltag = alloca(taglen+1);
   strcpy(fulltag,tag);
   strcat(fulltag, "=");
 
   for(i=0;i<vc->comments;i++){
     if(!tagcompare(vc->user_comments[i], fulltag, taglen))
@@ -126,19 +129,19 @@ int vorbis_comment_query_count(vorbis_co
   }
 
   return count;
 }
 
 void vorbis_comment_clear(vorbis_comment *vc){
   if(vc){
     long i;
-    if (vc->user_comments) {
+    if(vc->user_comments){
       for(i=0;i<vc->comments;i++)
-	if(vc->user_comments[i])_ogg_free(vc->user_comments[i]);
+        if(vc->user_comments[i])_ogg_free(vc->user_comments[i]);
       _ogg_free(vc->user_comments);
     }
     if(vc->comment_lengths)_ogg_free(vc->comment_lengths);
     if(vc->vendor)_ogg_free(vc->vendor);
     memset(vc,0,sizeof(*vc));
   }
 }
 
@@ -161,42 +164,42 @@ void vorbis_info_clear(vorbis_info *vi){
 
   if(ci){
 
     for(i=0;i<ci->modes;i++)
       if(ci->mode_param[i])_ogg_free(ci->mode_param[i]);
 
     for(i=0;i<ci->maps;i++) /* unpack does the range checking */
       if(ci->map_param[i]) /* this may be cleaning up an aborted
-			      unpack, in which case the below type
-			      cannot be trusted */
-	_mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]);
+                              unpack, in which case the below type
+                              cannot be trusted */
+        _mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]);
 
     for(i=0;i<ci->floors;i++) /* unpack does the range checking */
       if(ci->floor_param[i]) /* this may be cleaning up an aborted
-				unpack, in which case the below type
-				cannot be trusted */
-	_floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]);
+                                unpack, in which case the below type
+                                cannot be trusted */
+        _floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]);
     
     for(i=0;i<ci->residues;i++) /* unpack does the range checking */
       if(ci->residue_param[i]) /* this may be cleaning up an aborted
-				  unpack, in which case the below type
-				  cannot be trusted */
-	_residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]);
+                                  unpack, in which case the below type
+                                  cannot be trusted */
+        _residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]);
     
     for(i=0;i<ci->books;i++){
       if(ci->book_param[i]){
-	/* knows if the book was not alloced */
-	vorbis_staticbook_destroy(ci->book_param[i]);
+        /* knows if the book was not alloced */
+        vorbis_staticbook_destroy(ci->book_param[i]);
       }
       if(ci->fullbooks)
-	vorbis_book_clear(ci->fullbooks+i);
+        vorbis_book_clear(ci->fullbooks+i);
     }
     if(ci->fullbooks)
-	_ogg_free(ci->fullbooks);
+        _ogg_free(ci->fullbooks);
     
     for(i=0;i<ci->psys;i++)
       _vi_psy_free(ci->psy_param[i]);
 
     _ogg_free(ci);
   }
 
   memset(vi,0,sizeof(*vi));
@@ -233,31 +236,35 @@ static int _vorbis_unpack_info(vorbis_in
  err_out:
   vorbis_info_clear(vi);
   return(OV_EBADHEADER);
 }
 
 static int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb){
   int i;
   int vendorlen=oggpack_read(opb,32);
-  if(vendorlen<0||vendorlen>opb->storage)goto err_out;
+  if(vendorlen<0)goto err_out;
+  if(vendorlen+8>opb->storage)goto err_out;
   vc->vendor=_ogg_calloc(vendorlen+1,1);
   _v_readstring(opb,vc->vendor,vendorlen);
-  vc->comments=oggpack_read(opb,32);
-  if(vc->comments<0||vc->comments>(LONG_MAX>>2)||vc->comments<<2>opb->storage)goto err_out;
+  i=oggpack_read(opb,32);
+  if(i<0)goto err_out;
+  if(4*i+oggpack_bytes(opb)>opb->storage)goto err_out;
+  vc->comments=i;
   vc->user_comments=_ogg_calloc(vc->comments+1,sizeof(*vc->user_comments));
   vc->comment_lengths=_ogg_calloc(vc->comments+1, sizeof(*vc->comment_lengths));
-	    
+            
   for(i=0;i<vc->comments;i++){
     int len=oggpack_read(opb,32);
-    if(len<0||len>opb->storage)goto err_out;
-	vc->comment_lengths[i]=len;
+    if(len<0)goto err_out;
+    if(len+oggpack_bytes(opb)>opb->storage)goto err_out;
+    vc->comment_lengths[i]=len;
     vc->user_comments[i]=_ogg_calloc(len+1,1);
     _v_readstring(opb,vc->user_comments[i],len);
-  }	  
+  }          
   if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */
 
   return(0);
  err_out:
   vorbis_comment_clear(vc);
   return(OV_EBADHEADER);
 }
 
@@ -380,52 +387,52 @@ int vorbis_synthesis_headerin(vorbis_inf
     /* Which of the three types of header is this? */
     /* Also verify header-ness, vorbis */
     {
       char buffer[6];
       int packtype=oggpack_read(&opb,8);
       memset(buffer,0,6);
       _v_readstring(&opb,buffer,6);
       if(memcmp(buffer,"vorbis",6)){
-	/* not a vorbis header */
-	return(OV_ENOTVORBIS);
+        /* not a vorbis header */
+        return(OV_ENOTVORBIS);
       }
       switch(packtype){
       case 0x01: /* least significant *bit* is read first */
-	if(!op->b_o_s){
-	  /* Not the initial packet */
-	  return(OV_EBADHEADER);
-	}
-	if(vi->rate!=0){
-	  /* previously initialized info header */
-	  return(OV_EBADHEADER);
-	}
+        if(!op->b_o_s){
+          /* Not the initial packet */
+          return(OV_EBADHEADER);
+        }
+        if(vi->rate!=0){
+          /* previously initialized info header */
+          return(OV_EBADHEADER);
+        }
 
-	return(_vorbis_unpack_info(vi,&opb));
+        return(_vorbis_unpack_info(vi,&opb));
 
       case 0x03: /* least significant *bit* is read first */
-	if(vi->rate==0){
-	  /* um... we didn't get the initial header */
-	  return(OV_EBADHEADER);
-	}
+        if(vi->rate==0){
+          /* um... we didn't get the initial header */
+          return(OV_EBADHEADER);
+        }
 
-	return(_vorbis_unpack_comment(vc,&opb));
+        return(_vorbis_unpack_comment(vc,&opb));
 
       case 0x05: /* least significant *bit* is read first */
-	if(vi->rate==0 || vc->vendor==NULL){
-	  /* um... we didn;t get the initial header or comments yet */
-	  return(OV_EBADHEADER);
-	}
+        if(vi->rate==0 || vc->vendor==NULL){
+          /* um... we didn;t get the initial header or comments yet */
+          return(OV_EBADHEADER);
+        }
 
-	return(_vorbis_unpack_books(vi,&opb));
+        return(_vorbis_unpack_books(vi,&opb));
 
       default:
-	/* Not a valid vorbis header type */
-	return(OV_EBADHEADER);
-	break;
+        /* Not a valid vorbis header type */
+        return(OV_EBADHEADER);
+        break;
       }
     }
   }
   return(OV_EBADHEADER);
 }
 
 /* pack side **********************************************************/
 
@@ -449,38 +456,37 @@ static int _vorbis_pack_info(oggpack_buf
   oggpack_write(opb,ilog2(ci->blocksizes[0]),4);
   oggpack_write(opb,ilog2(ci->blocksizes[1]),4);
   oggpack_write(opb,1,1);
 
   return(0);
 }
 
 static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){
-  char temp[]="Xiph.Org libVorbis I 20070622";
-  int bytes = strlen(temp);
+  int bytes = strlen(ENCODE_VENDOR_STRING);
 
   /* preamble */  
   oggpack_write(opb,0x03,8);
   _v_writestring(opb,"vorbis", 6);
 
   /* vendor */
   oggpack_write(opb,bytes,32);
-  _v_writestring(opb,temp, bytes);
-  
+  _v_writestring(opb,ENCODE_VENDOR_STRING, bytes);
+
   /* comments */
 
   oggpack_write(opb,vc->comments,32);
   if(vc->comments){
     int i;
     for(i=0;i<vc->comments;i++){
       if(vc->user_comments[i]){
-	oggpack_write(opb,vc->comment_lengths[i],32);
-	_v_writestring(opb,vc->user_comments[i], vc->comment_lengths[i]);
+        oggpack_write(opb,vc->comment_lengths[i],32);
+        _v_writestring(opb,vc->user_comments[i], vc->comment_lengths[i]);
       }else{
-	oggpack_write(opb,0,32);
+        oggpack_write(opb,0,32);
       }
     }
   }
   oggpack_write(opb,1,1);
 
   return(0);
 }
  
@@ -536,17 +542,17 @@ static int _vorbis_pack_books(oggpack_bu
   oggpack_write(opb,1,1);
 
   return(0);
 err_out:
   return(-1);
 } 
 
 int vorbis_commentheader_out(vorbis_comment *vc,
-    				      ogg_packet *op){
+                                          ogg_packet *op){
 
   oggpack_buffer opb;
 
   oggpack_writeinit(&opb);
   if(_vorbis_pack_comment(&opb,vc)) return OV_EIMPL;
 
   op->packet = _ogg_malloc(oggpack_bytes(&opb));
   memcpy(op->packet, opb.buffer, oggpack_bytes(&opb));
@@ -556,20 +562,20 @@ int vorbis_commentheader_out(vorbis_comm
   op->e_o_s=0;
   op->granulepos=0;
   op->packetno=1;
 
   return 0;
 }
 
 int vorbis_analysis_headerout(vorbis_dsp_state *v,
-			      vorbis_comment *vc,
-			      ogg_packet *op,
-			      ogg_packet *op_comm,
-			      ogg_packet *op_code){
+                              vorbis_comment *vc,
+                              ogg_packet *op,
+                              ogg_packet *op_comm,
+                              ogg_packet *op_code){
   int ret=OV_EIMPL;
   vorbis_info *vi=v->vi;
   oggpack_buffer opb;
   private_state *b=v->backend_state;
 
   if(!b){
     ret=OV_EFAULT;
     goto err_out;
@@ -640,8 +646,12 @@ int vorbis_analysis_headerout(vorbis_dsp
   return(ret);
 }
 
 double vorbis_granule_time(vorbis_dsp_state *v,ogg_int64_t granulepos){
   if(granulepos>=0)
     return((double)granulepos/v->vi->rate);
   return(-1);
 }
+
+const char *vorbis_version_string(void){
+  return GENERAL_VENDOR_STRING;
+}
--- a/media/libvorbis/lib/vorbis_lookup.c
+++ b/media/libvorbis/lib/vorbis_lookup.c
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
   function: lookup based functions
-  last mod: $Id: lookup.c 13293 2007-07-24 00:09:47Z xiphmont $
+  last mod: $Id$
 
  ********************************************************************/
 
 #include <math.h>
 #include "lookup.h"
 #include "lookup_data.h"
 #include "os.h"
 #include "misc.h"
@@ -83,12 +83,12 @@ float vorbis_fromdBlook_i(long a){
 }
 
 /* interpolated lookup based cos function, domain 0 to PI only */
 /* a is in 0.16 format, where 0==0, 2^^16-1==PI, return 0.14 */
 long vorbis_coslook_i(long a){
   int i=a>>COS_LOOKUP_I_SHIFT;
   int d=a&COS_LOOKUP_I_MASK;
   return COS_LOOKUP_I[i]- ((d*(COS_LOOKUP_I[i]-COS_LOOKUP_I[i+1]))>>
-			   COS_LOOKUP_I_SHIFT);
+                           COS_LOOKUP_I_SHIFT);
 }
 
 #endif
--- a/media/libvorbis/lib/vorbis_lpc.c
+++ b/media/libvorbis/lib/vorbis_lpc.c
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
   function: LPC low level routines
-  last mod: $Id: lpc.c 13293 2007-07-24 00:09:47Z xiphmont $
+  last mod: $Id$
 
  ********************************************************************/
 
 /* Some of these routines (autocorrelator, LPC coefficient estimator)
    are derived from code written by Jutta Degener and Carsten Bormann;
    thus we include their copyright below.  The entirety of this file
    is freely redistributable on the condition that both of these
    copyright notices are preserved without modification.  */
@@ -57,36 +57,39 @@ Carsten Bormann
 
 /* Input : n elements of time doamin data
    Output: m lpc coefficients, excitation energy */
 
 float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){
   double *aut=alloca(sizeof(*aut)*(m+1));
   double *lpc=alloca(sizeof(*lpc)*(m));
   double error;
+  double epsilon;
   int i,j;
 
   /* autocorrelation, p+1 lag coefficients */
   j=m+1;
   while(j--){
     double d=0; /* double needed for accumulator depth */
     for(i=j;i<n;i++)d+=(double)data[i]*data[i-j];
     aut[j]=d;
   }
   
   /* Generate lpc coefficients from autocorr values */
 
-  error=aut[0];
-  
+  /* set our noise floor to about -100dB */
+  error=aut[0] * (1. + 1e-10);
+  epsilon=1e-9*aut[0]+1e-10;
+
   for(i=0;i<m;i++){
     double r= -aut[i+1];
 
-    if(error==0){
-      memset(lpci,0,m*sizeof(*lpci));
-      return 0;
+    if(error<epsilon){
+      memset(lpc+i,0,(m-i)*sizeof(*lpc));
+      goto done;
     }
 
     /* Sum up this iteration's reflection coefficient; note that in
        Vorbis we don't save it.  If anyone wants to recycle this code
        and needs reflection coefficients, save the results of 'r' from
        each iteration. */
 
     for(j=0;j<i;j++)r-=lpc[j]*aut[i-j];
@@ -96,19 +99,32 @@ float vorbis_lpc_from_data(float *data,f
     
     lpc[i]=r;
     for(j=0;j<i/2;j++){
       double tmp=lpc[j];
 
       lpc[j]+=r*lpc[i-1-j];
       lpc[i-1-j]+=r*tmp;
     }
-    if(i%2)lpc[j]+=lpc[j]*r;
+    if(i&1)lpc[j]+=lpc[j]*r;
+
+    error*=1.-r*r;
+
+  }
 
-    error*=1.f-r*r;
+ done:
+   
+  /* slightly damp the filter */ 
+  {
+    double g = .99;
+    double damp = g;
+    for(j=0;j<m;j++){
+      lpc[j]*=damp;
+      damp*=g;
+    }
   }
 
   for(j=0;j<m;j++)lpci[j]=(float)lpc[j];
 
   /* we need the error value to know how big an impulse to hit the
      filter with later */
   
   return error;
--- a/media/libvorbis/lib/vorbis_lsp.c
+++ b/media/libvorbis/lib/vorbis_lsp.c
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
   function: LSP (also called LSF) conversion routines
-  last mod: $Id: lsp.c 13293 2007-07-24 00:09:47Z xiphmont $
+  last mod: $Id$
 
   The LSP generation code is taken (with minimal modification and a
   few bugfixes) from "On the Computation of the LSP Frequencies" by
   Joseph Rothweiler (see http://www.rothweiler.us for contact info).
   The paper is available at:
 
   http://www.myown1.com/joe/lsf
 
@@ -57,17 +57,17 @@
 
 #ifdef FLOAT_LOOKUP
 #include "vorbis_lookup.c" /* catch this in the build system; we #include for
                        compilers (like gcc) that can't inline across
                        modules */
 
 /* side effect: changes *lsp to cosines of lsp */
 void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m,
-			    float amp,float ampoffset){
+                            float amp,float ampoffset){
   int i;
   float wdel=M_PI/ln;
   vorbis_fpu_control fpu;
   
   vorbis_fpu_setround(&fpu);
   for(i=0;i<m;i++)lsp[i]=vorbis_coslook(lsp[i]);
 
   i=0;
@@ -95,54 +95,54 @@ void vorbis_lsp_to_curve(float *curve,in
     }else{
       /* even order filter; still symmetric */
       q*=q*(1.f+w);
       p*=p*(1.f-w);
     }
 
     q=frexp(p+q,&qexp);
     q=vorbis_fromdBlook(amp*             
-			vorbis_invsqlook(q)*
-			vorbis_invsq2explook(qexp+m)- 
-			ampoffset);
+                        vorbis_invsqlook(q)*
+                        vorbis_invsq2explook(qexp+m)- 
+                        ampoffset);
 
     do{
       curve[i++]*=q;
     }while(map[i]==k);
   }
   vorbis_fpu_restore(fpu);
 }
 
 #else
 
 #ifdef INT_LOOKUP
 #include "vorbis_lookup.c" /* catch this in the build system; we #include for
                        compilers (like gcc) that can't inline across
                        modules */
 
-static int MLOOP_1[64]={
+static const int MLOOP_1[64]={
    0,10,11,11, 12,12,12,12, 13,13,13,13, 13,13,13,13,
   14,14,14,14, 14,14,14,14, 14,14,14,14, 14,14,14,14,
   15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
   15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
 };
 
-static int MLOOP_2[64]={
+static const int MLOOP_2[64]={
   0,4,5,5, 6,6,6,6, 7,7,7,7, 7,7,7,7,
   8,8,8,8, 8,8,8,8, 8,8,8,8, 8,8,8,8,
   9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9,
   9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9,
 };
 
-static int MLOOP_3[8]={0,1,2,2,3,3,3,3};
+static const int MLOOP_3[8]={0,1,2,2,3,3,3,3};
 
 
 /* side effect: changes *lsp to cosines of lsp */
 void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m,
-			    float amp,float ampoffset){
+                            float amp,float ampoffset){
 
   /* 0 <= m < 256 */
 
   /* set up for using all int later */
   int i;
   int ampoffseti=rint(ampoffset*4096.f);
   int ampi=rint(amp*16.f);
   long *ilsp=alloca(m*sizeof(*ilsp));
@@ -156,55 +156,55 @@ void vorbis_lsp_to_curve(float *curve,in
     int qexp=0,shift;
     long wi=vorbis_coslook_i(k*65536/ln);
 
     qi*=labs(ilsp[0]-wi);
     pi*=labs(ilsp[1]-wi);
 
     for(j=3;j<m;j+=2){
       if(!(shift=MLOOP_1[(pi|qi)>>25]))
-	if(!(shift=MLOOP_2[(pi|qi)>>19]))
-	  shift=MLOOP_3[(pi|qi)>>16];
+        if(!(shift=MLOOP_2[(pi|qi)>>19]))
+          shift=MLOOP_3[(pi|qi)>>16];
       qi=(qi>>shift)*labs(ilsp[j-1]-wi);
       pi=(pi>>shift)*labs(ilsp[j]-wi);
       qexp+=shift;
     }
     if(!(shift=MLOOP_1[(pi|qi)>>25]))
       if(!(shift=MLOOP_2[(pi|qi)>>19]))
-	shift=MLOOP_3[(pi|qi)>>16];
+        shift=MLOOP_3[(pi|qi)>>16];
 
     /* pi,qi normalized collectively, both tracked using qexp */
 
     if(m&1){
       /* odd order filter; slightly assymetric */
       /* the last coefficient */
       qi=(qi>>shift)*labs(ilsp[j-1]-wi);
       pi=(pi>>shift)<<14;
       qexp+=shift;
 
       if(!(shift=MLOOP_1[(pi|qi)>>25]))
-	if(!(shift=MLOOP_2[(pi|qi)>>19]))
-	  shift=MLOOP_3[(pi|qi)>>16];
+        if(!(shift=MLOOP_2[(pi|qi)>>19]))
+          shift=MLOOP_3[(pi|qi)>>16];
       
       pi>>=shift;
       qi>>=shift;
       qexp+=shift-14*((m+1)>>1);
 
       pi=((pi*pi)>>16);
       qi=((qi*qi)>>16);
       qexp=qexp*2+m;
 
       pi*=(1<<14)-((wi*wi)>>14);
       qi+=pi>>14;
 
     }else{
       /* even order filter; still symmetric */
 
       /* p*=p(1-w), q*=q(1+w), let normalization drift because it isn't
-	 worth tracking step by step */
+         worth tracking step by step */
       
       pi>>=shift;
       qi>>=shift;
       qexp+=shift-7*m;
 
       pi=((pi*pi)>>16);
       qi=((qi*qi)>>16);
       qexp=qexp*2+m;
@@ -219,38 +219,38 @@ void vorbis_lsp_to_curve(float *curve,in
     /* we've let the normalization drift because it wasn't important;
        however, for the lookup, things must be normalized again.  We
        need at most one right shift or a number of left shifts */
 
     if(qi&0xffff0000){ /* checks for 1.xxxxxxxxxxxxxxxx */
       qi>>=1; qexp++; 
     }else
       while(qi && !(qi&0x8000)){ /* checks for 0.0xxxxxxxxxxxxxxx or less*/
-	qi<<=1; qexp--; 
+        qi<<=1; qexp--; 
       }
 
     amp=vorbis_fromdBlook_i(ampi*                     /*  n.4         */
-			    vorbis_invsqlook_i(qi,qexp)- 
-			                              /*  m.8, m+n<=8 */
-			    ampoffseti);              /*  8.12[0]     */
+                            vorbis_invsqlook_i(qi,qexp)- 
+                                                      /*  m.8, m+n<=8 */
+                            ampoffseti);              /*  8.12[0]     */
 
     curve[i]*=amp;
     while(map[++i]==k)curve[i]*=amp;
   }
 }
 
 #else 
 
 /* old, nonoptimized but simple version for any poor sap who needs to
    figure out what the hell this code does, or wants the other
    fraction of a dB precision */
 
 /* side effect: changes *lsp to cosines of lsp */
 void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m,
-			    float amp,float ampoffset){
+                            float amp,float ampoffset){
   int i;
   float wdel=M_PI/ln;
   for(i=0;i<m;i++)lsp[i]=2.f*cos(lsp[i]);
 
   i=0;
   while(i<n){
     int j,k=map[i];
     float p=.5f;
@@ -316,32 +316,32 @@ static int Laguerre_With_Deflation(float
     double new=0.f,delta;
 
     /* iterate a root */
     while(1){
       double p=defl[m],pp=0.f,ppp=0.f,denom;
       
       /* eval the polynomial and its first two derivatives */
       for(i=m;i>0;i--){
-	ppp = new*ppp + pp;
-	pp  = new*pp  + p;
-	p   = new*p   + defl[i-1];
+        ppp = new*ppp + pp;
+        pp  = new*pp  + p;
+        p   = new*p   + defl[i-1];
       }
       
       /* Laguerre's method */
       denom=(m-1) * ((m-1)*pp*pp - m*p*ppp);
       if(denom<0)
-	return(-1);  /* complex root!  The LPC generator handed us a bad filter */
+        return(-1);  /* complex root!  The LPC generator handed us a bad filter */
 
       if(pp>0){
-	denom = pp + sqrt(denom);
-	if(denom<EPSILON)denom=EPSILON;
+        denom = pp + sqrt(denom);
+        if(denom<EPSILON)denom=EPSILON;
       }else{
-	denom = pp - sqrt(denom);
-	if(denom>-(EPSILON))denom=-(EPSILON);
+        denom = pp - sqrt(denom);
+        if(denom>-(EPSILON))denom=-(EPSILON);
       }
 
       delta  = m*p/denom;
       new   -= delta;
 
       if(delta<0.f)delta*=-1;
 
       if(fabs(delta/new)<10e-12)break; 
@@ -373,18 +373,18 @@ static int Newton_Raphson(float *a,int o
     error=0;
     
     for(i=0; i<ord; i++) { /* Update each point. */
       double pp=0.,delta;
       double rooti=root[i];
       double p=a[ord];
       for(k=ord-1; k>= 0; k--) {
 
-	pp= pp* rooti + p;
-	p = p * rooti + a[k];
+        pp= pp* rooti + p;
+        p = p * rooti + a[k];
       }
 
       delta = p/pp;
       root[i] -= delta;
       error+= delta*delta;
     }
     
     if(count>40)return(-1);
--- a/media/libvorbis/lib/vorbis_mapping0.c
+++ b/media/libvorbis/lib/vorbis_mapping0.c
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: channel mapping 0 implementation
- last mod: $Id: mapping0.c 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <math.h>
 #include <ogg/ogg.h>
@@ -51,17 +51,17 @@ static int ilog(unsigned int v){
   while(v){
     ret++;
     v>>=1;
   }
   return(ret);
 }
 
 static void mapping0_pack(vorbis_info *vi,vorbis_info_mapping *vm,
-			  oggpack_buffer *opb){
+                          oggpack_buffer *opb){
   int i;
   vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)vm;
 
   /* another 'we meant to do it this way' hack...  up to beta 4, we
      packed 4 binary zeros here to signify one submapping in use.  We
      now redefine that to mean four bitflags that indicate use of
      deeper features; bit0:submappings, bit1:coupling,
      bit2,3:reserved. This is backward compatable with all actual uses
@@ -113,20 +113,20 @@ static vorbis_info_mapping *mapping0_unp
   if(oggpack_read(opb,1)){
     info->coupling_steps=oggpack_read(opb,8)+1;
 
     for(i=0;i<info->coupling_steps;i++){
       int testM=info->coupling_mag[i]=oggpack_read(opb,ilog(vi->channels));
       int testA=info->coupling_ang[i]=oggpack_read(opb,ilog(vi->channels));
 
       if(testM<0 || 
-	 testA<0 || 
-	 testM==testA || 
-	 testM>=vi->channels ||
-	 testA>=vi->channels) goto err_out;
+         testA<0 || 
+         testM==testA || 
+         testM>=vi->channels ||
+         testA>=vi->channels) goto err_out;
     }
 
   }
 
   if(oggpack_read(opb,2)>0)goto err_out; /* 2,3:reserved */
     
   if(info->submaps>1){
     for(i=0;i<vi->channels;i++){
@@ -224,26 +224,16 @@ static float FLOOR1_fromdB_LOOKUP[256]={
   0.38890521F, 0.41417847F, 0.44109412F, 0.46975890F, 
   0.50028648F, 0.53279791F, 0.56742212F, 0.60429640F, 
   0.64356699F, 0.68538959F, 0.72993007F, 0.77736504F, 
   0.82788260F, 0.88168307F, 0.9389798F, 1.F, 
 };
 
 #endif 
 
-extern int *floor1_fit(vorbis_block *vb,vorbis_look_floor *look,
-		       const float *logmdct,   /* in */
-		       const float *logmask);
-extern int *floor1_interpolate_fit(vorbis_block *vb,vorbis_look_floor *look,
-				   int *A,int *B,
-				   int del);
-extern int floor1_encode(oggpack_buffer *opb,vorbis_block *vb,
-			 vorbis_look_floor *look,
-			 int *post,int *ilogmask);
-
 
 static int mapping0_forward(vorbis_block *vb){
   vorbis_dsp_state      *vd=vb->vd;
   vorbis_info           *vi=vd->vi;
   codec_setup_info      *ci=vi->codec_setup;
   private_state         *b=vb->vd->backend_state;
   vorbis_block_internal *vbi=(vorbis_block_internal *)vb->internal;
   int                    n=vb->pcmend;
@@ -285,32 +275,38 @@ static int mapping0_forward(vorbis_block
                                      in the estimator requires
                                      changing all the tunings as well.
                                      For now, it's easier to sync
                                      things back up here, and
                                      recalibrate the tunings in the
                                      next major model upgrade. */
 
 #if 0
-    if(vi->channels==2)
+    if(vi->channels==2){
       if(i==0)
-	_analysis_output("pcmL",seq,pcm,n,0,0,total-n/2);
+        _analysis_output("pcmL",seq,pcm,n,0,0,total-n/2);
       else
-	_analysis_output("pcmR",seq,pcm,n,0,0,total-n/2);
+        _analysis_output("pcmR",seq,pcm,n,0,0,total-n/2);
+    }else{
+      _analysis_output("pcm",seq,pcm,n,0,0,total-n/2);
+    }
 #endif
   
     /* window the PCM data */
     _vorbis_apply_window(pcm,b->window,ci->blocksizes,vb->lW,vb->W,vb->nW);
 
 #if 0
-    if(vi->channels==2)
+    if(vi->channels==2){
       if(i==0)
-	_analysis_output("windowedL",seq,pcm,n,0,0,total-n/2);
+        _analysis_output("windowedL",seq,pcm,n,0,0,total-n/2);
       else
-	_analysis_output("windowedR",seq,pcm,n,0,0,total-n/2);
+        _analysis_output("windowedR",seq,pcm,n,0,0,total-n/2);
+    }else{
+      _analysis_output("windowed",seq,pcm,n,0,0,total-n/2);
+    }
 #endif
 
     /* transform the PCM data */
     /* only MDCT right now.... */
     mdct_forward(b->transform[vb->W][0],pcm,gmdct[i]);
     
     /* FFT yields more accurate tonal estimation (not phase sensitive) */
     drft_forward(&b->fft_look[vb->W],pcm);
@@ -350,223 +346,238 @@ static int mapping0_forward(vorbis_block
     }
 
     if(local_ampmax[i]>0.f)local_ampmax[i]=0.f;
     if(local_ampmax[i]>global_ampmax)global_ampmax=local_ampmax[i];
 
 #if 0
     if(vi->channels==2){
       if(i==0){
-	_analysis_output("fftL",seq,logfft,n/2,1,0,0);
+        _analysis_output("fftL",seq,logfft,n/2,1,0,0);
       }else{
-	_analysis_output("fftR",seq,logfft,n/2,1,0,0);
+        _analysis_output("fftR",seq,logfft,n/2,1,0,0);
       }
+    }else{
+      _analysis_output("fft",seq,logfft,n/2,1,0,0);
     }
 #endif
 
   }
   
   {
     float   *noise        = _vorbis_block_alloc(vb,n/2*sizeof(*noise));
     float   *tone         = _vorbis_block_alloc(vb,n/2*sizeof(*tone));
     
     for(i=0;i<vi->channels;i++){
       /* the encoder setup assumes that all the modes used by any
-	 specific bitrate tweaking use the same floor */
+         specific bitrate tweaking use the same floor */
       
       int submap=info->chmuxlist[i];
       
       /* the following makes things clearer to *me* anyway */
       float *mdct    =gmdct[i];
       float *logfft  =vb->pcm[i];
       
       float *logmdct =logfft+n/2;
       float *logmask =logfft;
 
       vb->mode=modenumber;
 
       floor_posts[i]=_vorbis_block_alloc(vb,PACKETBLOBS*sizeof(**floor_posts));
       memset(floor_posts[i],0,sizeof(**floor_posts)*PACKETBLOBS);
       
       for(j=0;j<n/2;j++)
-	logmdct[j]=todB(mdct+j)  + .345; /* + .345 is a hack; the original
+        logmdct[j]=todB(mdct+j)  + .345; /* + .345 is a hack; the original
                                      todB estimation used on IEEE 754
                                      compliant machines had a bug that
                                      returned dB values about a third
                                      of a decibel too high.  The bug
                                      was harmless because tunings
                                      implicitly took that into
                                      account.  However, fixing the bug
                                      in the estimator requires
                                      changing all the tunings as well.
                                      For now, it's easier to sync
                                      things back up here, and
                                      recalibrate the tunings in the
                                      next major model upgrade. */
 
 #if 0
       if(vi->channels==2){
-	if(i==0)
-	  _analysis_output("mdctL",seq,logmdct,n/2,1,0,0);
-	else
-	  _analysis_output("mdctR",seq,logmdct,n/2,1,0,0);
+        if(i==0)
+          _analysis_output("mdctL",seq,logmdct,n/2,1,0,0);
+        else
+          _analysis_output("mdctR",seq,logmdct,n/2,1,0,0);
       }else{
-	_analysis_output("mdct",seq,logmdct,n/2,1,0,0);
+        _analysis_output("mdct",seq,logmdct,n/2,1,0,0);
       }
 #endif 
       
       /* first step; noise masking.  Not only does 'noise masking'
          give us curves from which we can decide how much resolution
          to give noise parts of the spectrum, it also implicitly hands
          us a tonality estimate (the larger the value in the
          'noise_depth' vector, the more tonal that area is) */
 
       _vp_noisemask(psy_look,
-		    logmdct,
-		    noise); /* noise does not have by-frequency offset
+                    logmdct,
+                    noise); /* noise does not have by-frequency offset
                                bias applied yet */
 #if 0
       if(vi->channels==2){
-	if(i==0)
-	  _analysis_output("noiseL",seq,noise,n/2,1,0,0);
-	else
-	  _analysis_output("noiseR",seq,noise,n/2,1,0,0);
+        if(i==0)
+          _analysis_output("noiseL",seq,noise,n/2,1,0,0);
+        else
+          _analysis_output("noiseR",seq,noise,n/2,1,0,0);
+      }else{
+        _analysis_output("noise",seq,noise,n/2,1,0,0);
       }
 #endif
 
       /* second step: 'all the other crap'; all the stuff that isn't
          computed/fit for bitrate management goes in the second psy
          vector.  This includes tone masking, peak limiting and ATH */
 
       _vp_tonemask(psy_look,
-		   logfft,
-		   tone,
-		   global_ampmax,
-		   local_ampmax[i]);
+                   logfft,
+                   tone,
+                   global_ampmax,
+                   local_ampmax[i]);
 
 #if 0
       if(vi->channels==2){
-	if(i==0)
-	  _analysis_output("toneL",seq,tone,n/2,1,0,0);
-	else
-	  _analysis_output("toneR",seq,tone,n/2,1,0,0);
+        if(i==0)
+          _analysis_output("toneL",seq,tone,n/2,1,0,0);
+        else
+          _analysis_output("toneR",seq,tone,n/2,1,0,0);
+      }else{
+        _analysis_output("tone",seq,tone,n/2,1,0,0);
       }
 #endif
 
       /* third step; we offset the noise vectors, overlay tone
-	 masking.  We then do a floor1-specific line fit.  If we're
-	 performing bitrate management, the line fit is performed
-	 multiple times for up/down tweakage on demand. */
+         masking.  We then do a floor1-specific line fit.  If we're
+         performing bitrate management, the line fit is performed
+         multiple times for up/down tweakage on demand. */
 
 #if 0
       {
       float aotuv[psy_look->n];
 #endif
 
-	_vp_offset_and_mix(psy_look,
-			   noise,
-			   tone,
-			   1,
-			   logmask,
-			   mdct,
-			   logmdct);
-	
+        _vp_offset_and_mix(psy_look,
+                           noise,
+                           tone,
+                           1,
+                           logmask,
+                           mdct,
+                           logmdct);
+        
 #if 0
-	if(vi->channels==2){
-	  if(i==0)
-	    _analysis_output("aotuvM1_L",seq,aotuv,psy_look->n,1,1,0);
-	  else
-	    _analysis_output("aotuvM1_R",seq,aotuv,psy_look->n,1,1,0);
-	}
+        if(vi->channels==2){
+          if(i==0)
+            _analysis_output("aotuvM1_L",seq,aotuv,psy_look->n,1,1,0);
+          else
+            _analysis_output("aotuvM1_R",seq,aotuv,psy_look->n,1,1,0);
+        }else{
+          _analysis_output("aotuvM1",seq,aotuv,psy_look->n,1,1,0);
+        }
       }
 #endif
 
 
 #if 0
       if(vi->channels==2){
-	if(i==0)
-	  _analysis_output("mask1L",seq,logmask,n/2,1,0,0);
-	else
-	  _analysis_output("mask1R",seq,logmask,n/2,1,0,0);
+        if(i==0)
+          _analysis_output("mask1L",seq,logmask,n/2,1,0,0);
+        else
+          _analysis_output("mask1R",seq,logmask,n/2,1,0,0);
+      }else{
+        _analysis_output("mask1",seq,logmask,n/2,1,0,0);
       }
 #endif
 
       /* this algorithm is hardwired to floor 1 for now; abort out if
          we're *not* floor1.  This won't happen unless someone has
          broken the encode setup lib.  Guard it anyway. */
       if(ci->floor_type[info->floorsubmap[submap]]!=1)return(-1);
 
       floor_posts[i][PACKETBLOBS/2]=
-	floor1_fit(vb,b->flr[info->floorsubmap[submap]],
-		   logmdct,
-		   logmask);
+        floor1_fit(vb,b->flr[info->floorsubmap[submap]],
+                   logmdct,
+                   logmask);
       
       /* are we managing bitrate?  If so, perform two more fits for
          later rate tweaking (fits represent hi/lo) */
       if(vorbis_bitrate_managed(vb) && floor_posts[i][PACKETBLOBS/2]){
-	/* higher rate by way of lower noise curve */
+        /* higher rate by way of lower noise curve */
 
-	_vp_offset_and_mix(psy_look,
-			   noise,
-			   tone,
-			   2,
-			   logmask,
-			   mdct,
-			   logmdct);
+        _vp_offset_and_mix(psy_look,
+                           noise,
+                           tone,
+                           2,
+                           logmask,
+                           mdct,
+                           logmdct);
 
 #if 0
-	if(vi->channels==2){
-	  if(i==0)
-	    _analysis_output("mask2L",seq,logmask,n/2,1,0,0);
-	  else
-	    _analysis_output("mask2R",seq,logmask,n/2,1,0,0);
-	}
+        if(vi->channels==2){
+          if(i==0)
+            _analysis_output("mask2L",seq,logmask,n/2,1,0,0);
+          else
+            _analysis_output("mask2R",seq,logmask,n/2,1,0,0);
+        }else{
+          _analysis_output("mask2",seq,logmask,n/2,1,0,0);
+        }
 #endif
-	
-	floor_posts[i][PACKETBLOBS-1]=
-	  floor1_fit(vb,b->flr[info->floorsubmap[submap]],
-		     logmdct,
-		     logmask);
+        
+        floor_posts[i][PACKETBLOBS-1]=
+          floor1_fit(vb,b->flr[info->floorsubmap[submap]],
+                     logmdct,
+                     logmask);
       
-	/* lower rate by way of higher noise curve */
-	_vp_offset_and_mix(psy_look,
-			   noise,
-			   tone,
-			   0,
-			   logmask,
-			   mdct,
-			   logmdct);
+        /* lower rate by way of higher noise curve */
+        _vp_offset_and_mix(psy_look,
+                           noise,
+                           tone,
+                           0,
+                           logmask,
+                           mdct,
+                           logmdct);
 
 #if 0
-	if(vi->channels==2)
-	  if(i==0)
-	    _analysis_output("mask0L",seq,logmask,n/2,1,0,0);
-	  else
-	    _analysis_output("mask0R",seq,logmask,n/2,1,0,0);
+        if(vi->channels==2){
+          if(i==0)
+            _analysis_output("mask0L",seq,logmask,n/2,1,0,0);
+          else
+            _analysis_output("mask0R",seq,logmask,n/2,1,0,0);
+        }else{
+          _analysis_output("mask0",seq,logmask,n/2,1,0,0);
+        }
 #endif
 
-	floor_posts[i][0]=
-	  floor1_fit(vb,b->flr[info->floorsubmap[submap]],
-		     logmdct,
-		     logmask);
-	
-	/* we also interpolate a range of intermediate curves for
+        floor_posts[i][0]=
+          floor1_fit(vb,b->flr[info->floorsubmap[submap]],
+                     logmdct,
+                     logmask);
+        
+        /* we also interpolate a range of intermediate curves for
            intermediate rates */
-	for(k=1;k<PACKETBLOBS/2;k++)
-	  floor_posts[i][k]=
-	    floor1_interpolate_fit(vb,b->flr[info->floorsubmap[submap]],
-				   floor_posts[i][0],
-				   floor_posts[i][PACKETBLOBS/2],
-				   k*65536/(PACKETBLOBS/2));
-	for(k=PACKETBLOBS/2+1;k<PACKETBLOBS-1;k++)
-	  floor_posts[i][k]=
-	    floor1_interpolate_fit(vb,b->flr[info->floorsubmap[submap]],
-				   floor_posts[i][PACKETBLOBS/2],
-				   floor_posts[i][PACKETBLOBS-1],
-				   (k-PACKETBLOBS/2)*65536/(PACKETBLOBS/2));
+        for(k=1;k<PACKETBLOBS/2;k++)
+          floor_posts[i][k]=
+            floor1_interpolate_fit(vb,b->flr[info->floorsubmap[submap]],
+                                   floor_posts[i][0],
+                                   floor_posts[i][PACKETBLOBS/2],
+                                   k*65536/(PACKETBLOBS/2));
+        for(k=PACKETBLOBS/2+1;k<PACKETBLOBS-1;k++)
+          floor_posts[i][k]=
+            floor1_interpolate_fit(vb,b->flr[info->floorsubmap[submap]],
+                                   floor_posts[i][PACKETBLOBS/2],
+                                   floor_posts[i][PACKETBLOBS-1],
+                                   (k-PACKETBLOBS/2)*65536/(PACKETBLOBS/2));
       }
     }
   }
   vbi->ampmax=global_ampmax;
 
   /*
     the next phases are performed once for vbr-only and PACKETBLOB
     times for bitrate managed modes.
@@ -581,145 +592,153 @@ static int mapping0_forward(vorbis_block
 
   /* iterate over the many masking curve fits we've created */
 
   {
     float **res_bundle=alloca(sizeof(*res_bundle)*vi->channels);
     float **couple_bundle=alloca(sizeof(*couple_bundle)*vi->channels);
     int *zerobundle=alloca(sizeof(*zerobundle)*vi->channels);
     int **sortindex=alloca(sizeof(*sortindex)*vi->channels);
-    float **mag_memo;
-    int **mag_sort;
+    float **mag_memo=NULL;
+    int **mag_sort=NULL;
 
     if(info->coupling_steps){
       mag_memo=_vp_quantize_couple_memo(vb,
-					&ci->psy_g_param,
-					psy_look,
-					info,
-					gmdct);    
+                                        &ci->psy_g_param,
+                                        psy_look,
+                                        info,
+                                        gmdct);    
       
       mag_sort=_vp_quantize_couple_sort(vb,
-					psy_look,
-					info,
-					mag_memo);    
+                                        psy_look,
+                                        info,
+                                        mag_memo);    
 
       hf_reduction(&ci->psy_g_param,
-		   psy_look,
-		   info,
-		   mag_memo);
+                   psy_look,
+                   info,
+                   mag_memo);
     }
 
     memset(sortindex,0,sizeof(*sortindex)*vi->channels);
     if(psy_look->vi->normal_channel_p){
       for(i=0;i<vi->channels;i++){
-	float *mdct    =gmdct[i];
-	sortindex[i]=alloca(sizeof(**sortindex)*n/2);
-	_vp_noise_normalize_sort(psy_look,mdct,sortindex[i]);
+        float *mdct    =gmdct[i];
+        sortindex[i]=alloca(sizeof(**sortindex)*n/2);
+        _vp_noise_normalize_sort(psy_look,mdct,sortindex[i]);
       }
     }
 
     for(k=(vorbis_bitrate_managed(vb)?0:PACKETBLOBS/2);
-	k<=(vorbis_bitrate_managed(vb)?PACKETBLOBS-1:PACKETBLOBS/2);
-	k++){
+        k<=(vorbis_bitrate_managed(vb)?PACKETBLOBS-1:PACKETBLOBS/2);
+        k++){
       oggpack_buffer *opb=vbi->packetblob[k];
 
       /* start out our new packet blob with packet type and mode */
       /* Encode the packet type */
       oggpack_write(opb,0,1);
       /* Encode the modenumber */
       /* Encode frame mode, pre,post windowsize, then dispatch */
       oggpack_write(opb,modenumber,b->modebits);
       if(vb->W){
-	oggpack_write(opb,vb->lW,1);
-	oggpack_write(opb,vb->nW,1);
+        oggpack_write(opb,vb->lW,1);
+        oggpack_write(opb,vb->nW,1);
       }
 
       /* encode floor, compute masking curve, sep out residue */
       for(i=0;i<vi->channels;i++){
-	int submap=info->chmuxlist[i];
-	float *mdct    =gmdct[i];
-	float *res     =vb->pcm[i];
-	int   *ilogmask=ilogmaskch[i]=
-	  _vorbis_block_alloc(vb,n/2*sizeof(**gmdct));
+        int submap=info->chmuxlist[i];
+        float *mdct    =gmdct[i];
+        float *res     =vb->pcm[i];
+        int   *ilogmask=ilogmaskch[i]=
+          _vorbis_block_alloc(vb,n/2*sizeof(**gmdct));
       
-	nonzero[i]=floor1_encode(opb,vb,b->flr[info->floorsubmap[submap]],
-				 floor_posts[i][k],
-				 ilogmask);
+        nonzero[i]=floor1_encode(opb,vb,b->flr[info->floorsubmap[submap]],
+                                 floor_posts[i][k],
+                                 ilogmask);
 #if 0
-	{
-	  char buf[80];
-	  sprintf(buf,"maskI%c%d",i?'R':'L',k);
-	  float work[n/2];
-	  for(j=0;j<n/2;j++)
-	    work[j]=FLOOR1_fromdB_LOOKUP[ilogmask[j]];
-	  _analysis_output(buf,seq,work,n/2,1,1,0);
-	}
+        {
+          char buf[80];
+          sprintf(buf,"maskI%c%d",i?'R':'L',k);
+          float work[n/2];
+          for(j=0;j<n/2;j++)
+            work[j]=FLOOR1_fromdB_LOOKUP[ilogmask[j]];
+          _analysis_output(buf,seq,work,n/2,1,1,0);
+        }
 #endif
-	_vp_remove_floor(psy_look,
-			 mdct,
-			 ilogmask,
-			 res,
-			 ci->psy_g_param.sliding_lowpass[vb->W][k]);
+        _vp_remove_floor(psy_look,
+                         mdct,
+                         ilogmask,
+                         res,
+                         ci->psy_g_param.sliding_lowpass[vb->W][k]);
 
-	_vp_noise_normalize(psy_look,res,res+n/2,sortindex[i]);
+        _vp_noise_normalize(psy_look,res,res+n/2,sortindex[i]);
 
-	
+        
 #if 0
-	{
-	  char buf[80];
-	  float work[n/2];
-	  for(j=0;j<n/2;j++)
-	    work[j]=FLOOR1_fromdB_LOOKUP[ilogmask[j]]*(res+n/2)[j];
-	  sprintf(buf,"resI%c%d",i?'R':'L',k);
-	  _analysis_output(buf,seq,work,n/2,1,1,0);
+        {
+          char buf[80];
+          float work[n/2];
+          for(j=0;j<n/2;j++)
+            work[j]=FLOOR1_fromdB_LOOKUP[ilogmask[j]]*(res+n/2)[j];
+          sprintf(buf,"resI%c%d",i?'R':'L',k);
+          _analysis_output(buf,seq,work,n/2,1,1,0);
 
-	}
+        }
 #endif
       }
       
       /* our iteration is now based on masking curve, not prequant and
-	 coupling.  Only one prequant/coupling step */
+         coupling.  Only one prequant/coupling step */
       
       /* quantize/couple */
       /* incomplete implementation that assumes the tree is all depth
          one, or no tree at all */
       if(info->coupling_steps){
-	_vp_couple(k,
-		   &ci->psy_g_param,
-		   psy_look,
-		   info,
-		   vb->pcm,
-		   mag_memo,
-		   mag_sort,
-		   ilogmaskch,
-		   nonzero,
-		   ci->psy_g_param.sliding_lowpass[vb->W][k]);
+        _vp_couple(k,
+                   &ci->psy_g_param,
+                   psy_look,
+                   info,
+                   vb->pcm,
+                   mag_memo,
+                   mag_sort,
+                   ilogmaskch,
+                   nonzero,
+                   ci->psy_g_param.sliding_lowpass[vb->W][k]);
       }
       
       /* classify and encode by submap */
       for(i=0;i<info->submaps;i++){
-	int ch_in_bundle=0;
-	long **classifications;
-	int resnum=info->residuesubmap[i];
+        int ch_in_bundle=0;
+        long **classifications;
+        int resnum=info->residuesubmap[i];
 
-	for(j=0;j<vi->channels;j++){
-	  if(info->chmuxlist[j]==i){
-	    zerobundle[ch_in_bundle]=0;
-	    if(nonzero[j])zerobundle[ch_in_bundle]=1;
-	    res_bundle[ch_in_bundle]=vb->pcm[j];
-	    couple_bundle[ch_in_bundle++]=vb->pcm[j]+n/2;
-	  }
-	}
-	
-	classifications=_residue_P[ci->residue_type[resnum]]->
-	  class(vb,b->residue[resnum],couple_bundle,zerobundle,ch_in_bundle);
-	
-	_residue_P[ci->residue_type[resnum]]->
-	  forward(opb,vb,b->residue[resnum],
-		  couple_bundle,NULL,zerobundle,ch_in_bundle,classifications);
+        for(j=0;j<vi->channels;j++){
+          if(info->chmuxlist[j]==i){
+            zerobundle[ch_in_bundle]=0;
+            if(nonzero[j])zerobundle[ch_in_bundle]=1;
+            res_bundle[ch_in_bundle]=vb->pcm[j];
+            couple_bundle[ch_in_bundle++]=vb->pcm[j]+n/2;
+          }
+        }
+        
+        classifications=_residue_P[ci->residue_type[resnum]]->
+          class(vb,b->residue[resnum],couple_bundle,zerobundle,ch_in_bundle);
+
+        /* couple_bundle is destructively overwritten by
+           the class function if some but not all of the channels are
+           marked as silence; build a fresh copy */
+        ch_in_bundle=0;        
+        for(j=0;j<vi->channels;j++)
+          if(info->chmuxlist[j]==i)
+            couple_bundle[ch_in_bundle++]=vb->pcm[j]+n/2;
+
+        _residue_P[ci->residue_type[resnum]]->
+          forward(opb,vb,b->residue[resnum],
+                  couple_bundle,NULL,zerobundle,ch_in_bundle,classifications);
       }
       
       /* ok, done encoding.  Next protopacket. */
     }
     
   }
 
 #if 0
@@ -730,17 +749,16 @@ static int mapping0_forward(vorbis_block
 }
 
 static int mapping0_inverse(vorbis_block *vb,vorbis_info_mapping *l){
   vorbis_dsp_state     *vd=vb->vd;
   vorbis_info          *vi=vd->vi;
   codec_setup_info     *ci=vi->codec_setup;
   private_state        *b=vd->backend_state;
   vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)l;
-  int hs=ci->halfrate_flag; 
 
   int                   i,j;
   long                  n=vb->pcmend=ci->blocksizes[vb->W];
 
   float **pcmbundle=alloca(sizeof(*pcmbundle)*vi->channels);
   int    *zerobundle=alloca(sizeof(*zerobundle)*vi->channels);
 
   int   *nonzero  =alloca(sizeof(*nonzero)*vi->channels);
@@ -767,78 +785,78 @@ static int mapping0_inverse(vorbis_block
     }
   }
 
   /* recover the residue into our working vectors */
   for(i=0;i<info->submaps;i++){
     int ch_in_bundle=0;
     for(j=0;j<vi->channels;j++){
       if(info->chmuxlist[j]==i){
-	if(nonzero[j])
-	  zerobundle[ch_in_bundle]=1;
-	else
-	  zerobundle[ch_in_bundle]=0;
-	pcmbundle[ch_in_bundle++]=vb->pcm[j];
+        if(nonzero[j])
+          zerobundle[ch_in_bundle]=1;
+        else
+          zerobundle[ch_in_bundle]=0;
+        pcmbundle[ch_in_bundle++]=vb->pcm[j];
       }
     }
 
     _residue_P[ci->residue_type[info->residuesubmap[i]]]->
       inverse(vb,b->residue[info->residuesubmap[i]],
-	      pcmbundle,zerobundle,ch_in_bundle);
+              pcmbundle,zerobundle,ch_in_bundle);
   }
 
   /* channel coupling */
   for(i=info->coupling_steps-1;i>=0;i--){
     float *pcmM=vb->pcm[info->coupling_mag[i]];
     float *pcmA=vb->pcm[info->coupling_ang[i]];
 
     for(j=0;j<n/2;j++){
       float mag=pcmM[j];
       float ang=pcmA[j];
 
       if(mag>0)
-	if(ang>0){
-	  pcmM[j]=mag;
-	  pcmA[j]=mag-ang;
-	}else{
-	  pcmA[j]=mag;
-	  pcmM[j]=mag+ang;
-	}
+        if(ang>0){
+          pcmM[j]=mag;
+          pcmA[j]=mag-ang;
+        }else{
+          pcmA[j]=mag;
+          pcmM[j]=mag+ang;
+        }
       else
-	if(ang>0){
-	  pcmM[j]=mag;
-	  pcmA[j]=mag+ang;
-	}else{
-	  pcmA[j]=mag;
-	  pcmM[j]=mag-ang;
-	}
+        if(ang>0){
+          pcmM[j]=mag;
+          pcmA[j]=mag+ang;
+        }else{
+          pcmA[j]=mag;
+          pcmM[j]=mag-ang;
+        }
     }
   }
 
   /* compute and apply spectral envelope */
   for(i=0;i<vi->channels;i++){
     float *pcm=vb->pcm[i];
     int submap=info->chmuxlist[i];
     _floor_P[ci->floor_type[info->floorsubmap[submap]]]->
       inverse2(vb,b->flr[info->floorsubmap[submap]],
-	       floormemo[i],pcm);
+               floormemo[i],pcm);
   }
 
   /* transform the PCM data; takes PCM vector, vb; modifies PCM vector */
   /* only MDCT right now.... */
   for(i=0;i<vi->channels;i++){
     float *pcm=vb->pcm[i];
     mdct_backward(b->transform[vb->W][0],pcm,pcm);
   }
 
   /* all done! */
   return(0);
 }
 
 /* export hooks */
-vorbis_func_mapping mapping0_exportbundle={
+const vorbis_func_mapping mapping0_exportbundle={
   &mapping0_pack,
   &mapping0_unpack,
   &mapping0_free_info,
   &mapping0_forward,
   &mapping0_inverse
 };
 
--- a/media/libvorbis/lib/vorbis_mdct.c
+++ b/media/libvorbis/lib/vorbis_mdct.c
@@ -7,17 +7,17 @@
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: normalized modified discrete cosine transform
            power of two length transform only [64 <= n ]
- last mod: $Id: mdct.c 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  Original algorithm adapted long ago from _The use of multirate filter
  banks for coding of high quality digital audio_, by T. Sporer,
  K. Brandenburg and B. Edler, collection of the European Signal
  Processing Conference (EUSIPCO), Amsterdam, June 1992, Vol.1, pp
  211-214
 
  The below code implements an algorithm that no longer looks much like
@@ -76,47 +76,47 @@ void mdct_init(mdct_lookup *lookup,int n
   /* bitreverse lookup... */
 
   {
     int mask=(1<<(log2n-1))-1,i,j;
     int msb=1<<(log2n-2);
     for(i=0;i<n/8;i++){
       int acc=0;
       for(j=0;msb>>j;j++)
-	if((msb>>j)&i)acc|=1<<j;
+        if((msb>>j)&i)acc|=1<<j;
       bitrev[i*2]=((~acc)&mask)-1;
       bitrev[i*2+1]=acc;
 
     }
   }
   lookup->scale=FLOAT_CONV(4.f/n);
 }
 
 /* 8 point butterfly (in place, 4 register) */
 STIN void mdct_butterfly_8(DATA_TYPE *x){
   REG_TYPE r0   = x[6] + x[2];
   REG_TYPE r1   = x[6] - x[2];
   REG_TYPE r2   = x[4] + x[0];
   REG_TYPE r3   = x[4] - x[0];
 
-	   x[6] = r0   + r2;
-	   x[4] = r0   - r2;
-	   
-	   r0   = x[5] - x[1];
-	   r2   = x[7] - x[3];
-	   x[0] = r1   + r0;
-	   x[2] = r1   - r0;
-	   
-	   r0   = x[5] + x[1];
-	   r1   = x[7] + x[3];
-	   x[3] = r2   + r3;
-	   x[1] = r2   - r3;
-	   x[7] = r1   + r0;
-	   x[5] = r1   - r0;
-	   
+           x[6] = r0   + r2;
+           x[4] = r0   - r2;
+           
+           r0   = x[5] - x[1];
+           r2   = x[7] - x[3];
+           x[0] = r1   + r0;
+           x[2] = r1   - r0;
+           
+           r0   = x[5] + x[1];
+           r1   = x[7] + x[3];
+           x[3] = r2   + r3;
+           x[1] = r2   - r3;
+           x[7] = r1   + r0;
+           x[5] = r1   - r0;
+           
 }
 
 /* 16 point butterfly (in place, 4 register) */
 STIN void mdct_butterfly_16(DATA_TYPE *x){
   REG_TYPE r0     = x[1]  - x[9];
   REG_TYPE r1     = x[0]  - x[8];
 
            x[8]  += x[0];
@@ -140,188 +140,188 @@ STIN void mdct_butterfly_16(DATA_TYPE *x
 
            r0     = x[14] - x[6];
            r1     = x[15] - x[7];
            x[14] += x[6];
            x[15] += x[7];
            x[6]  = r0;
            x[7]  = r1;
 
-	   mdct_butterfly_8(x);
-	   mdct_butterfly_8(x+8);
+           mdct_butterfly_8(x);
+           mdct_butterfly_8(x+8);
 }
 
 /* 32 point butterfly (in place, 4 register) */
 STIN void mdct_butterfly_32(DATA_TYPE *x){
   REG_TYPE r0     = x[30] - x[14];
   REG_TYPE r1     = x[31] - x[15];
 
            x[30] +=         x[14];           
-	   x[31] +=         x[15];
+           x[31] +=         x[15];
            x[14]  =         r0;              
-	   x[15]  =         r1;
+           x[15]  =         r1;
 
            r0     = x[28] - x[12];   
-	   r1     = x[29] - x[13];
+           r1     = x[29] - x[13];
            x[28] +=         x[12];           
-	   x[29] +=         x[13];
+           x[29] +=         x[13];
            x[12]  = MULT_NORM( r0 * cPI1_8  -  r1 * cPI3_8 );
-	   x[13]  = MULT_NORM( r0 * cPI3_8  +  r1 * cPI1_8 );
+           x[13]  = MULT_NORM( r0 * cPI3_8  +  r1 * cPI1_8 );
 
            r0     = x[26] - x[10];
-	   r1     = x[27] - x[11];
-	   x[26] +=         x[10];
-	   x[27] +=         x[11];
-	   x[10]  = MULT_NORM(( r0  - r1 ) * cPI2_8);
-	   x[11]  = MULT_NORM(( r0  + r1 ) * cPI2_8);
+           r1     = x[27] - x[11];
+           x[26] +=         x[10];
+           x[27] +=         x[11];
+           x[10]  = MULT_NORM(( r0  - r1 ) * cPI2_8);
+           x[11]  = MULT_NORM(( r0  + r1 ) * cPI2_8);
 
-	   r0     = x[24] - x[8];
-	   r1     = x[25] - x[9];
-	   x[24] += x[8];
-	   x[25] += x[9];
-	   x[8]   = MULT_NORM( r0 * cPI3_8  -  r1 * cPI1_8 );
-	   x[9]   = MULT_NORM( r1 * cPI3_8  +  r0 * cPI1_8 );
+           r0     = x[24] - x[8];
+           r1     = x[25] - x[9];
+           x[24] += x[8];
+           x[25] += x[9];
+           x[8]   = MULT_NORM( r0 * cPI3_8  -  r1 * cPI1_8 );
+           x[9]   = MULT_NORM( r1 * cPI3_8  +  r0 * cPI1_8 );
 
-	   r0     = x[22] - x[6];
-	   r1     = x[7]  - x[23];
-	   x[22] += x[6];
-	   x[23] += x[7];
-	   x[6]   = r1;
-	   x[7]   = r0;
+           r0     = x[22] - x[6];
+           r1     = x[7]  - x[23];
+           x[22] += x[6];
+           x[23] += x[7];
+           x[6]   = r1;
+           x[7]   = r0;
 
-	   r0     = x[4]  - x[20];
-	   r1     = x[5]  - x[21];
-	   x[20] += x[4];
-	   x[21] += x[5];
-	   x[4]   = MULT_NORM( r1 * cPI1_8  +  r0 * cPI3_8 );
-	   x[5]   = MULT_NORM( r1 * cPI3_8  -  r0 * cPI1_8 );
+           r0     = x[4]  - x[20];
+           r1     = x[5]  - x[21];
+           x[20] += x[4];
+           x[21] += x[5];
+           x[4]   = MULT_NORM( r1 * cPI1_8  +  r0 * cPI3_8 );
+           x[5]   = MULT_NORM( r1 * cPI3_8  -  r0 * cPI1_8 );
 
-	   r0     = x[2]  - x[18];
-	   r1     = x[3]  - x[19];
-	   x[18] += x[2];
-	   x[19] += x[3];
-	   x[2]   = MULT_NORM(( r1  + r0 ) * cPI2_8);
-	   x[3]   = MULT_NORM(( r1  - r0 ) * cPI2_8);
+           r0     = x[2]  - x[18];
+           r1     = x[3]  - x[19];
+           x[18] += x[2];
+           x[19] += x[3];
+           x[2]   = MULT_NORM(( r1  + r0 ) * cPI2_8);
+           x[3]   = MULT_NORM(( r1  - r0 ) * cPI2_8);
 
-	   r0     = x[0]  - x[16];
-	   r1     = x[1]  - x[17];
-	   x[16] += x[0];
-	   x[17] += x[1];
-	   x[0]   = MULT_NORM( r1 * cPI3_8  +  r0 * cPI1_8 );
-	   x[1]   = MULT_NORM( r1 * cPI1_8  -  r0 * cPI3_8 );
+           r0     = x[0]  - x[16];
+           r1     = x[1]  - x[17];
+           x[16] += x[0];
+           x[17] += x[1];
+           x[0]   = MULT_NORM( r1 * cPI3_8  +  r0 * cPI1_8 );
+           x[1]   = MULT_NORM( r1 * cPI1_8  -  r0 * cPI3_8 );
 
-	   mdct_butterfly_16(x);
-	   mdct_butterfly_16(x+16);
+           mdct_butterfly_16(x);
+           mdct_butterfly_16(x+16);
 
 }
 
 /* N point first stage butterfly (in place, 2 register) */
 STIN void mdct_butterfly_first(DATA_TYPE *T,
-					DATA_TYPE *x,
-					int points){
+                                        DATA_TYPE *x,
+                                        int points){
   
   DATA_TYPE *x1        = x          + points      - 8;
   DATA_TYPE *x2        = x          + (points>>1) - 8;
   REG_TYPE   r0;
   REG_TYPE   r1;
 
   do{
     
                r0      = x1[6]      -  x2[6];
-	       r1      = x1[7]      -  x2[7];
-	       x1[6]  += x2[6];
-	       x1[7]  += x2[7];
-	       x2[6]   = MULT_NORM(r1 * T[1]  +  r0 * T[0]);
-	       x2[7]   = MULT_NORM(r1 * T[0]  -  r0 * T[1]);
-	       
-	       r0      = x1[4]      -  x2[4];
-	       r1      = x1[5]      -  x2[5];
-	       x1[4]  += x2[4];
-	       x1[5]  += x2[5];
-	       x2[4]   = MULT_NORM(r1 * T[5]  +  r0 * T[4]);
-	       x2[5]   = MULT_NORM(r1 * T[4]  -  r0 * T[5]);
-	       
-	       r0      = x1[2]      -  x2[2];
-	       r1      = x1[3]      -  x2[3];
-	       x1[2]  += x2[2];
-	       x1[3]  += x2[3];
-	       x2[2]   = MULT_NORM(r1 * T[9]  +  r0 * T[8]);
-	       x2[3]   = MULT_NORM(r1 * T[8]  -  r0 * T[9]);
-	       
-	       r0      = x1[0]      -  x2[0];
-	       r1      = x1[1]      -  x2[1];
-	       x1[0]  += x2[0];
-	       x1[1]  += x2[1];
-	       x2[0]   = MULT_NORM(r1 * T[13] +  r0 * T[12]);
-	       x2[1]   = MULT_NORM(r1 * T[12] -  r0 * T[13]);
-	       
+               r1      = x1[7]      -  x2[7];
+               x1[6]  += x2[6];
+               x1[7]  += x2[7];
+               x2[6]   = MULT_NORM(r1 * T[1]  +  r0 * T[0]);
+               x2[7]   = MULT_NORM(r1 * T[0]  -  r0 * T[1]);
+               
+               r0      = x1[4]      -  x2[4];
+               r1      = x1[5]      -  x2[5];
+               x1[4]  += x2[4];
+               x1[5]  += x2[5];
+               x2[4]   = MULT_NORM(r1 * T[5]  +  r0 * T[4]);
+               x2[5]   = MULT_NORM(r1 * T[4]  -  r0 * T[5]);
+               
+               r0      = x1[2]      -  x2[2];
+               r1      = x1[3]      -  x2[3];
+               x1[2]  += x2[2];
+               x1[3]  += x2[3];
+               x2[2]   = MULT_NORM(r1 * T[9]  +  r0 * T[8]);
+               x2[3]   = MULT_NORM(r1 * T[8]  -  r0 * T[9]);
+               
+               r0      = x1[0]      -  x2[0];
+               r1      = x1[1]      -  x2[1];
+               x1[0]  += x2[0];
+               x1[1]  += x2[1];
+               x2[0]   = MULT_NORM(r1 * T[13] +  r0 * T[12]);
+               x2[1]   = MULT_NORM(r1 * T[12] -  r0 * T[13]);
+               
     x1-=8;
     x2-=8;
     T+=16;
 
   }while(x2>=x);
 }
 
 /* N/stage point generic N stage butterfly (in place, 2 register) */
 STIN void mdct_butterfly_generic(DATA_TYPE *T,
-					  DATA_TYPE *x,
-					  int points,
-					  int trigint){
+                                          DATA_TYPE *x,
+                                          int points,
+                                          int trigint){
   
   DATA_TYPE *x1        = x          + points      - 8;
   DATA_TYPE *x2        = x          + (points>>1) - 8;
   REG_TYPE   r0;
   REG_TYPE   r1;
 
   do{
     
                r0      = x1[6]      -  x2[6];
-	       r1      = x1[7]      -  x2[7];
-	       x1[6]  += x2[6];
-	       x1[7]  += x2[7];
-	       x2[6]   = MULT_NORM(r1 * T[1]  +  r0 * T[0]);
-	       x2[7]   = MULT_NORM(r1 * T[0]  -  r0 * T[1]);
-	       
-	       T+=trigint;
-	       
-	       r0      = x1[4]      -  x2[4];
-	       r1      = x1[5]      -  x2[5];
-	       x1[4]  += x2[4];
-	       x1[5]  += x2[5];
-	       x2[4]   = MULT_NORM(r1 * T[1]  +  r0 * T[0]);
-	       x2[5]   = MULT_NORM(r1 * T[0]  -  r0 * T[1]);
-	       
-	       T+=trigint;
-	       
-	       r0      = x1[2]      -  x2[2];
-	       r1      = x1[3]      -  x2[3];
-	       x1[2]  += x2[2];
-	       x1[3]  += x2[3];
-	       x2[2]   = MULT_NORM(r1 * T[1]  +  r0 * T[0]);
-	       x2[3]   = MULT_NORM(r1 * T[0]  -  r0 * T[1]);
-	       
-	       T+=trigint;
-	       
-	       r0      = x1[0]      -  x2[0];
-	       r1      = x1[1]      -  x2[1];
-	       x1[0]  += x2[0];
-	       x1[1]  += x2[1];
-	       x2[0]   = MULT_NORM(r1 * T[1]  +  r0 * T[0]);
-	       x2[1]   = MULT_NORM(r1 * T[0]  -  r0 * T[1]);
+               r1      = x1[7]      -  x2[7];
+               x1[6]  += x2[6];
+               x1[7]  += x2[7];
+               x2[6]   = MULT_NORM(r1 * T[1]  +  r0 * T[0]);
+               x2[7]   = MULT_NORM(r1 * T[0]  -  r0 * T[1]);
+               
+               T+=trigint;
+               
+               r0      = x1[4]      -  x2[4];
+               r1      = x1[5]      -  x2[5];
+               x1[4]  += x2[4];
+               x1[5]  += x2[5];
+               x2[4]   = MULT_NORM(r1 * T[1]  +  r0 * T[0]);
+               x2[5]   = MULT_NORM(r1 * T[0]  -  r0 * T[1]);
+               
+               T+=trigint;
+               
+               r0      = x1[2]      -  x2[2];
+               r1      = x1[3]      -  x2[3];
+               x1[2]  += x2[2];
+               x1[3]  += x2[3];
+               x2[2]   = MULT_NORM(r1 * T[1]  +  r0 * T[0]);
+               x2[3]   = MULT_NORM(r1 * T[0]  -  r0 * T[1]);
+               
+               T+=trigint;
+               
+               r0      = x1[0]      -  x2[0];
+               r1      = x1[1]      -  x2[1];
+               x1[0]  += x2[0];
+               x1[1]  += x2[1];
+               x2[0]   = MULT_NORM(r1 * T[1]  +  r0 * T[0]);
+               x2[1]   = MULT_NORM(r1 * T[0]  -  r0 * T[1]);
 
-	       T+=trigint;
+               T+=trigint;
     x1-=8;
     x2-=8;
 
   }while(x2>=x);
 }
 
 STIN void mdct_butterflies(mdct_lookup *init,
-			     DATA_TYPE *x,
-			     int points){
+                             DATA_TYPE *x,
+                             int points){
   
   DATA_TYPE *T=init->trig;
   int stages=init->log2n-5;
   int i,j;
   
   if(--stages>0){
     mdct_butterfly_first(T,x,points);
   }
@@ -340,61 +340,61 @@ void mdct_clear(mdct_lookup *l){
   if(l){
     if(l->trig)_ogg_free(l->trig);
     if(l->bitrev)_ogg_free(l->bitrev);
     memset(l,0,sizeof(*l));
   }
 }
 
 STIN void mdct_bitreverse(mdct_lookup *init, 
-			    DATA_TYPE *x){
+                            DATA_TYPE *x){
   int        n       = init->n;
   int       *bit     = init->bitrev;
   DATA_TYPE *w0      = x;
   DATA_TYPE *w1      = x = w0+(n>>1);
   DATA_TYPE *T       = init->trig+n;
 
   do{
     DATA_TYPE *x0    = x+bit[0];
     DATA_TYPE *x1    = x+bit[1];
 
     REG_TYPE  r0     = x0[1]  - x1[1];
     REG_TYPE  r1     = x0[0]  + x1[0];
     REG_TYPE  r2     = MULT_NORM(r1     * T[0]   + r0 * T[1]);
     REG_TYPE  r3     = MULT_NORM(r1     * T[1]   - r0 * T[0]);
 
-	      w1    -= 4;
+              w1    -= 4;
 
               r0     = HALVE(x0[1] + x1[1]);
               r1     = HALVE(x0[0] - x1[0]);
       
-	      w0[0]  = r0     + r2;
-	      w1[2]  = r0     - r2;
-	      w0[1]  = r1     + r3;
-	      w1[3]  = r3     - r1;
+              w0[0]  = r0     + r2;
+              w1[2]  = r0     - r2;
+              w0[1]  = r1     + r3;
+              w1[3]  = r3     - r1;
 
               x0     = x+bit[2];
               x1     = x+bit[3];
 
               r0     = x0[1]  - x1[1];
               r1     = x0[0]  + x1[0];
               r2     = MULT_NORM(r1     * T[2]   + r0 * T[3]);
               r3     = MULT_NORM(r1     * T[3]   - r0 * T[2]);
 
               r0     = HALVE(x0[1] + x1[1]);
               r1     = HALVE(x0[0] - x1[0]);
       
-	      w0[2]  = r0     + r2;
-	      w1[0]  = r0     - r2;
-	      w0[3]  = r1     + r3;
-	      w1[1]  = r3     - r1;
+              w0[2]  = r0     + r2;
+              w1[0]  = r0     - r2;
+              w0[3]  = r1     + r3;
+              w1[1]  = r3     - r1;
 
-	      T     += 4;
-	      bit   += 4;
-	      w0    += 4;
+              T     += 4;
+              bit   += 4;
+              w0    += 4;
 
   }while(w0<w1);
 }
 
 void mdct_backward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out){
   int n=init->n;
   int n2=n>>1;
   int n4=n>>2;
--- a/media/libvorbis/lib/vorbis_psy.c
+++ b/media/libvorbis/lib/vorbis_psy.c
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: psychoacoustics not including preecho
- last mod: $Id: psy.c 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #include <stdlib.h>
 #include <math.h>
 #include <string.h>
 #include "vorbis/codec.h"
 #include "codec_internal.h"
@@ -25,18 +25,18 @@
 #include "psy.h"
 #include "os.h"
 #include "lpc.h"
 #include "smallft.h"
 #include "scales.h"
 #include "misc.h"
 
 #define NEGINF -9999.f
-static double stereo_threshholds[]={0.0, .5, 1.0, 1.5, 2.5, 4.5, 8.5, 16.5, 9e10};
-static double stereo_threshholds_limited[]={0.0, .5, 1.0, 1.5, 2.0, 2.5, 4.5, 8.5, 9e10};
+static const double stereo_threshholds[]={0.0, .5, 1.0, 1.5, 2.5, 4.5, 8.5, 16.5, 9e10};
+static const double stereo_threshholds_limited[]={0.0, .5, 1.0, 1.5, 2.0, 2.5, 4.5, 8.5, 9e10};
 
 vorbis_look_psy_global *_vp_global_look(vorbis_info *vi){
   codec_setup_info *ci=vi->codec_setup;
   vorbis_info_psy_global *gi=&ci->psy_g_param;
   vorbis_look_psy_global *look=_ogg_calloc(1,sizeof(*look));
 
   look->channels=vi->channels;
 
@@ -62,34 +62,34 @@ void _vi_gpsy_free(vorbis_info_psy_globa
 void _vi_psy_free(vorbis_info_psy *i){
   if(i){
     memset(i,0,sizeof(*i));
     _ogg_free(i);
   }
 }
 
 static void min_curve(float *c,
-		       float *c2){
+                       float *c2){
   int i;  
   for(i=0;i<EHMER_MAX;i++)if(c2[i]<c[i])c[i]=c2[i];
 }
 static void max_curve(float *c,
-		       float *c2){
+                       float *c2){
   int i;  
   for(i=0;i<EHMER_MAX;i++)if(c2[i]>c[i])c[i]=c2[i];
 }
 
 static void attenuate_curve(float *c,float att){
   int i;
   for(i=0;i<EHMER_MAX;i++)
     c[i]+=att;
 }
 
 static float ***setup_tone_curves(float curveatt_dB[P_BANDS],float binHz,int n,
-				  float center_boost, float center_decay_rate){
+                                  float center_boost, float center_decay_rate){
   int i,j,k,m;
   float ath[EHMER_MAX];
   float workc[P_BANDS][P_LEVELS][EHMER_MAX];
   float athc[P_LEVELS][EHMER_MAX];
   float *brute_buffer=alloca(n*sizeof(*brute_buffer));
 
   float ***ret=_ogg_malloc(sizeof(*ret)*P_BANDS);
 
@@ -101,38 +101,38 @@ static float ***setup_tone_curves(float 
        curve limiting (last step). */
 
     /* A half-band's settings must be valid over the whole band, and
        it's better to mask too little than too much */  
     int ath_offset=i*4;
     for(j=0;j<EHMER_MAX;j++){
       float min=999.;
       for(k=0;k<4;k++)
-	if(j+k+ath_offset<MAX_ATH){
-	  if(min>ATH[j+k+ath_offset])min=ATH[j+k+ath_offset];
-	}else{
-	  if(min>ATH[MAX_ATH-1])min=ATH[MAX_ATH-1];
-	}
+        if(j+k+ath_offset<MAX_ATH){
+          if(min>ATH[j+k+ath_offset])min=ATH[j+k+ath_offset];
+        }else{
+          if(min>ATH[MAX_ATH-1])min=ATH[MAX_ATH-1];
+        }
       ath[j]=min;
     }
 
     /* copy curves into working space, replicate the 50dB curve to 30
        and 40, replicate the 100dB curve to 110 */
     for(j=0;j<6;j++)
       memcpy(workc[i][j+2],tonemasks[i][j],EHMER_MAX*sizeof(*tonemasks[i][j]));
     memcpy(workc[i][0],tonemasks[i][0],EHMER_MAX*sizeof(*tonemasks[i][0]));
     memcpy(workc[i][1],tonemasks[i][0],EHMER_MAX*sizeof(*tonemasks[i][0]));
     
     /* apply centered curve boost/decay */
     for(j=0;j<P_LEVELS;j++){
       for(k=0;k<EHMER_MAX;k++){
-	float adj=center_boost+abs(EHMER_OFFSET-k)*center_decay_rate;
-	if(adj<0. && center_boost>0)adj=0.;
-	if(adj>0. && center_boost<0)adj=0.;
-	workc[i][j][k]+=adj;
+        float adj=center_boost+abs(EHMER_OFFSET-k)*center_decay_rate;
+        if(adj<0. && center_boost>0)adj=0.;
+        if(adj>0. && center_boost<0)adj=0.;
+        workc[i][j][k]+=adj;
       }
     }
 
     /* normalize curves so the driving amplitude is 0dB */
     /* make temp curves with the ATH overlayed */
     for(j=0;j<P_LEVELS;j++){
       attenuate_curve(workc[i][j],curveatt_dB[i]+100.-(j<2?2:j)*10.-P_LEVEL_0);
       memcpy(athc[j],ath,EHMER_MAX*sizeof(**athc));
@@ -178,99 +178,99 @@ static float ***setup_tone_curves(float 
     if(hi_curve>=P_BANDS)hi_curve=P_BANDS-1;
 
     for(m=0;m<P_LEVELS;m++){
       ret[i][m]=_ogg_malloc(sizeof(***ret)*(EHMER_MAX+2));
       
       for(j=0;j<n;j++)brute_buffer[j]=999.;
       
       /* render the curve into bins, then pull values back into curve.
-	 The point is that any inherent subsampling aliasing results in
-	 a safe minimum */
+         The point is that any inherent subsampling aliasing results in
+         a safe minimum */
       for(k=lo_curve;k<=hi_curve;k++){
-	int l=0;
+        int l=0;
 
-	for(j=0;j<EHMER_MAX;j++){
-	  int lo_bin= fromOC(j*.125+k*.5-2.0625)/binHz;
-	  int hi_bin= fromOC(j*.125+k*.5-1.9375)/binHz+1;
-	  
-	  if(lo_bin<0)lo_bin=0;
-	  if(lo_bin>n)lo_bin=n;
-	  if(lo_bin<l)l=lo_bin;
-	  if(hi_bin<0)hi_bin=0;
-	  if(hi_bin>n)hi_bin=n;
+        for(j=0;j<EHMER_MAX;j++){
+          int lo_bin= fromOC(j*.125+k*.5-2.0625)/binHz;
+          int hi_bin= fromOC(j*.125+k*.5-1.9375)/binHz+1;
+          
+          if(lo_bin<0)lo_bin=0;
+          if(lo_bin>n)lo_bin=n;
+          if(lo_bin<l)l=lo_bin;
+          if(hi_bin<0)hi_bin=0;
+          if(hi_bin>n)hi_bin=n;
 
-	  for(;l<hi_bin && l<n;l++)
-	    if(brute_buffer[l]>workc[k][m][j])
-	      brute_buffer[l]=workc[k][m][j];
-	}
+          for(;l<hi_bin && l<n;l++)
+            if(brute_buffer[l]>workc[k][m][j])
+              brute_buffer[l]=workc[k][m][j];
+        }
 
-	for(;l<n;l++)
-	  if(brute_buffer[l]>workc[k][m][EHMER_MAX-1])
-	    brute_buffer[l]=workc[k][m][EHMER_MAX-1];
+        for(;l<n;l++)
+          if(brute_buffer[l]>workc[k][m][EHMER_MAX-1])
+            brute_buffer[l]=workc[k][m][EHMER_MAX-1];
 
       }
 
       /* be equally paranoid about being valid up to next half ocatve */
       if(i+1<P_BANDS){
-	int l=0;
-	k=i+1;
-	for(j=0;j<EHMER_MAX;j++){
-	  int lo_bin= fromOC(j*.125+i*.5-2.0625)/binHz;
-	  int hi_bin= fromOC(j*.125+i*.5-1.9375)/binHz+1;
-	  
-	  if(lo_bin<0)lo_bin=0;
-	  if(lo_bin>n)lo_bin=n;
-	  if(lo_bin<l)l=lo_bin;
-	  if(hi_bin<0)hi_bin=0;
-	  if(hi_bin>n)hi_bin=n;
+        int l=0;
+        k=i+1;
+        for(j=0;j<EHMER_MAX;j++){
+          int lo_bin= fromOC(j*.125+i*.5-2.0625)/binHz;
+          int hi_bin= fromOC(j*.125+i*.5-1.9375)/binHz+1;
+          
+          if(lo_bin<0)lo_bin=0;
+          if(lo_bin>n)lo_bin=n;
+          if(lo_bin<l)l=lo_bin;
+          if(hi_bin<0)hi_bin=0;
+          if(hi_bin>n)hi_bin=n;
 
-	  for(;l<hi_bin && l<n;l++)
-	    if(brute_buffer[l]>workc[k][m][j])
-	      brute_buffer[l]=workc[k][m][j];
-	}
+          for(;l<hi_bin && l<n;l++)
+            if(brute_buffer[l]>workc[k][m][j])
+              brute_buffer[l]=workc[k][m][j];
+        }
 
-	for(;l<n;l++)
-	  if(brute_buffer[l]>workc[k][m][EHMER_MAX-1])
-	    brute_buffer[l]=workc[k][m][EHMER_MAX-1];
+        for(;l<n;l++)
+          if(brute_buffer[l]>workc[k][m][EHMER_MAX-1])
+            brute_buffer[l]=workc[k][m][EHMER_MAX-1];
 
       }
 
 
       for(j=0;j<EHMER_MAX;j++){
-	int bin=fromOC(j*.125+i*.5-2.)/binHz;
-	if(bin<0){
-	  ret[i][m][j+2]=-999.;
-	}else{
-	  if(bin>=n){
-	    ret[i][m][j+2]=-999.;
-	  }else{
-	    ret[i][m][j+2]=brute_buffer[bin];
-	  }
-	}
+        int bin=fromOC(j*.125+i*.5-2.)/binHz;
+        if(bin<0){
+          ret[i][m][j+2]=-999.;
+        }else{
+          if(bin>=n){
+            ret[i][m][j+2]=-999.;
+          }else{
+            ret[i][m][j+2]=brute_buffer[bin];
+          }
+        }
       }
 
       /* add fenceposts */
       for(j=0;j<EHMER_OFFSET;j++)
-	if(ret[i][m][j+2]>-200.f)break;  
+        if(ret[i][m][j+2]>-200.f)break;  
       ret[i][m][0]=j;
       
       for(j=EHMER_MAX-1;j>EHMER_OFFSET+1;j--)
-	if(ret[i][m][j+2]>-200.f)
-	  break;
+        if(ret[i][m][j+2]>-200.f)
+          break;
       ret[i][m][1]=j;
 
     }
   }
 
   return(ret);
 }
 
 void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,
-		  vorbis_info_psy_global *gi,int n,long rate){
+                  vorbis_info_psy_global *gi,int n,long rate){
   long i,j,lo=-99,hi=1;
   long maxoc;
   memset(p,0,sizeof(*p));
 
   p->eighth_octave_lines=gi->eighth_octave_lines;
   p->shiftoc=rint(log(gi->eighth_octave_lines*8.f)/log(2.f))-1;
 
   p->firstoc=toOC(.25f*rate*.5/n)*(1<<(p->shiftoc+1))-gi->eighth_octave_lines;
@@ -299,34 +299,38 @@ void _vp_psy_init(vorbis_look_psy *p,vor
       float delta=(ATH[i+1]-base)/(endpos-j);
       for(;j<endpos && j<n;j++){
         p->ath[j]=base+100.;
         base+=delta;
       }
     }
   }
 
+  for(;j<n;j++){
+    p->ath[j]=p->ath[j-1];
+  }
+
   for(i=0;i<n;i++){
     float bark=toBARK(rate/(2*n)*i); 
 
     for(;lo+vi->noisewindowlomin<i && 
-	  toBARK(rate/(2*n)*lo)<(bark-vi->noisewindowlo);lo++);
+          toBARK(rate/(2*n)*lo)<(bark-vi->noisewindowlo);lo++);
     
     for(;hi<=n && (hi<i+vi->noisewindowhimin ||
-	  toBARK(rate/(2*n)*hi)<(bark+vi->noisewindowhi));hi++);
+          toBARK(rate/(2*n)*hi)<(bark+vi->noisewindowhi));hi++);
     
     p->bark[i]=((lo-1)<<16)+(hi-1);
 
   }
 
   for(i=0;i<n;i++)
     p->octave[i]=toOC((i+.25f)*.5*rate/n)*(1<<(p->shiftoc+1))+.5f;
 
   p->tonecurves=setup_tone_curves(vi->toneatt,rate*.5/n,n,
-				  vi->tone_centerboost,vi->tone_decay);
+                                  vi->tone_centerboost,vi->tone_decay);
   
   /* set up rolling noise median */
   p->noiseoffset=_ogg_malloc(P_NOISECURVES*sizeof(*p->noiseoffset));
   for(i=0;i<P_NOISECURVES;i++)
     p->noiseoffset[i]=_ogg_malloc(n*sizeof(**p->noiseoffset));
   
   for(i=0;i<n;i++){
     float halfoc=toOC((i+.5)*rate/(2.*n))*2.;
@@ -335,18 +339,18 @@ void _vp_psy_init(vorbis_look_psy *p,vor
     
     if(halfoc<0)halfoc=0;
     if(halfoc>=P_BANDS-1)halfoc=P_BANDS-1;
     inthalfoc=(int)halfoc;
     del=halfoc-inthalfoc;
     
     for(j=0;j<P_NOISECURVES;j++)
       p->noiseoffset[j][i]=
-	p->vi->noiseoff[j][inthalfoc]*(1.-del) + 
-	p->vi->noiseoff[j][inthalfoc+1]*del;
+        p->vi->noiseoff[j][inthalfoc]*(1.-del) + 
+        p->vi->noiseoff[j][inthalfoc+1]*del;
     
   }
 #if 0
   {
     static int ls=0;
     _analysis_output_always("noiseoff0",ls,p->noiseoffset[0],n,1,0,0);
     _analysis_output_always("noiseoff1",ls,p->noiseoffset[1],n,1,0,0);
     _analysis_output_always("noiseoff2",ls++,p->noiseoffset[2],n,1,0,0);
@@ -357,39 +361,39 @@ void _vp_psy_init(vorbis_look_psy *p,vor
 void _vp_psy_clear(vorbis_look_psy *p){
   int i,j;
   if(p){
     if(p->ath)_ogg_free(p->ath);
     if(p->octave)_ogg_free(p->octave);
     if(p->bark)_ogg_free(p->bark);
     if(p->tonecurves){
       for(i=0;i<P_BANDS;i++){
-	for(j=0;j<P_LEVELS;j++){
-	  _ogg_free(p->tonecurves[i][j]);
-	}
-	_ogg_free(p->tonecurves[i]);
+        for(j=0;j<P_LEVELS;j++){
+          _ogg_free(p->tonecurves[i][j]);
+        }
+        _ogg_free(p->tonecurves[i]);
       }
       _ogg_free(p->tonecurves);
     }
     if(p->noiseoffset){
       for(i=0;i<P_NOISECURVES;i++){
         _ogg_free(p->noiseoffset[i]);
       }
       _ogg_free(p->noiseoffset);
     }
     memset(p,0,sizeof(*p));
   }
 }
 
 /* octave/(8*eighth_octave_lines) x scale and dB y scale */
 static void seed_curve(float *seed,
-		       const float **curves,
-		       float amp,
-		       int oc, int n,
-		       int linesper,float dBoffset){
+                       const float **curves,
+                       float amp,
+                       int oc, int n,
+                       int linesper,float dBoffset){
   int i,post1;
   int seedptr;
   const float *posts,*curve;
 
   int choice=(int)((amp+dBoffset-P_LEVEL_0)*.1f);
   choice=max(choice,0);
   choice=min(choice,P_LEVELS-1);
   posts=curves[choice];
@@ -403,21 +407,21 @@ static void seed_curve(float *seed,
       if(seed[seedptr]<lin)seed[seedptr]=lin;
     }
     seedptr+=linesper;
     if(seedptr>=n)break;
   }
 }
 
 static void seed_loop(vorbis_look_psy *p,
-		      const float ***curves,
-		      const float *f, 
-		      const float *flr,
-		      float *seed,
-		      float specmax){
+                      const float ***curves,
+                      const float *f, 
+                      const float *flr,
+                      float *seed,
+                      float specmax){
   vorbis_info_psy *vi=p->vi;
   long n=p->n,i;
   float dBoffset=vi->max_curve_dB-specmax;
 
   /* prime the working vector with peak values */
 
   for(i=0;i<n;i++){
     float max=f[i];
@@ -429,22 +433,22 @@ static void seed_loop(vorbis_look_psy *p
     
     if(max+6.f>flr[i]){
       oc=oc>>p->shiftoc;
 
       if(oc>=P_BANDS)oc=P_BANDS-1;
       if(oc<0)oc=0;
 
       seed_curve(seed,
-		 curves[oc],
-		 max,
-		 p->octave[i]-p->firstoc,
-		 p->total_octave_lines,
-		 p->eighth_octave_lines,
-		 dBoffset);
+                 curves[oc],
+                 max,
+                 p->octave[i]-p->firstoc,
+                 p->total_octave_lines,
+                 p->eighth_octave_lines,
+                 dBoffset);
     }
   }
 }
 
 static void seed_chase(float *seeds, int linesper, long n){
   long  *posstack=alloca(n*sizeof(*posstack));
   float *ampstack=alloca(n*sizeof(*ampstack));
   long   stack=0;
@@ -452,81 +456,81 @@ static void seed_chase(float *seeds, int
   long   i;
 
   for(i=0;i<n;i++){
     if(stack<2){
       posstack[stack]=i;
       ampstack[stack++]=seeds[i];
     }else{
       while(1){
-	if(seeds[i]<ampstack[stack-1]){
-	  posstack[stack]=i;
-	  ampstack[stack++]=seeds[i];
-	  break;
-	}else{
-	  if(i<posstack[stack-1]+linesper){
-	    if(stack>1 && ampstack[stack-1]<=ampstack[stack-2] &&
-	       i<posstack[stack-2]+linesper){
-	      /* we completely overlap, making stack-1 irrelevant.  pop it */
-	      stack--;
-	      continue;
-	    }
-	  }
-	  posstack[stack]=i;
-	  ampstack[stack++]=seeds[i];
-	  break;
+        if(seeds[i]<ampstack[stack-1]){
+          posstack[stack]=i;
+          ampstack[stack++]=seeds[i];
+          break;
+        }else{
+          if(i<posstack[stack-1]+linesper){
+            if(stack>1 && ampstack[stack-1]<=ampstack[stack-2] &&
+               i<posstack[stack-2]+linesper){
+              /* we completely overlap, making stack-1 irrelevant.  pop it */
+              stack--;
+              continue;
+            }
+          }
+          posstack[stack]=i;
+          ampstack[stack++]=seeds[i];
+          break;
 
-	}
+        }
       }
     }
   }
 
   /* the stack now contains only the positions that are relevant. Scan
      'em straight through */
 
   for(i=0;i<stack;i++){
     long endpos;
     if(i<stack-1 && ampstack[i+1]>ampstack[i]){
       endpos=posstack[i+1];
     }else{
       endpos=posstack[i]+linesper+1; /* +1 is important, else bin 0 is
-					discarded in short frames */
+                                        discarded in short frames */
     }
     if(endpos>n)endpos=n;
     for(;pos<endpos;pos++)
       seeds[pos]=ampstack[i];
   }
   
   /* there.  Linear time.  I now remember this was on a problem set I
      had in Grad Skool... I didn't solve it at the time ;-) */
 
 }
 
 /* bleaugh, this is more complicated than it needs to be */
 #include<stdio.h>
 static void max_seeds(vorbis_look_psy *p,
-		      float *seed,
-		      float *flr){
+                      float *seed,
+                      float *flr){
   long   n=p->total_octave_lines;
   int    linesper=p->eighth_octave_lines;
   long   linpos=0;
   long   pos;
 
   seed_chase(seed,linesper,n); /* for masking */
  
   pos=p->octave[0]-p->firstoc-(linesper>>1);
 
   while(linpos+1<p->n){
     float minV=seed[pos];
     long end=((p->octave[linpos]+p->octave[linpos+1])>>1)-p->firstoc;
     if(minV>p->vi->tone_abs_limit)minV=p->vi->tone_abs_limit;
     while(pos+1<=end){
       pos++;
       if((seed[pos]>NEGINF && seed[pos]<minV) || minV==NEGINF)
-	minV=seed[pos];
+        minV=seed[pos];
     }
     
     end=pos+p->firstoc;
     for(;linpos<p->n && p->octave[linpos]<=end;linpos++)
       if(flr[linpos]<minV)flr[linpos]=minV;
   }
   
   {
@@ -687,17 +691,17 @@ static void bark_noise_hybridmp(int n,co
     if (R - offset < noise[i]) noise[i] = R - offset;
   }
   for ( ; i < n; i++, x += 1.f) {
     R = (A + x * B) / D;
     if (R - offset < noise[i]) noise[i] = R - offset;
   }
 }
 
-static float FLOOR1_fromdB_INV_LOOKUP[256]={
+static const float FLOOR1_fromdB_INV_LOOKUP[256]={
   0.F, 8.81683e+06F, 8.27882e+06F, 7.77365e+06F, 
   7.29930e+06F, 6.85389e+06F, 6.43567e+06F, 6.04296e+06F, 
   5.67422e+06F, 5.32798e+06F, 5.00286e+06F, 4.69759e+06F, 
   4.41094e+06F, 4.14178e+06F, 3.88905e+06F, 3.65174e+06F, 
   3.42891e+06F, 3.21968e+06F, 3.02321e+06F, 2.83873e+06F, 
   2.66551e+06F, 2.50286e+06F, 2.35014e+06F, 2.20673e+06F, 
   2.07208e+06F, 1.94564e+06F, 1.82692e+06F, 1.71544e+06F, 
   1.61076e+06F, 1.51247e+06F, 1.42018e+06F, 1.33352e+06F, 
@@ -755,48 +759,48 @@ static float FLOOR1_fromdB_INV_LOOKUP[25
   3.30774F, 3.10590F, 2.91638F, 2.73842F, 
   2.57132F, 2.41442F, 2.26709F, 2.12875F, 
   1.99885F, 1.87688F, 1.76236F, 1.65482F, 
   1.55384F, 1.45902F, 1.36999F, 1.28640F, 
   1.20790F, 1.13419F, 1.06499F, 1.F
 };
 
 void _vp_remove_floor(vorbis_look_psy *p,
-		      float *mdct,
-		      int *codedflr,
-		      float *residue,
-		      int sliding_lowpass){ 
+                      float *mdct,
+                      int *codedflr,
+                      float *residue,
+                      int sliding_lowpass){ 
 
   int i,n=p->n;
  
   if(sliding_lowpass>n)sliding_lowpass=n;
   
   for(i=0;i<sliding_lowpass;i++){
     residue[i]=
       mdct[i]*FLOOR1_fromdB_INV_LOOKUP[codedflr[i]];
   }
 
   for(;i<n;i++)
     residue[i]=0.;
 }
 
 void _vp_noisemask(vorbis_look_psy *p,
-		   float *logmdct, 
-		   float *logmask){
+                   float *logmdct, 
+                   float *logmask){
 
   int i,n=p->n;
   float *work=alloca(n*sizeof(*work));
 
   bark_noise_hybridmp(n,p->bark,logmdct,logmask,
-		      140.,-1);
+                      140.,-1);
 
   for(i=0;i<n;i++)work[i]=logmdct[i]-logmask[i];
 
   bark_noise_hybridmp(n,p->bark,work,logmask,0.,
-		      p->vi->noisewindowfixed);
+                      p->vi->noisewindowfixed);
 
   for(i=0;i<n;i++)work[i]=logmdct[i]-work[i];
   
 #if 0
   {
     static int seq=0;
 
     float work2[n];
@@ -822,20 +826,20 @@ void _vp_noisemask(vorbis_look_psy *p,
     if(dB>=NOISE_COMPAND_LEVELS)dB=NOISE_COMPAND_LEVELS-1;
     if(dB<0)dB=0;
     logmask[i]= work[i]+p->vi->noisecompand[dB];
   }
 
 }
 
 void _vp_tonemask(vorbis_look_psy *p,
-		  float *logfft,
-		  float *logmask,
-		  float global_specmax,
-		  float local_specmax){
+                  float *logfft,
+                  float *logmask,
+                  float global_specmax,
+                  float local_specmax){
 
   int i,n=p->n;
 
   float *seed=alloca(sizeof(*seed)*p->total_octave_lines);
   float att=local_specmax+p->vi->ath_adjatt;
   for(i=0;i<p->total_octave_lines;i++)seed[i]=NEGINF;
   
   /* set the ATH (floating below localmax, not global max by a
@@ -847,66 +851,66 @@ void _vp_tonemask(vorbis_look_psy *p,
 
   /* tone masking */
   seed_loop(p,(const float ***)p->tonecurves,logfft,logmask,seed,global_specmax);
   max_seeds(p,seed,logmask);
 
 }
 
 void _vp_offset_and_mix(vorbis_look_psy *p,
-			float *noise,
-			float *tone,
-			int offset_select,
-			float *logmask,
-			float *mdct,
-			float *logmdct){
+                        float *noise,
+                        float *tone,
+                        int offset_select,
+                        float *logmask,
+                        float *mdct,
+                        float *logmdct){
   int i,n=p->n;
   float de, coeffi, cx;/* AoTuV */
   float toneatt=p->vi->tone_masteratt[offset_select];
 
   cx = p->m_val;
   
   for(i=0;i<n;i++){
     float val= noise[i]+p->noiseoffset[offset_select][i];
     if(val>p->vi->noisemaxsupp)val=p->vi->noisemaxsupp;
     logmask[i]=max(val,tone[i]+toneatt);
 
 
     /* AoTuV */
     /** @ M1 **
-	The following codes improve a noise problem.  
-	A fundamental idea uses the value of masking and carries out
-	the relative compensation of the MDCT. 
-	However, this code is not perfect and all noise problems cannot be solved. 
-	by Aoyumi @ 2004/04/18
+        The following codes improve a noise problem.  
+        A fundamental idea uses the value of masking and carries out
+        the relative compensation of the MDCT. 
+        However, this code is not perfect and all noise problems cannot be solved. 
+        by Aoyumi @ 2004/04/18
     */
 
     if(offset_select == 1) {
       coeffi = -17.2;       /* coeffi is a -17.2dB threshold */
       val = val - logmdct[i];  /* val == mdct line value relative to floor in dB */
       
       if(val > coeffi){
-	/* mdct value is > -17.2 dB below floor */
-	
-	de = 1.0-((val-coeffi)*0.005*cx);
-	/* pro-rated attenuation:
-	   -0.00 dB boost if mdct value is -17.2dB (relative to floor) 
-	   -0.77 dB boost if mdct value is 0dB (relative to floor) 
-	   -1.64 dB boost if mdct value is +17.2dB (relative to floor) 
-	   etc... */
-	
-	if(de < 0) de = 0.0001;
+        /* mdct value is > -17.2 dB below floor */
+        
+        de = 1.0-((val-coeffi)*0.005*cx);
+        /* pro-rated attenuation:
+           -0.00 dB boost if mdct value is -17.2dB (relative to floor) 
+           -0.77 dB boost if mdct value is 0dB (relative to floor) 
+           -1.64 dB boost if mdct value is +17.2dB (relative to floor) 
+           etc... */
+        
+        if(de < 0) de = 0.0001;
       }else
-	/* mdct value is <= -17.2 dB below floor */
-	
-	de = 1.0-((val-coeffi)*0.0003*cx);
+        /* mdct value is <= -17.2 dB below floor */
+        
+        de = 1.0-((val-coeffi)*0.0003*cx);
       /* pro-rated attenuation:
-	 +0.00 dB atten if mdct value is -17.2dB (relative to floor) 
-	 +0.45 dB atten if mdct value is -34.4dB (relative to floor) 
-	 etc... */
+         +0.00 dB atten if mdct value is -17.2dB (relative to floor) 
+         +0.45 dB atten if mdct value is -34.4dB (relative to floor) 
+         etc... */
       
       mdct[i] *= de;
       
     }
   }
 }
 
 float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd){
@@ -918,17 +922,17 @@ float _vp_ampmax_decay(float amp,vorbis_
   float secs=(float)n/vi->rate;
 
   amp+=secs*gi->ampmax_att_per_sec;
   if(amp<-9999)amp=-9999;
   return(amp);
 }
 
 static void couple_lossless(float A, float B, 
-			    float *qA, float *qB){
+                            float *qA, float *qB){
   int test1=fabs(*qA)>fabs(*qB);
   test1-= fabs(*qA)<fabs(*qB);
   
   if(!test1)test1=((fabs(A)>fabs(B))<<1)-1;
   if(test1==1){
     *qB=(*qA>0.f?*qA-*qB:*qB-*qA);
   }else{
     float temp=*qB;  
@@ -937,29 +941,29 @@ static void couple_lossless(float A, flo
   }
 
   if(*qB>fabs(*qA)*1.9999f){
     *qB= -fabs(*qA)*2.f;
     *qA= -*qA;
   }
 }
 
-static float hypot_lookup[32]={
+static const float hypot_lookup[32]={
   -0.009935, -0.011245, -0.012726, -0.014397, 
   -0.016282, -0.018407, -0.020800, -0.023494, 
   -0.026522, -0.029923, -0.033737, -0.038010, 
   -0.042787, -0.048121, -0.054064, -0.060671, 
   -0.068000, -0.076109, -0.085054, -0.094892, 
   -0.105675, -0.117451, -0.130260, -0.144134, 
   -0.159093, -0.175146, -0.192286, -0.210490, 
   -0.229718, -0.249913, -0.271001, -0.292893};
 
 static void precomputed_couple_point(float premag,
-				     int floorA,int floorB,
-				     float *mag, float *ang){
+                                     int floorA,int floorB,
+                                     float *mag, float *ang){
   
   int test=(floorA>floorB)-1;
   int offset=31-abs(floorA-floorB);
   float floormag=hypot_lookup[((offset<0)-1)&offset]+1.f;
 
   floormag*=FLOOR1_fromdB_INV_LOOKUP[(floorB&test)|(floorA&(~test))];
 
   *mag=premag*floormag;
@@ -990,20 +994,20 @@ static float round_hypot(float a, float 
   }
   if(b<0.)return -sqrt(a*a+b*b);
   if(-a>b)return -sqrt(a*a+b*b);
   return sqrt(b*b+a*a);
 }
 
 /* revert to round hypot for now */
 float **_vp_quantize_couple_memo(vorbis_block *vb,
-				 vorbis_info_psy_global *g,
-				 vorbis_look_psy *p,
-				 vorbis_info_mapping0 *vi,
-				 float **mdct){
+                                 vorbis_info_psy_global *g,
+                                 vorbis_look_psy *p,
+                                 vorbis_info_mapping0 *vi,
+                                 float **mdct){
   
   int i,j,n=p->n;
   float **ret=_vorbis_block_alloc(vb,vi->coupling_steps*sizeof(*ret));
   int limit=g->coupling_pointlimit[p->vi->blockflag][PACKETBLOBS/2];
   
   for(i=0;i<vi->coupling_steps;i++){
     float *mdctM=mdct[vi->coupling_mag[i]];
     float *mdctA=mdct[vi->coupling_ang[i]];
@@ -1020,43 +1024,43 @@ float **_vp_quantize_couple_memo(vorbis_
 /* this is for per-channel noise normalization */
 static int apsort(const void *a, const void *b){
   float f1=fabs(**(float**)a);
   float f2=fabs(**(float**)b);
   return (f1<f2)-(f1>f2);
 }
 
 int **_vp_quantize_couple_sort(vorbis_block *vb,
-			       vorbis_look_psy *p,
-			       vorbis_info_mapping0 *vi,
-			       float **mags){
+                               vorbis_look_psy *p,
+                               vorbis_info_mapping0 *vi,
+                               float **mags){
 
 
   if(p->vi->normal_point_p){
     int i,j,k,n=p->n;
     int **ret=_vorbis_block_alloc(vb,vi->coupling_steps*sizeof(*ret));
     int partition=p->vi->normal_partition;
     float **work=alloca(sizeof(*work)*partition);
     
     for(i=0;i<vi->coupling_steps;i++){
       ret[i]=_vorbis_block_alloc(vb,n*sizeof(**ret));
       
       for(j=0;j<n;j+=partition){
-	for(k=0;k<partition;k++)work[k]=mags[i]+k+j;
-	qsort(work,partition,sizeof(*work),apsort);
-	for(k=0;k<partition;k++)ret[i][k+j]=work[k]-mags[i];
+        for(k=0;k<partition;k++)work[k]=mags[i]+k+j;
+        qsort(work,partition,sizeof(*work),apsort);
+        for(k=0;k<partition;k++)ret[i][k+j]=work[k]-mags[i];
       }
     }
     return(ret);
   }
   return(NULL);
 }
 
 void _vp_noise_normalize_sort(vorbis_look_psy *p,
-			      float *magnitudes,int *sortedindex){
+                              float *magnitudes,int *sortedindex){
   int i,j,n=p->n;
   vorbis_info_psy *vi=p->vi;
   int partition=vi->normal_partition;
   float **work=alloca(sizeof(*work)*partition);
   int start=vi->normal_start;
 
   for(j=start;j<n;j+=partition){
     if(j+partition>n)partition=n-j;
@@ -1064,71 +1068,71 @@ void _vp_noise_normalize_sort(vorbis_loo
     qsort(work,partition,sizeof(*work),apsort);
     for(i=0;i<partition;i++){
       sortedindex[i+j-start]=work[i]-magnitudes;
     }
   }
 }
 
 void _vp_noise_normalize(vorbis_look_psy *p,
-			 float *in,float *out,int *sortedindex){
+                         float *in,float *out,int *sortedindex){
   int flag=0,i,j=0,n=p->n;
   vorbis_info_psy *vi=p->vi;
   int partition=vi->normal_partition;
   int start=vi->normal_start;
 
   if(start>n)start=n;
 
   if(vi->normal_channel_p){
     for(;j<start;j++)
       out[j]=rint(in[j]);
     
     for(;j+partition<=n;j+=partition){
       float acc=0.;
       int k;
       
       for(i=j;i<j+partition;i++)
-	acc+=in[i]*in[i];
+        acc+=in[i]*in[i];
       
       for(i=0;i<partition;i++){
-	k=sortedindex[i+j-start];
-	
-	if(in[k]*in[k]>=.25f){
-	  out[k]=rint(in[k]);
-	  acc-=in[k]*in[k];
-	  flag=1;
-	}else{
-	  if(acc<vi->normal_thresh)break;
-	  out[k]=unitnorm(in[k]);
-	  acc-=1.;
-	}
+        k=sortedindex[i+j-start];
+        
+        if(in[k]*in[k]>=.25f){
+          out[k]=rint(in[k]);
+          acc-=in[k]*in[k];
+          flag=1;
+        }else{
+          if(acc<vi->normal_thresh)break;
+          out[k]=unitnorm(in[k]);
+          acc-=1.;
+        }
       }
       
       for(;i<partition;i++){
-	k=sortedindex[i+j-start];
-	out[k]=0.;
+        k=sortedindex[i+j-start];
+        out[k]=0.;
       }
     }
   }
   
   for(;j<n;j++)
     out[j]=rint(in[j]);
   
 }
 
 void _vp_couple(int blobno,
-		vorbis_info_psy_global *g,
-		vorbis_look_psy *p,
-		vorbis_info_mapping0 *vi,
-		float **res,
-		float **mag_memo,
-		int   **mag_sort,
-		int   **ifloor,
-		int   *nonzero,
-		int  sliding_lowpass){
+                vorbis_info_psy_global *g,
+                vorbis_look_psy *p,
+                vorbis_info_mapping0 *vi,
+                float **res,
+                float **mag_memo,
+                int   **mag_sort,
+                int   **ifloor,
+                int   *nonzero,
+                int  sliding_lowpass){
 
   int i,j,k,n=p->n;
 
   /* perform any requested channel coupling */
   /* point stereo can only be used in a first stage (in this encoder)
      because of the dependency on floor lookups */
   for(i=0;i<vi->coupling_steps;i++){
 
@@ -1160,49 +1164,49 @@ void _vp_couple(int blobno,
       nonzero[vi->coupling_mag[i]]=1; 
       nonzero[vi->coupling_ang[i]]=1; 
 
        /* The threshold of a stereo is changed with the size of n */
        if(n > 1000)
          postpoint=stereo_threshholds_limited[g->coupling_postpointamp[blobno]]; 
  
       for(j=0;j<p->n;j+=partition){
-	float acc=0.f;
+        float acc=0.f;
 
-	for(k=0;k<partition;k++){
-	  int l=k+j;
+        for(k=0;k<partition;k++){
+          int l=k+j;
 
-	  if(l<sliding_lowpass){
-	    if((l>=limit && fabs(rM[l])<postpoint && fabs(rA[l])<postpoint) ||
-	       (fabs(rM[l])<prepoint && fabs(rA[l])<prepoint)){
+          if(l<sliding_lowpass){
+            if((l>=limit && fabs(rM[l])<postpoint && fabs(rA[l])<postpoint) ||
+               (fabs(rM[l])<prepoint && fabs(rA[l])<prepoint)){
 
 
-	      precomputed_couple_point(mag_memo[i][l],
-				       floorM[l],floorA[l],
-				       qM+l,qA+l);
+              precomputed_couple_point(mag_memo[i][l],
+                                       floorM[l],floorA[l],
+                                       qM+l,qA+l);
 
-	      if(rint(qM[l])==0.f)acc+=qM[l]*qM[l];
-	    }else{
-	      couple_lossless(rM[l],rA[l],qM+l,qA+l);
-	    }
-	  }else{
-	    qM[l]=0.;
-	    qA[l]=0.;
-	  }
-	}
-	
-	if(p->vi->normal_point_p){
-	  for(k=0;k<partition && acc>=p->vi->normal_thresh;k++){
-	    int l=mag_sort[i][j+k];
-	    if(l<sliding_lowpass && l>=pointlimit && rint(qM[l])==0.f){
-	      qM[l]=unitnorm(qM[l]);
-	      acc-=1.f;
-	    }
-	  } 
-	}
+              if(rint(qM[l])==0.f)acc+=qM[l]*qM[l];
+            }else{
+              couple_lossless(rM[l],rA[l],qM+l,qA+l);
+            }
+          }else{
+            qM[l]=0.;
+            qA[l]=0.;
+          }
+        }
+        
+        if(p->vi->normal_point_p){
+          for(k=0;k<partition && acc>=p->vi->normal_thresh;k++){
+            int l=mag_sort[i][j+k];
+            if(l<sliding_lowpass && l>=pointlimit && rint(qM[l])==0.f){
+              qM[l]=unitnorm(qM[l]);
+              acc-=1.f;
+            }
+          } 
+        }
       }
     }
   }
 }
 
 /* AoTuV */
 /** @ M2 **
    The boost problem by the combination of noise normalization and point stereo is eased. 
@@ -1212,16 +1216,15 @@ void _vp_couple(int blobno,
 
 void hf_reduction(vorbis_info_psy_global *g,
                       vorbis_look_psy *p, 
                       vorbis_info_mapping0 *vi,
                       float **mdct){
  
   int i,j,n=p->n, de=0.3*p->m_val;
   int limit=g->coupling_pointlimit[p->vi->blockflag][PACKETBLOBS/2];
-  int start=p->vi->normal_start;
   
   for(i=0; i<vi->coupling_steps; i++){
     /* for(j=start; j<limit; j++){} // ???*/
     for(j=limit; j<n; j++) 
       mdct[i][j] *= (1.0 - de*((float)(j-limit) / (float)(n-limit)));
   }
 }
--- a/media/libvorbis/lib/vorbis_registry.c
+++ b/media/libvorbis/lib/vorbis_registry.c
@@ -6,41 +6,41 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: registry for time, floor, res backends and channel mappings
- last mod: $Id: registry.c 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #include "vorbis/codec.h"
 #include "codec_internal.h"
 #include "registry.h"
 #include "misc.h"
 /* seems like major overkill now; the backend numbers will grow into
    the infrastructure soon enough */
 
-extern vorbis_func_floor     floor0_exportbundle;
-extern vorbis_func_floor     floor1_exportbundle;
-extern vorbis_func_residue   residue0_exportbundle;
-extern vorbis_func_residue   residue1_exportbundle;
-extern vorbis_func_residue   residue2_exportbundle;
-extern vorbis_func_mapping   mapping0_exportbundle;
+extern const vorbis_func_floor     floor0_exportbundle;
+extern const vorbis_func_floor     floor1_exportbundle;
+extern const vorbis_func_residue   residue0_exportbundle;
+extern const vorbis_func_residue   residue1_exportbundle;
+extern const vorbis_func_residue   residue2_exportbundle;
+extern const vorbis_func_mapping   mapping0_exportbundle;
 
-vorbis_func_floor     *_floor_P[]={
+const vorbis_func_floor     *const _floor_P[]={
   &floor0_exportbundle,
   &floor1_exportbundle,
 };
 
-vorbis_func_residue   *_residue_P[]={
+const vorbis_func_residue   *const _residue_P[]={
   &residue0_exportbundle,
   &residue1_exportbundle,
   &residue2_exportbundle,
 };
 
-vorbis_func_mapping   *_mapping_P[]={
+const vorbis_func_mapping   *const _mapping_P[]={
   &mapping0_exportbundle,
 };
 
--- a/media/libvorbis/lib/vorbis_res0.c
+++ b/media/libvorbis/lib/vorbis_res0.c
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: residue backend 0, 1 and 2 implementation
- last mod: $Id: res0.c 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 /* Slow, slow, slow, simpleminded and did I mention it was slow?  The
    encode/decode loops are coded for clarity and performance is not
    yet even a nagging little idea lurking in the shadows.  Oh and BTW,
    it's slow. */
 
@@ -75,69 +75,69 @@ void res0_free_look(vorbis_look_residue 
   if(i){
 
     vorbis_look_residue0 *look=(vorbis_look_residue0 *)i;
 
 #ifdef TRAIN_RES
     {
       int j,k,l;
       for(j=0;j<look->parts;j++){
-	/*fprintf(stderr,"partition %d: ",j);*/
-	for(k=0;k<8;k++)
-	  if(look->training_data[k][j]){
-	    char buffer[80];
-	    FILE *of;
-	    codebook *statebook=look->partbooks[j][k];
-	    
-	    /* long and short into the same bucket by current convention */
-	    sprintf(buffer,"res_part%d_pass%d.vqd",j,k);
-	    of=fopen(buffer,"a");
+        /*fprintf(stderr,"partition %d: ",j);*/
+        for(k=0;k<8;k++)
+          if(look->training_data[k][j]){
+            char buffer[80];
+            FILE *of;
+            codebook *statebook=look->partbooks[j][k];
+            
+            /* long and short into the same bucket by current convention */
+            sprintf(buffer,"res_part%d_pass%d.vqd",j,k);
+            of=fopen(buffer,"a");
 
-	    for(l=0;l<statebook->entries;l++)
-	      fprintf(of,"%d:%ld\n",l,look->training_data[k][j][l]);
-	    
-	    fclose(of);
-	    
-	    /*fprintf(stderr,"%d(%.2f|%.2f) ",k,
-	      look->training_min[k][j],look->training_max[k][j]);*/
+            for(l=0;l<statebook->entries;l++)
+              fprintf(of,"%d:%ld\n",l,look->training_data[k][j][l]);
+            
+            fclose(of);
+            
+            /*fprintf(stderr,"%d(%.2f|%.2f) ",k,
+              look->training_min[k][j],look->training_max[k][j]);*/
 
-	    _ogg_free(look->training_data[k][j]);
-	    look->training_data[k][j]=NULL;
-	  }
-	/*fprintf(stderr,"\n");*/
+            _ogg_free(look->training_data[k][j]);
+            look->training_data[k][j]=NULL;
+          }
+        /*fprintf(stderr,"\n");*/
       }
     }
     fprintf(stderr,"min/max residue: %g::%g\n",look->tmin,look->tmax);
 
     /*fprintf(stderr,"residue bit usage %f:%f (%f total)\n",
-	    (float)look->phrasebits/look->frames,
-	    (float)look->postbits/look->frames,
-	    (float)(look->postbits+look->phrasebits)/look->frames);*/
+            (float)look->phrasebits/look->frames,
+            (float)look->postbits/look->frames,
+            (float)(look->postbits+look->phrasebits)/look->frames);*/
 #endif
 
 
     /*vorbis_info_residue0 *info=look->info;
 
     fprintf(stderr,
-	    "%ld frames encoded in %ld phrasebits and %ld residue bits "
-	    "(%g/frame) \n",look->frames,look->phrasebits,
-	    look->resbitsflat,
-	    (look->phrasebits+look->resbitsflat)/(float)look->frames);
+            "%ld frames encoded in %ld phrasebits and %ld residue bits "
+            "(%g/frame) \n",look->frames,look->phrasebits,
+            look->resbitsflat,
+            (look->phrasebits+look->resbitsflat)/(float)look->frames);
     
     for(j=0;j<look->parts;j++){
       long acc=0;
       fprintf(stderr,"\t[%d] == ",j);
       for(k=0;k<look->stages;k++)
-	if((info->secondstages[j]>>k)&1){
-	  fprintf(stderr,"%ld,",look->resbits[j][k]);
-	  acc+=look->resbits[j][k];
-	}
+        if((info->secondstages[j]>>k)&1){
+          fprintf(stderr,"%ld,",look->resbits[j][k]);
+          acc+=look->resbits[j][k];
+        }
 
       fprintf(stderr,":: (%ld vals) %1.2fbits/sample\n",look->resvals[j],
-	      acc?(float)acc/(look->resvals[j]*info->grouping):0);
+              acc?(float)acc/(look->resvals[j]*info->grouping):0);
     }
     fprintf(stderr,"\n");*/
 
     for(j=0;j<look->parts;j++)
       if(look->partbooks[j])_ogg_free(look->partbooks[j]);
     _ogg_free(look->partbooks);
     for(j=0;j<look->partvals;j++)
       _ogg_free(look->decodemap[j]);
@@ -169,17 +169,17 @@ static int icount(unsigned int v){
 
 void res0_pack(vorbis_info_residue *vr,oggpack_buffer *opb){
   vorbis_info_residue0 *info=(vorbis_info_residue0 *)vr;
   int j,acc=0;
   oggpack_write(opb,info->begin,24);
   oggpack_write(opb,info->end,24);
 
   oggpack_write(opb,info->grouping-1,24);  /* residue vectors to group and 
-					     code with a partitioned book */
+                                             code with a partitioned book */
   oggpack_write(opb,info->partitions-1,6); /* possible partition choices */
   oggpack_write(opb,info->groupbook,8);  /* group huffman book */
 
   /* secondstages is a bitmask; as encoding progresses pass by pass, a
      bitmask of one indicates this partition class has bits to write
      this pass */
   for(j=0;j<info->partitions;j++){
     if(ilog(info->secondstages[j])>3){
@@ -215,27 +215,42 @@ vorbis_info_residue *res0_unpack(vorbis_
     info->secondstages[j]=cascade;
 
     acc+=icount(cascade);
   }
   for(j=0;j<acc;j++)
     info->booklist[j]=oggpack_read(opb,8);
 
   if(info->groupbook>=ci->books)goto errout;
-  for(j=0;j<acc;j++)
+  for(j=0;j<acc;j++){
     if(info->booklist[j]>=ci->books)goto errout;
+    if(ci->book_param[info->booklist[j]]->maptype==0)goto errout;
+  }
+
+  /* verify the phrasebook is not specifying an impossible or
+     inconsistent partitioning scheme. */
+  {
+    int entries = ci->book_param[info->groupbook]->entries;
+    int dim = ci->book_param[info->groupbook]->dim;
+    int partvals = 1;
+    while(dim>0){
+      partvals *= info->partitions;
+      if(partvals > entries) goto errout;
+      dim--;
+    }
+  }
 
   return(info);
  errout:
   res0_free_info(info);
   return(NULL);
 }
 
 vorbis_look_residue *res0_look(vorbis_dsp_state *vd,
-			       vorbis_info_residue *vr){
+                               vorbis_info_residue *vr){
   vorbis_info_residue0 *info=(vorbis_info_residue0 *)vr;
   vorbis_look_residue0 *look=_ogg_calloc(1,sizeof(*look));
   codec_setup_info     *ci=vd->vi->codec_setup;
 
   int j,k,acc=0;
   int dim;
   int maxstage=0;
   look->info=info;
@@ -248,27 +263,30 @@ vorbis_look_residue *res0_look(vorbis_ds
   look->partbooks=_ogg_calloc(look->parts,sizeof(*look->partbooks));
 
   for(j=0;j<look->parts;j++){
     int stages=ilog(info->secondstages[j]);
     if(stages){
       if(stages>maxstage)maxstage=stages;
       look->partbooks[j]=_ogg_calloc(stages,sizeof(*look->partbooks[j]));
       for(k=0;k<stages;k++)
-	if(info->secondstages[j]&(1<<k)){
-	  look->partbooks[j][k]=ci->fullbooks+info->booklist[acc++];
+        if(info->secondstages[j]&(1<<k)){
+          look->partbooks[j][k]=ci->fullbooks+info->booklist[acc++];
 #ifdef TRAIN_RES
-	  look->training_data[k][j]=_ogg_calloc(look->partbooks[j][k]->entries,
-					   sizeof(***look->training_data));
+          look->training_data[k][j]=_ogg_calloc(look->partbooks[j][k]->entries,
+                                           sizeof(***look->training_data));
 #endif
-	}
+        }
     }
   }
 
-  look->partvals=rint(pow((float)look->parts,(float)dim));
+  look->partvals=1;
+  for(j=0;j<dim;j++)
+      look->partvals*=look->parts;
+
   look->stages=maxstage;
   look->decodemap=_ogg_malloc(look->partvals*sizeof(*look->decodemap));
   for(j=0;j<look->partvals;j++){
     long val=j;
     long mult=look->partvals/look->parts;
     look->decodemap[j]=_ogg_malloc(dim*sizeof(*look->decodemap[j]));
     for(k=0;k<dim;k++){
       long deco=val/mult;
@@ -294,64 +312,64 @@ static int local_book_besterror(codebook
 
   /* find the quant val of each scalar */
   for(k=0,o=dim;k<dim;++k){
     float val=a[--o];
     i=tt->threshvals>>1;
 
     if(val<tt->quantthresh[i]){      
       if(val<tt->quantthresh[i-1]){
-	for(--i;i>0;--i)
-	  if(val>=tt->quantthresh[i-1])
-	    break;
+        for(--i;i>0;--i)
+          if(val>=tt->quantthresh[i-1])
+            break;
       }
     }else{
       
       for(++i;i<tt->threshvals-1;++i)
-	if(val<tt->quantthresh[i])break;
+        if(val<tt->quantthresh[i])break;
       
     }
 
     best=(best*tt->quantvals)+tt->quantmap[i];
   }
   /* regular lattices are easy :-) */
   
   if(book->c->lengthlist[best]<=0){
     const static_codebook *c=book->c;
     int i,j;
     float bestf=0.f;
     float *e=book->valuelist;
     best=-1;
     for(i=0;i<book->entries;i++){
       if(c->lengthlist[i]>0){
-	float this=0.f;
-	for(j=0;j<dim;j++){
-	  float val=(e[j]-a[j]);
-	  this+=val*val;
-	}
-	if(best==-1 || this<bestf){
-	  bestf=this;
-	  best=i;
-	}
+        float this=0.f;
+        for(j=0;j<dim;j++){
+          float val=(e[j]-a[j]);
+          this+=val*val;
+        }
+        if(best==-1 || this<bestf){
+          bestf=this;
+          best=i;
+        }
       }
       e+=dim;
     }
   }
 
   if(best>-1){
     float *ptr=book->valuelist+best*dim;
     for(i=0;i<dim;i++)
       *a++ -= *ptr++;
   }
 
   return(best);
 }
 
 static int _encodepart(oggpack_buffer *opb,float *vec, int n,
-		       codebook *book,long *acc){
+                       codebook *book,long *acc){
   int i,bits=0;
   int dim=book->dim;
   int step=n/dim;
 
   for(i=0;i<step;i++){
     int entry=local_book_besterror(book,vec+i*dim);
 
 #ifdef TRAIN_RES
@@ -362,22 +380,20 @@ static int _encodepart(oggpack_buffer *o
     bits+=vorbis_book_encode(book,entry,opb);
   
   }
 
   return(bits);
 }
 
 static long **_01class(vorbis_block *vb,vorbis_look_residue *vl,
-		       float **in,int ch){
+                       float **in,int ch){
   long i,j,k;
   vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
   vorbis_info_residue0 *info=look->info;
-  vorbis_info           *vi=vb->vd->vi;
-  codec_setup_info      *ci=vi->codec_setup;
 
   /* move all this setup out later */
   int samples_per_partition=info->grouping;
   int possible_partitions=info->partitions;
   int n=info->end-info->begin;
   
   int partvals=n/samples_per_partition;
   long **partword=_vorbis_block_alloc(vb,ch*sizeof(*partword));
@@ -393,55 +409,55 @@ static long **_01class(vorbis_block *vb,
   }
   
   for(i=0;i<partvals;i++){
     int offset=i*samples_per_partition+info->begin;
     for(j=0;j<ch;j++){
       float max=0.;
       float ent=0.;
       for(k=0;k<samples_per_partition;k++){
-	if(fabs(in[j][offset+k])>max)max=fabs(in[j][offset+k]);
-	ent+=fabs(rint(in[j][offset+k]));
+        if(fabs(in[j][offset+k])>max)max=fabs(in[j][offset+k]);
+        ent+=fabs(rint(in[j][offset+k]));
       }
       ent*=scale;
       
       for(k=0;k<possible_partitions-1;k++)
-	if(max<=info->classmetric1[k] &&
-	   (info->classmetric2[k]<0 || (int)ent<info->classmetric2[k]))
-	  break;
+        if(max<=info->classmetric1[k] &&
+           (info->classmetric2[k]<0 || (int)ent<info->classmetric2[k]))
+          break;
       
       partword[j][i]=k;  
     }
   }
   
 #ifdef TRAIN_RESAUX
   {
     FILE *of;
     char buffer[80];
     
     for(i=0;i<ch;i++){
       sprintf(buffer,"resaux_%d.vqd",look->train_seq);
       of=fopen(buffer,"a");
       for(j=0;j<partvals;j++)
-	fprintf(of,"%ld, ",partword[i][j]);
+        fprintf(of,"%ld, ",partword[i][j]);
       fprintf(of,"\n");
       fclose(of);
     }
   }
 #endif
   look->frames++;
   
   return(partword);
 }
 
 /* designed for stereo or other modes where the partition size is an
    integer multiple of the number of channels encoded in the current
    submap */
 static long **_2class(vorbis_block *vb,vorbis_look_residue *vl,float **in,
-		      int ch){
+                      int ch){
   long i,j,k,l;
   vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
   vorbis_info_residue0 *info=look->info;
 
   /* move all this setup out later */
   int samples_per_partition=info->grouping;
   int possible_partitions=info->partitions;
   int n=info->end-info->begin;
@@ -458,24 +474,24 @@ static long **_2class(vorbis_block *vb,v
   memset(partword[0],0,n*ch/samples_per_partition*sizeof(*partword[0]));
   
   for(i=0,l=info->begin/ch;i<partvals;i++){
     float magmax=0.f;
     float angmax=0.f;
     for(j=0;j<samples_per_partition;j+=ch){
       if(fabs(in[0][l])>magmax)magmax=fabs(in[0][l]);
       for(k=1;k<ch;k++)
-	if(fabs(in[k][l])>angmax)angmax=fabs(in[k][l]);
-	l++;
+        if(fabs(in[k][l])>angmax)angmax=fabs(in[k][l]);
+        l++;
     }
     
     for(j=0;j<possible_partitions-1;j++)
       if(magmax<=info->classmetric1[j] &&
-	 angmax<=info->classmetric2[j])
-	break;
+         angmax<=info->classmetric2[j])
+        break;
     
     partword[0][i]=j;
     
   }  
   
 #ifdef TRAIN_RESAUX
   sprintf(buffer,"resaux_%d.vqd",look->train_seq);
   of=fopen(buffer,"a");
@@ -486,27 +502,25 @@ static long **_2class(vorbis_block *vb,v
 #endif
   
   look->frames++;
   
   return(partword);
 }
 
 static int _01forward(oggpack_buffer *opb,
-		      vorbis_block *vb,vorbis_look_residue *vl,
-		      float **in,int ch,
-		      long **partword,
-		      int (*encode)(oggpack_buffer *,float *,int,
-				    codebook *,long *)){
+                      vorbis_block *vb,vorbis_look_residue *vl,
+                      float **in,int ch,
+                      long **partword,
+                      int (*encode)(oggpack_buffer *,float *,int,
+                                    codebook *,long *)){
   long i,j,k,s;
   vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
   vorbis_info_residue0 *info=look->info;
 
-  vorbis_dsp_state      *vd=vb->vd;
-
   /* move all this setup out later */
   int samples_per_partition=info->grouping;
   int possible_partitions=info->partitions;
   int partitions_per_word=look->phrasebook->dim;
   int n=info->end-info->begin;
 
   int partvals=n/samples_per_partition;
   long resbits[128];
@@ -529,69 +543,69 @@ static int _01forward(oggpack_buffer *op
      partition channel words... */
   
   for(s=0;s<look->stages;s++){
     
     for(i=0;i<partvals;){
       
       /* first we encode a partition codeword for each channel */
       if(s==0){
-	for(j=0;j<ch;j++){
-	  long val=partword[j][i];
-	  for(k=1;k<partitions_per_word;k++){
-	    val*=possible_partitions;
-	    if(i+k<partvals)
-	      val+=partword[j][i+k];
-	  }	
-	  
-	  /* training hack */
-	  if(val<look->phrasebook->entries)
-	    look->phrasebits+=vorbis_book_encode(look->phrasebook,val,opb);
+        for(j=0;j<ch;j++){
+          long val=partword[j][i];
+          for(k=1;k<partitions_per_word;k++){
+            val*=possible_partitions;
+            if(i+k<partvals)
+              val+=partword[j][i+k];
+          }        
+          
+          /* training hack */
+          if(val<look->phrasebook->entries)
+            look->phrasebits+=vorbis_book_encode(look->phrasebook,val,opb);
 #if 0 /*def TRAIN_RES*/
-	  else
-	    fprintf(stderr,"!");
+          else
+            fprintf(stderr,"!");
 #endif
-	  
-	}
+          
+        }
       }
       
       /* now we encode interleaved residual values for the partitions */
       for(k=0;k<partitions_per_word && i<partvals;k++,i++){
-	long offset=i*samples_per_partition+info->begin;
-	  
-	for(j=0;j<ch;j++){
-	  if(s==0)resvals[partword[j][i]]+=samples_per_partition;
-	  if(info->secondstages[partword[j][i]]&(1<<s)){
-	    codebook *statebook=look->partbooks[partword[j][i]][s];
-	    if(statebook){
-	      int ret;
-	      long *accumulator=NULL;
-	      
+        long offset=i*samples_per_partition+info->begin;
+          
+        for(j=0;j<ch;j++){
+          if(s==0)resvals[partword[j][i]]+=samples_per_partition;
+          if(info->secondstages[partword[j][i]]&(1<<s)){
+            codebook *statebook=look->partbooks[partword[j][i]][s];
+            if(statebook){
+              int ret;
+              long *accumulator=NULL;
+              
 #ifdef TRAIN_RES
-	      accumulator=look->training_data[s][partword[j][i]];
-	      {
-		int l;
-		float *samples=in[j]+offset;
-		for(l=0;l<samples_per_partition;l++){
-		  if(samples[l]<look->training_min[s][partword[j][i]])
-		    look->training_min[s][partword[j][i]]=samples[l];
-		  if(samples[l]>look->training_max[s][partword[j][i]])
-		    look->training_max[s][partword[j][i]]=samples[l];
-		}
-	      }
+              accumulator=look->training_data[s][partword[j][i]];
+              {
+                int l;
+                float *samples=in[j]+offset;
+                for(l=0;l<samples_per_partition;l++){
+                  if(samples[l]<look->training_min[s][partword[j][i]])
+                    look->training_min[s][partword[j][i]]=samples[l];
+                  if(samples[l]>look->training_max[s][partword[j][i]])
+                    look->training_max[s][partword[j][i]]=samples[l];
+                }
+              }
 #endif
-	      
-	      ret=encode(opb,in[j]+offset,samples_per_partition,
-			 statebook,accumulator);
-	      
-	      look->postbits+=ret;
-	      resbits[partword[j][i]]+=ret;
-	    }
-	  }
-	}
+              
+              ret=encode(opb,in[j]+offset,samples_per_partition,
+                         statebook,accumulator);
+              
+              look->postbits+=ret;
+              resbits[partword[j][i]]+=ret;
+            }
+          }
+        }
       }
     }
   }
   
   /*{
     long total=0;
     long totalbits=0;
     fprintf(stderr,"%d :: ",vb->mode);
@@ -604,19 +618,19 @@ static int _01forward(oggpack_buffer *op
     fprintf(stderr,":: %ld:%1.2g\n",total,(double)totalbits/total);
     }*/
 
   return(0);
 }
 
 /* a truncated packet here just means 'stop working'; it's not an error */
 static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl,
-		      float **in,int ch,
-		      long (*decodepart)(codebook *, float *, 
-					 oggpack_buffer *,int)){
+                      float **in,int ch,
+                      long (*decodepart)(codebook *, float *, 
+                                         oggpack_buffer *,int)){
 
   long i,j,k,l,s;
   vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
   vorbis_info_residue0 *info=look->info;
 
   /* move all this setup out later */
   int samples_per_partition=info->grouping;
   int partitions_per_word=look->phrasebook->dim;
@@ -630,180 +644,180 @@ static int _01inverse(vorbis_block *vb,v
     int ***partword=alloca(ch*sizeof(*partword));
     
     for(j=0;j<ch;j++)
       partword[j]=_vorbis_block_alloc(vb,partwords*sizeof(*partword[j]));
     
     for(s=0;s<look->stages;s++){
       
       /* each loop decodes on partition codeword containing 
-	 partitions_per_word partitions */
+         partitions_per_word partitions */
       for(i=0,l=0;i<partvals;l++){
-	if(s==0){
-	  /* fetch the partition word for each channel */
-	  for(j=0;j<ch;j++){
-	    int temp=vorbis_book_decode(look->phrasebook,&vb->opb);
-	    
-	    if(temp==-1)goto eopbreak;
-	    partword[j][l]=look->decodemap[temp];
-	    if(partword[j][l]==NULL)goto errout;
-	  }
-	}
-	
-	/* now we decode residual values for the partitions */
-	for(k=0;k<partitions_per_word && i<partvals;k++,i++)
-	  for(j=0;j<ch;j++){
-	    long offset=info->begin+i*samples_per_partition;
-	    if(info->secondstages[partword[j][l][k]]&(1<<s)){
-	      codebook *stagebook=look->partbooks[partword[j][l][k]][s];
-	      if(stagebook){
-		if(decodepart(stagebook,in[j]+offset,&vb->opb,
-			      samples_per_partition)==-1)goto eopbreak;
-	      }
-	    }
-	  }
+        if(s==0){
+          /* fetch the partition word for each channel */
+          for(j=0;j<ch;j++){
+            int temp=vorbis_book_decode(look->phrasebook,&vb->opb);
+            
+            if(temp==-1)goto eopbreak;
+            partword[j][l]=look->decodemap[temp];
+            if(partword[j][l]==NULL)goto errout;
+          }
+        }
+        
+        /* now we decode residual values for the partitions */
+        for(k=0;k<partitions_per_word && i<partvals;k++,i++)
+          for(j=0;j<ch;j++){
+            long offset=info->begin+i*samples_per_partition;
+            if(info->secondstages[partword[j][l][k]]&(1<<s)){
+              codebook *stagebook=look->partbooks[partword[j][l][k]][s];
+              if(stagebook){
+                if(decodepart(stagebook,in[j]+offset,&vb->opb,
+                              samples_per_partition)==-1)goto eopbreak;
+              }
+            }
+          }
       } 
     }
   }
  errout:
  eopbreak:
   return(0);
 }
 
 #if 0
 /* residue 0 and 1 are just slight variants of one another. 0 is
    interleaved, 1 is not */
 long **res0_class(vorbis_block *vb,vorbis_look_residue *vl,
-		  float **in,int *nonzero,int ch){
+                  float **in,int *nonzero,int ch){
   /* we encode only the nonzero parts of a bundle */
   int i,used=0;
   for(i=0;i<ch;i++)
     if(nonzero[i])
       in[used++]=in[i];
   if(used)
     /*return(_01class(vb,vl,in,used,_interleaved_testhack));*/
     return(_01class(vb,vl,in,used));
   else
     return(0);
 }
 
 int res0_forward(vorbis_block *vb,vorbis_look_residue *vl,
-		 float **in,float **out,int *nonzero,int ch,
-		 long **partword){
+                 float **in,float **out,int *nonzero,int ch,
+                 long **partword){
   /* we encode only the nonzero parts of a bundle */
   int i,j,used=0,n=vb->pcmend/2;
   for(i=0;i<ch;i++)
     if(nonzero[i]){
       if(out)
-	for(j=0;j<n;j++)
-	  out[i][j]+=in[i][j];
+        for(j=0;j<n;j++)
+          out[i][j]+=in[i][j];
       in[used++]=in[i];
     }
   if(used){
     int ret=_01forward(vb,vl,in,used,partword,
-		      _interleaved_encodepart);
+                      _interleaved_encodepart);
     if(out){
       used=0;
       for(i=0;i<ch;i++)
-	if(nonzero[i]){
-	  for(j=0;j<n;j++)
-	    out[i][j]-=in[used][j];
-	  used++;
-	}
+        if(nonzero[i]){
+          for(j=0;j<n;j++)
+            out[i][j]-=in[used][j];
+          used++;
+        }
     }
     return(ret);
   }else{
     return(0);
   }
 }
 #endif
 
 int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl,
-		 float **in,int *nonzero,int ch){
+                 float **in,int *nonzero,int ch){
   int i,used=0;
   for(i=0;i<ch;i++)
     if(nonzero[i])
       in[used++]=in[i];
   if(used)
     return(_01inverse(vb,vl,in,used,vorbis_book_decodevs_add));
   else
     return(0);
 }
 
 int res1_forward(oggpack_buffer *opb,vorbis_block *vb,vorbis_look_residue *vl,
-		 float **in,float **out,int *nonzero,int ch,
-		 long **partword){
+                 float **in,float **out,int *nonzero,int ch,
+                 long **partword){
   int i,j,used=0,n=vb->pcmend/2;
   for(i=0;i<ch;i++)
     if(nonzero[i]){
       if(out)
-	for(j=0;j<n;j++)
-	  out[i][j]+=in[i][j];
+        for(j=0;j<n;j++)
+          out[i][j]+=in[i][j];
       in[used++]=in[i];
     }
 
   if(used){
     int ret=_01forward(opb,vb,vl,in,used,partword,_encodepart);
     if(out){
       used=0;
       for(i=0;i<ch;i++)
-	if(nonzero[i]){
-	  for(j=0;j<n;j++)
-	    out[i][j]-=in[used][j];
-	  used++;
-	}
+        if(nonzero[i]){
+          for(j=0;j<n;j++)
+            out[i][j]-=in[used][j];
+          used++;
+        }
     }
     return(ret);
   }else{
     return(0);
   }
 }
 
 long **res1_class(vorbis_block *vb,vorbis_look_residue *vl,
-		  float **in,int *nonzero,int ch){
+                  float **in,int *nonzero,int ch){
   int i,used=0;
   for(i=0;i<ch;i++)
     if(nonzero[i])
       in[used++]=in[i];
   if(used)
     return(_01class(vb,vl,in,used));
   else
     return(0);
 }
 
 int res1_inverse(vorbis_block *vb,vorbis_look_residue *vl,
-		 float **in,int *nonzero,int ch){
+                 float **in,int *nonzero,int ch){
   int i,used=0;
   for(i=0;i<ch;i++)
     if(nonzero[i])
       in[used++]=in[i];
   if(used)
     return(_01inverse(vb,vl,in,used,vorbis_book_decodev_add));
   else
     return(0);
 }
 
 long **res2_class(vorbis_block *vb,vorbis_look_residue *vl,
-		  float **in,int *nonzero,int ch){
+                  float **in,int *nonzero,int ch){
   int i,used=0;
   for(i=0;i<ch;i++)
     if(nonzero[i])used++;
   if(used)
     return(_2class(vb,vl,in,ch));
   else
     return(0);
 }
 
 /* res2 is slightly more different; all the channels are interleaved
    into a single vector and encoded. */
 
 int res2_forward(oggpack_buffer *opb,
-		 vorbis_block *vb,vorbis_look_residue *vl,
-		 float **in,float **out,int *nonzero,int ch,
-		 long **partword){
+                 vorbis_block *vb,vorbis_look_residue *vl,
+                 float **in,float **out,int *nonzero,int ch,
+                 long **partword){
   long i,j,k,n=vb->pcmend/2,used=0;
 
   /* don't duplicate the code; use a working vector hack for now and
      reshape ourselves into a single channel res1 */
   /* ugly; reallocs for each coupling pass :-( */
   float *work=_vorbis_block_alloc(vb,ch*n*sizeof(*work));
   for(i=0;i<ch;i++){
     float *pcm=in[i];
@@ -812,32 +826,32 @@ int res2_forward(oggpack_buffer *opb,
       work[k]=pcm[j];
   }
   
   if(used){
     int ret=_01forward(opb,vb,vl,&work,1,partword,_encodepart);
     /* update the sofar vector */
     if(out){
       for(i=0;i<ch;i++){
-	float *pcm=in[i];
-	float *sofar=out[i];
-	for(j=0,k=i;j<n;j++,k+=ch)
-	  sofar[j]+=pcm[j]-work[k];
-	
+        float *pcm=in[i];
+        float *sofar=out[i];
+        for(j=0,k=i;j<n;j++,k+=ch)
+          sofar[j]+=pcm[j]-work[k];
+        
       }
     }
     return(ret);
   }else{
     return(0);
   }
 }
 
 /* duplicate code here as speed is somewhat more important */
 int res2_inverse(vorbis_block *vb,vorbis_look_residue *vl,
-		 float **in,int *nonzero,int ch){
+                 float **in,int *nonzero,int ch){
   long i,k,l,s;
   vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
   vorbis_info_residue0 *info=look->info;
 
   /* move all this setup out later */
   int samples_per_partition=info->grouping;
   int partitions_per_word=look->phrasebook->dim;
   int max=(vb->pcmend*ch)>>1;
@@ -849,69 +863,69 @@ int res2_inverse(vorbis_block *vb,vorbis
     int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
     int **partword=_vorbis_block_alloc(vb,partwords*sizeof(*partword));
     
     for(i=0;i<ch;i++)if(nonzero[i])break;
     if(i==ch)return(0); /* no nonzero vectors */
     
     for(s=0;s<look->stages;s++){
       for(i=0,l=0;i<partvals;l++){
-	
-	if(s==0){
-	  /* fetch the partition word */
-	  int temp=vorbis_book_decode(look->phrasebook,&vb->opb);
-	  if(temp==-1)goto eopbreak;
-	  partword[l]=look->decodemap[temp];
-	  if(partword[l]==NULL)goto errout;
-	}
-	
-	/* now we decode residual values for the partitions */
-	for(k=0;k<partitions_per_word && i<partvals;k++,i++)
-	  if(info->secondstages[partword[l][k]]&(1<<s)){
-	    codebook *stagebook=look->partbooks[partword[l][k]][s];
-	    
-	    if(stagebook){
-	      if(vorbis_book_decodevv_add(stagebook,in,
-					  i*samples_per_partition+info->begin,ch,
-					  &vb->opb,samples_per_partition)==-1)
-		goto eopbreak;
-	    }
-	  }
+        
+        if(s==0){
+          /* fetch the partition word */
+          int temp=vorbis_book_decode(look->phrasebook,&vb->opb);
+          if(temp==-1)goto eopbreak;
+          partword[l]=look->decodemap[temp];
+          if(partword[l]==NULL)goto errout;
+        }
+        
+        /* now we decode residual values for the partitions */
+        for(k=0;k<partitions_per_word && i<partvals;k++,i++)
+          if(info->secondstages[partword[l][k]]&(1<<s)){
+            codebook *stagebook=look->partbooks[partword[l][k]][s];
+            
+            if(stagebook){
+              if(vorbis_book_decodevv_add(stagebook,in,
+                                          i*samples_per_partition+info->begin,ch,
+                                          &vb->opb,samples_per_partition)==-1)
+                goto eopbreak;
+            }
+          }
       } 
     }
   }
  errout:
  eopbreak:
   return(0);
 }
 
 
-vorbis_func_residue residue0_exportbundle={
+const vorbis_func_residue residue0_exportbundle={
   NULL,
   &res0_unpack,
   &res0_look,
   &res0_free_info,
   &res0_free_look,
   NULL,
   NULL,
   &res0_inverse
 };
 
-vorbis_func_residue residue1_exportbundle={
+const vorbis_func_residue residue1_exportbundle={
   &res0_pack,
   &res0_unpack,
   &res0_look,
   &res0_free_info,
   &res0_free_look,
   &res1_class,
   &res1_forward,
   &res1_inverse
 };
 
-vorbis_func_residue residue2_exportbundle={
+const vorbis_func_residue residue2_exportbundle={
   &res0_pack,
   &res0_unpack,
   &res0_look,
   &res0_free_info,
   &res0_free_look,
   &res2_class,
   &res2_forward,
   &res2_inverse
--- a/media/libvorbis/lib/vorbis_sharedbook.c
+++ b/media/libvorbis/lib/vorbis_sharedbook.c
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: basic shared codebook operations
- last mod: $Id: sharedbook.c 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #include <stdlib.h>
 #include <math.h>
 #include <string.h>
 #include <ogg/ogg.h>
 #include "os.h"
@@ -77,71 +77,84 @@ ogg_uint32_t *_make_words(long *l,long n
   memset(marker,0,sizeof(marker));
 
   for(i=0;i<n;i++){
     long length=l[i];
     if(length>0){
       ogg_uint32_t entry=marker[length];
       
       /* when we claim a node for an entry, we also claim the nodes
-	 below it (pruning off the imagined tree that may have dangled
-	 from it) as well as blocking the use of any nodes directly
-	 above for leaves */
+         below it (pruning off the imagined tree that may have dangled
+         from it) as well as blocking the use of any nodes directly
+         above for leaves */
       
       /* update ourself */
       if(length<32 && (entry>>length)){
-	/* error condition; the lengths must specify an overpopulated tree */
-	_ogg_free(r);
-	return(NULL);
+        /* error condition; the lengths must specify an overpopulated tree */
+        _ogg_free(r);
+        return(NULL);
       }
       r[count++]=entry;
     
       /* Look to see if the next shorter marker points to the node
-	 above. if so, update it and repeat.  */
+         above. if so, update it and repeat.  */
       {
-	for(j=length;j>0;j--){
-	  
-	  if(marker[j]&1){
-	    /* have to jump branches */
-	    if(j==1)
-	      marker[1]++;
-	    else
-	      marker[j]=marker[j-1]<<1;
-	    break; /* invariant says next upper marker would already
-		      have been moved if it was on the same path */
-	  }
-	  marker[j]++;
-	}
+        for(j=length;j>0;j--){
+          
+          if(marker[j]&1){
+            /* have to jump branches */
+            if(j==1)
+              marker[1]++;
+            else
+              marker[j]=marker[j-1]<<1;
+            break; /* invariant says next upper marker would already
+                      have been moved if it was on the same path */
+          }
+          marker[j]++;
+        }
       }
       
       /* prune the tree; the implicit invariant says all the longer
-	 markers were dangling from our just-taken node.  Dangle them
-	 from our *new* node. */
+         markers were dangling from our just-taken node.  Dangle them
+         from our *new* node. */
       for(j=length+1;j<33;j++)
-	if((marker[j]>>1) == entry){
-	  entry=marker[j];
-	  marker[j]=marker[j-1]<<1;
-	}else
-	  break;
+        if((marker[j]>>1) == entry){
+          entry=marker[j];
+          marker[j]=marker[j-1]<<1;
+        }else
+          break;
     }else
       if(sparsecount==0)count++;
   }
-    
+  
+  /* sanity check the huffman tree; an underpopulated tree must be
+     rejected. The only exception is the one-node pseudo-nil tree,
+     which appears to be underpopulated because the tree doesn't
+     really exist; there's only one possible 'codeword' or zero bits,
+     but the above tree-gen code doesn't mark that. */
+  if(sparsecount != 1){
+    for(i=1;i<33;i++)
+      if(marker[i] & (0xffffffffUL>>(32-i))){
+	_ogg_free(r);
+	return(NULL);
+      }
+  }
+
   /* bitreverse the words because our bitwise packer/unpacker is LSb
      endian */
   for(i=0,count=0;i<n;i++){
     ogg_uint32_t temp=0;
     for(j=0;j<l[i];j++){
       temp<<=1;
       temp|=(r[count]>>j)&1;
     }
 
     if(sparsecount){
       if(l[i])
-	r[count++]=temp;
+        r[count++]=temp;
     }else
       r[count++]=temp;
   }
 
   return(r);
 }
 
 /* there might be a straightforward one-line way to do the below
@@ -162,19 +175,19 @@ long _book_maptype1_quantvals(const stat
     for(i=0;i<b->dim;i++){
       acc*=vals;
       acc1*=vals+1;
     }
     if(acc<=b->entries && acc1>b->entries){
       return(vals);
     }else{
       if(acc>b->entries){
-	vals--;
+        vals--;
       }else{
-	vals++;
+        vals++;
       }
     }
   }
 }
 
 /* unpack the quantized list of values for encode/decode ***********/
 /* we need to deal with two map types: in map type 1, the values are
    generated algorithmically (each column of the vector counts through
@@ -188,59 +201,59 @@ float *_book_unquantize(const static_cod
     float delta=_float32_unpack(b->q_delta);
     float *r=_ogg_calloc(n*b->dim,sizeof(*r));
 
     /* maptype 1 and 2 both use a quantized value vector, but
        different sizes */
     switch(b->maptype){
     case 1:
       /* most of the time, entries%dimensions == 0, but we need to be
-	 well defined.  We define that the possible vales at each
-	 scalar is values == entries/dim.  If entries%dim != 0, we'll
-	 have 'too few' values (values*dim<entries), which means that
-	 we'll have 'left over' entries; left over entries use zeroed
-	 values (and are wasted).  So don't generate codebooks like
-	 that */
+         well defined.  We define that the possible vales at each
+         scalar is values == entries/dim.  If entries%dim != 0, we'll
+         have 'too few' values (values*dim<entries), which means that
+         we'll have 'left over' entries; left over entries use zeroed
+         values (and are wasted).  So don't generate codebooks like
+         that */
       quantvals=_book_maptype1_quantvals(b);
       for(j=0;j<b->entries;j++){
-	if((sparsemap && b->lengthlist[j]) || !sparsemap){
-	  float last=0.f;
-	  int indexdiv=1;
-	  for(k=0;k<b->dim;k++){
-	    int index= (j/indexdiv)%quantvals;
-	    float val=b->quantlist[index];
-	    val=fabs(val)*delta+mindel+last;
-	    if(b->q_sequencep)last=val;	  
-	    if(sparsemap)
-	      r[sparsemap[count]*b->dim+k]=val;
-	    else
-	      r[count*b->dim+k]=val;
-	    indexdiv*=quantvals;
-	  }
-	  count++;
-	}
+        if((sparsemap && b->lengthlist[j]) || !sparsemap){
+          float last=0.f;
+          int indexdiv=1;
+          for(k=0;k<b->dim;k++){
+            int index= (j/indexdiv)%quantvals;
+            float val=b->quantlist[index];
+            val=fabs(val)*delta+mindel+last;
+            if(b->q_sequencep)last=val;          
+            if(sparsemap)
+              r[sparsemap[count]*b->dim+k]=val;
+            else
+              r[count*b->dim+k]=val;
+            indexdiv*=quantvals;
+          }
+          count++;
+        }
 
       }
       break;
     case 2:
       for(j=0;j<b->entries;j++){
-	if((sparsemap && b->lengthlist[j]) || !sparsemap){
-	  float last=0.f;
-	  
-	  for(k=0;k<b->dim;k++){
-	    float val=b->quantlist[j*b->dim+k];
-	    val=fabs(val)*delta+mindel+last;
-	    if(b->q_sequencep)last=val;	  
-	    if(sparsemap)
-	      r[sparsemap[count]*b->dim+k]=val;
-	    else
-	      r[count*b->dim+k]=val;
-	  }
-	  count++;
-	}
+        if((sparsemap && b->lengthlist[j]) || !sparsemap){
+          float last=0.f;
+          
+          for(k=0;k<b->dim;k++){
+            float val=b->quantlist[j*b->dim+k];
+            val=fabs(val)*delta+mindel+last;
+            if(b->q_sequencep)last=val;          
+            if(sparsemap)
+              r[sparsemap[count]*b->dim+k]=val;
+            else
+              r[count*b->dim+k]=val;
+          }
+          count++;
+        }
       }
       break;
     }
 
     return(r);
   }
   return(NULL);
 }
@@ -367,66 +380,66 @@ int vorbis_book_init_decode(codebook *c,
     _ogg_free(codes);
   
 
     c->valuelist=_book_unquantize(s,n,sortindex);
     c->dec_index=_ogg_malloc(n*sizeof(*c->dec_index));
     
     for(n=0,i=0;i<s->entries;i++)
       if(s->lengthlist[i]>0)
-	c->dec_index[sortindex[n++]]=i;
+        c->dec_index[sortindex[n++]]=i;
     
     c->dec_codelengths=_ogg_malloc(n*sizeof(*c->dec_codelengths));
     for(n=0,i=0;i<s->entries;i++)
       if(s->lengthlist[i]>0)
-	c->dec_codelengths[sortindex[n++]]=s->lengthlist[i];
+        c->dec_codelengths[sortindex[n++]]=s->lengthlist[i];
     
     c->dec_firsttablen=_ilog(c->used_entries)-4; /* this is magic */
     if(c->dec_firsttablen<5)c->dec_firsttablen=5;
     if(c->dec_firsttablen>8)c->dec_firsttablen=8;
     
     tabn=1<<c->dec_firsttablen;
     c->dec_firsttable=_ogg_calloc(tabn,sizeof(*c->dec_firsttable));
     c->dec_maxlength=0;
     
     for(i=0;i<n;i++){
       if(c->dec_maxlength<c->dec_codelengths[i])
-	c->dec_maxlength=c->dec_codelengths[i];
+        c->dec_maxlength=c->dec_codelengths[i];
       if(c->dec_codelengths[i]<=c->dec_firsttablen){
-	ogg_uint32_t orig=bitreverse(c->codelist[i]);
-	for(j=0;j<(1<<(c->dec_firsttablen-c->dec_codelengths[i]));j++)
-	  c->dec_firsttable[orig|(j<<c->dec_codelengths[i])]=i+1;
+        ogg_uint32_t orig=bitreverse(c->codelist[i]);
+        for(j=0;j<(1<<(c->dec_firsttablen-c->dec_codelengths[i]));j++)
+          c->dec_firsttable[orig|(j<<c->dec_codelengths[i])]=i+1;
       }
     }
     
     /* now fill in 'unused' entries in the firsttable with hi/lo search
        hints for the non-direct-hits */
     {
       ogg_uint32_t mask=0xfffffffeUL<<(31-c->dec_firsttablen);
       long lo=0,hi=0;
       
       for(i=0;i<tabn;i++){
-	ogg_uint32_t word=i<<(32-c->dec_firsttablen);
-	if(c->dec_firsttable[bitreverse(word)]==0){
-	  while((lo+1)<n && c->codelist[lo+1]<=word)lo++;
-	  while(    hi<n && word>=(c->codelist[hi]&mask))hi++;
-	  
-	  /* we only actually have 15 bits per hint to play with here.
-	     In order to overflow gracefully (nothing breaks, efficiency
-	     just drops), encode as the difference from the extremes. */
-	  {
-	    unsigned long loval=lo;
-	    unsigned long hival=n-hi;
-	    
-	    if(loval>0x7fff)loval=0x7fff;
-	    if(hival>0x7fff)hival=0x7fff;
-	    c->dec_firsttable[bitreverse(word)]=
-	      0x80000000UL | (loval<<15) | hival;
-	  }
-	}
+        ogg_uint32_t word=i<<(32-c->dec_firsttablen);
+        if(c->dec_firsttable[bitreverse(word)]==0){
+          while((lo+1)<n && c->codelist[lo+1]<=word)lo++;
+          while(    hi<n && word>=(c->codelist[hi]&mask))hi++;
+          
+          /* we only actually have 15 bits per hint to play with here.
+             In order to overflow gracefully (nothing breaks, efficiency
+             just drops), encode as the difference from the extremes. */
+          {
+            unsigned long loval=lo;
+            unsigned long hival=n-hi;
+            
+            if(loval>0x7fff)loval=0x7fff;
+            if(hival>0x7fff)hival=0x7fff;
+            c->dec_firsttable[bitreverse(word)]=
+              0x80000000UL | (loval<<15) | hival;
+          }
+        }
       }
     }
   }
 
   return(0);
  err_out:
   vorbis_book_clear(c);
   return(-1);
@@ -458,33 +471,33 @@ int _best(codebook *book, float *a, int 
   if(tt){
     int index=0,i;
     /* find the quant val of each scalar */
     for(k=0,o=step*(dim-1);k<dim;k++,o-=step){
 
       i=tt->threshvals>>1;
       if(a[o]<tt->quantthresh[i]){
 
-	for(;i>0;i--)
-	  if(a[o]>=tt->quantthresh[i-1])
-	    break;
-	
+        for(;i>0;i--)
+          if(a[o]>=tt->quantthresh[i-1])
+            break;
+        
       }else{
 
-	for(i++;i<tt->threshvals-1;i++)
-	  if(a[o]<tt->quantthresh[i])break;
+        for(i++;i<tt->threshvals-1;i++)
+          if(a[o]<tt->quantthresh[i])break;
 
       }
 
       index=(index*tt->quantvals)+tt->quantmap[i];
     }
     /* regular lattices are easy :-) */
     if(book->c->lengthlist[index]>0) /* is this unused?  If so, we'll
-					use a decision tree after all
-					and fall through*/
+                                        use a decision tree after all
+                                        and fall through*/
       return(index);
   }
 
 #if 0
   /* do we have a pigeonhole encode hint? */
   if(pt){
     const static_codebook *c=book->c;
     int i,besti=-1;
@@ -492,96 +505,96 @@ int _best(codebook *book, float *a, int 
     int entry=0;
 
     /* dealing with sequentialness is a pain in the ass */
     if(c->q_sequencep){
       int pv;
       long mul=1;
       float qlast=0;
       for(k=0,o=0;k<dim;k++,o+=step){
-	pv=(int)((a[o]-qlast-pt->min)/pt->del);
-	if(pv<0 || pv>=pt->mapentries)break;
-	entry+=pt->pigeonmap[pv]*mul;
-	mul*=pt->quantvals;
-	qlast+=pv*pt->del+pt->min;
+        pv=(int)((a[o]-qlast-pt->min)/pt->del);
+        if(pv<0 || pv>=pt->mapentries)break;
+        entry+=pt->pigeonmap[pv]*mul;
+        mul*=pt->quantvals;
+        qlast+=pv*pt->del+pt->min;
       }
     }else{
       for(k=0,o=step*(dim-1);k<dim;k++,o-=step){
-	int pv=(int)((a[o]-pt->min)/pt->del);
-	if(pv<0 || pv>=pt->mapentries)break;
-	entry=entry*pt->quantvals+pt->pigeonmap[pv];
+        int pv=(int)((a[o]-pt->min)/pt->del);
+        if(pv<0 || pv>=pt->mapentries)break;
+        entry=entry*pt->quantvals+pt->pigeonmap[pv];
       }
     }
 
     /* must be within the pigeonholable range; if we quant outside (or
        in an entry that we define no list for), brute force it */
     if(k==dim && pt->fitlength[entry]){
       /* search the abbreviated list */
       long *list=pt->fitlist+pt->fitmap[entry];
       for(i=0;i<pt->fitlength[entry];i++){
-	float this=_dist(dim,book->valuelist+list[i]*dim,a,step);
-	if(besti==-1 || this<best){
-	  best=this;
-	  besti=list[i];
-	}
+        float this=_dist(dim,book->valuelist+list[i]*dim,a,step);
+        if(besti==-1 || this<best){
+          best=this;
+          besti=list[i];
+        }
       }
 
       return(besti); 
     }
   }
 
   if(nt){
     /* optimized using the decision tree */
     while(1){
       float c=0.f;
       float *p=book->valuelist+nt->p[ptr];
       float *q=book->valuelist+nt->q[ptr];
       
       for(k=0,o=0;k<dim;k++,o+=step)
-	c+=(p[k]-q[k])*(a[o]-(p[k]+q[k])*.5);
+        c+=(p[k]-q[k])*(a[o]-(p[k]+q[k])*.5);
       
       if(c>0.f) /* in A */
-	ptr= -nt->ptr0[ptr];
+        ptr= -nt->ptr0[ptr];
       else     /* in B */
-	ptr= -nt->ptr1[ptr];
+        ptr= -nt->ptr1[ptr];
       if(ptr<=0)break;
     }
     return(-ptr);
   }
 #endif 
 
   /* brute force it! */
   {
     const static_codebook *c=book->c;
     int i,besti=-1;
     float best=0.f;
     float *e=book->valuelist;
     for(i=0;i<book->entries;i++){
       if(c->lengthlist[i]>0){
-	float this=_dist(dim,e,a,step);
-	if(besti==-1 || this<best){
-	  best=this;
-	  besti=i;
-	}
+        float this=_dist(dim,e,a,step);
+        if(besti==-1 || this<best){
+          best=this;
+          besti=i;
+        }
       }
       e+=dim;
     }
 
     /*if(savebest!=-1 && savebest!=besti){
       fprintf(stderr,"brute force/pigeonhole disagreement:\n"
-	      "original:");
+              "original:");
       for(i=0;i<dim*step;i+=step)fprintf(stderr,"%g,",a[i]);
       fprintf(stderr,"\n"
-	      "pigeonhole (entry %d, err %g):",savebest,saverr);
+              "pigeonhole (entry %d, err %g):",savebest,saverr);
       for(i=0;i<dim;i++)fprintf(stderr,"%g,",
-				(book->valuelist+savebest*dim)[i]);
+                                (book->valuelist+savebest*dim)[i]);
       fprintf(stderr,"\n"
-	      "bruteforce (entry %d, err %g):",besti,best);
+              "bruteforce (entry %d, err %g):",besti,best);
       for(i=0;i<dim;i++)fprintf(stderr,"%g,",
-				(book->valuelist+besti*dim)[i]);
+                                (book->valuelist+besti*dim)[i]);
       fprintf(stderr,"\n");
       }*/
     return(besti);
   }
 }
 
 long vorbis_book_codeword(codebook *book,int entry){
   if(book->c) /* only use with encode; decode optimizations are
@@ -620,101 +633,106 @@ static long partial_quantlist1[]={0,7,2}
 
 /* no mapping */
 static_codebook test1={
   4,16,
   NULL,
   0,
   0,0,0,0,
   NULL,
-  NULL,NULL
+  NULL,NULL,NULL,
+  0
 };
 static float *test1_result=NULL;
   
 /* linear, full mapping, nonsequential */
 static_codebook test2={
   4,3,
   NULL,
   2,
   -533200896,1611661312,4,0,
   full_quantlist1,
-  NULL,NULL
+  NULL,NULL,NULL,
+  0
 };
 static float test2_result[]={-3,-2,-1,0, 1,2,3,4, 5,0,3,-2};
 
 /* linear, full mapping, sequential */
 static_codebook test3={
   4,3,
   NULL,
   2,
   -533200896,1611661312,4,1,
   full_quantlist1,
-  NULL,NULL
+  NULL,NULL,NULL,
+  0
 };
 static float test3_result[]={-3,-5,-6,-6, 1,3,6,10, 5,5,8,6};
 
 /* linear, algorithmic mapping, nonsequential */
 static_codebook test4={
   3,27,
   NULL,
   1,
   -533200896,1611661312,4,0,
   partial_quantlist1,
-  NULL,NULL
+  NULL,NULL,NULL,
+  0
 };
 static float test4_result[]={-3,-3,-3, 4,-3,-3, -1,-3,-3,
-			      -3, 4,-3, 4, 4,-3, -1, 4,-3,
-			      -3,-1,-3, 4,-1,-3, -1,-1,-3, 
-			      -3,-3, 4, 4,-3, 4, -1,-3, 4,
-			      -3, 4, 4, 4, 4, 4, -1, 4, 4,
-			      -3,-1, 4, 4,-1, 4, -1,-1, 4,
-			      -3,-3,-1, 4,-3,-1, -1,-3,-1,
-			      -3, 4,-1, 4, 4,-1, -1, 4,-1,
-			      -3,-1,-1, 4,-1,-1, -1,-1,-1};
+                              -3, 4,-3, 4, 4,-3, -1, 4,-3,
+                              -3,-1,-3, 4,-1,-3, -1,-1,-3, 
+                              -3,-3, 4, 4,-3, 4, -1,-3, 4,
+                              -3, 4, 4, 4, 4, 4, -1, 4, 4,
+                              -3,-1, 4, 4,-1, 4, -1,-1, 4,
+                              -3,-3,-1, 4,-3,-1, -1,-3,-1,
+                              -3, 4,-1, 4, 4,-1, -1, 4,-1,
+                              -3,-1,-1, 4,-1,-1, -1,-1,-1};
 
 /* linear, algorithmic mapping, sequential */
 static_codebook test5={
   3,27,
   NULL,
   1,
   -533200896,1611661312,4,1,
   partial_quantlist1,
-  NULL,NULL
+  NULL,NULL,NULL,
+  0
 };
 static float test5_result[]={-3,-6,-9, 4, 1,-2, -1,-4,-7,
-			      -3, 1,-2, 4, 8, 5, -1, 3, 0,
-			      -3,-4,-7, 4, 3, 0, -1,-2,-5, 
-			      -3,-6,-2, 4, 1, 5, -1,-4, 0,
-			      -3, 1, 5, 4, 8,12, -1, 3, 7,
-			      -3,-4, 0, 4, 3, 7, -1,-2, 2,
-			      -3,-6,-7, 4, 1, 0, -1,-4,-5,
-			      -3, 1, 0, 4, 8, 7, -1, 3, 2,
-			      -3,-4,-5, 4, 3, 2, -1,-2,-3};
+                              -3, 1,-2, 4, 8, 5, -1, 3, 0,
+                              -3,-4,-7, 4, 3, 0, -1,-2,-5, 
+                              -3,-6,-2, 4, 1, 5, -1,-4, 0,
+                              -3, 1, 5, 4, 8,12, -1, 3, 7,
+                              -3,-4, 0, 4, 3, 7, -1,-2, 2,
+                              -3,-6,-7, 4, 1, 0, -1,-4,-5,
+                              -3, 1, 0, 4, 8, 7, -1, 3, 2,
+                              -3,-4,-5, 4, 3, 2, -1,-2,-3};
 
 void run_test(static_codebook *b,float *comp){
   float *out=_book_unquantize(b,b->entries,NULL);
   int i;
 
   if(comp){
     if(!out){
       fprintf(stderr,"_book_unquantize incorrectly returned NULL\n");
       exit(1);
     }
 
     for(i=0;i<b->entries*b->dim;i++)
       if(fabs(out[i]-comp[i])>.0001){
-	fprintf(stderr,"disagreement in unquantized and reference data:\n"
-		"position %d, %g != %g\n",i,out[i],comp[i]);
-	exit(1);
+        fprintf(stderr,"disagreement in unquantized and reference data:\n"
+                "position %d, %g != %g\n",i,out[i],comp[i]);
+        exit(1);
       }
 
   }else{
     if(out){
       fprintf(stderr,"_book_unquantize returned a value array: \n"
-	      " correct result should have been NULL\n");
+              " correct result should have been NULL\n");
       exit(1);
     }
   }
 }
 
 int main(){
   /* run the nine dequant tests, and compare to the hand-rolled results */
   fprintf(stderr,"Dequant test 1... ");
--- a/media/libvorbis/lib/vorbis_smallft.c
+++ b/media/libvorbis/lib/vorbis_smallft.c
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: *unnormalized* fft transform
- last mod: $Id: smallft.c 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 /* FFT implementation from OggSquish, minus cosine transforms,
  * minus all but radix 2/4 case.  In Vorbis we only need this
  * cut-down version.
  *
  * To do more than just power-of-two sized vectors, see the full
@@ -89,20 +89,20 @@ static void drfti1(int n, float *wa, int
     ipm=ip-1;
 
     for (j=0;j<ipm;j++){
       ld+=l1;
       i=is;
       argld=(float)ld*argh;
       fi=0.f;
       for (ii=2;ii<ido;ii+=2){
-	fi+=1.f;
-	arg=fi*argld;
-	wa[i++]=cos(arg);
-	wa[i++]=sin(arg);
+        fi+=1.f;
+        arg=fi*argld;
+        wa[i++]=cos(arg);
+        wa[i++]=sin(arg);
       }
       is+=ido;
     }
     l1=l2;
   }
 }
 
 static void fdrffti(int n, float *wsave, int *ifac){
@@ -162,17 +162,17 @@ static void dradf2(int ido,int l1,float 
     ch[t1-1]=cc[t3];
     t1+=ido<<1;
     t2+=ido;
     t3+=ido;
   }
 }
 
 static void dradf4(int ido,int l1,float *cc,float *ch,float *wa1,
-	    float *wa2,float *wa3){
+            float *wa2,float *wa3){
   static float hsqt2 = .70710678118654752f;
   int i,k,t0,t1,t2,t3,t4,t5,t6;
   float ci2,ci3,ci4,cr2,cr3,cr4,ti1,ti2,ti3,ti4,tr1,tr2,tr3,tr4;
   t0=l1*ido;
   
   t1=t0;
   t4=t1<<1;
   t2=t1+(t1<<1);
@@ -742,17 +742,17 @@ static void dradb3(int ido,int l1,float 
       ch[t10-1]=wa2[i-2]*dr3-wa2[i-1]*di3;
       ch[t10]=wa2[i-2]*di3+wa2[i-1]*dr3;
     }
     t1+=ido;
   }
 }
 
 static void dradb4(int ido,int l1,float *cc,float *ch,float *wa1,
-			  float *wa2,float *wa3){
+                          float *wa2,float *wa3){
   static float sqrt2=1.414213562373095f;
   int i,k,t0,t1,t2,t3,t4,t5,t6,t7,t8;
   float ci2,ci3,ci4,cr2,cr3,cr4,ti1,ti2,ti3,ti4,tr1,tr2,tr3,tr4;
   t0=l1*ido;
   
   t1=0;
   t2=ido<<2;
   t3=0;
--- a/media/libvorbis/lib/vorbis_synthesis.c
+++ b/media/libvorbis/lib/vorbis_synthesis.c
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: single-block PCM synthesis
- last mod: $Id: synthesis.c 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #include <stdio.h>
 #include <ogg/ogg.h>
 #include "vorbis/codec.h"
 #include "codec_internal.h"
 #include "registry.h"
@@ -78,17 +78,17 @@ int vorbis_synthesis(vorbis_block *vb,og
   vb->pcm=_vorbis_block_alloc(vb,sizeof(*vb->pcm)*vi->channels);
   for(i=0;i<vi->channels;i++)
     vb->pcm[i]=_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i]));
 
   /* unpack_header enforces range checking */
   type=ci->map_type[ci->mode_param[mode]->mapping];
 
   return(_mapping_P[type]->inverse(vb,ci->map_param[ci->mode_param[mode]->
-						   mapping]));
+                                                   mapping]));
 }
 
 /* used to track pcm position without actually performing decode.
    Useful for sequential 'fast forward' */
 int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op){
   vorbis_dsp_state     *vd=vb->vd;
   private_state        *b=vd->backend_state;
   vorbis_info          *vi=vd->vi;
--- a/media/libvorbis/lib/vorbis_window.c
+++ b/media/libvorbis/lib/vorbis_window.c
@@ -6,37 +6,37 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: window functions
- last mod: $Id: window.c 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #include <stdlib.h>
 #include <math.h>
 #include "os.h"
 #include "misc.h"
 
-static float vwin64[32] = {
+static const float vwin64[32] = {
   0.0009460463F, 0.0085006468F, 0.0235352254F, 0.0458950567F, 
   0.0753351908F, 0.1115073077F, 0.1539457973F, 0.2020557475F, 
   0.2551056759F, 0.3122276645F, 0.3724270287F, 0.4346027792F, 
   0.4975789974F, 0.5601459521F, 0.6211085051F, 0.6793382689F, 
   0.7338252629F, 0.7837245849F, 0.8283939355F, 0.8674186656F, 
   0.9006222429F, 0.9280614787F, 0.9500073081F, 0.9669131782F, 
   0.9793740220F, 0.9880792941F, 0.9937636139F, 0.9971582668F, 
   0.9989462667F, 0.9997230082F, 0.9999638688F, 0.9999995525F, 
 };
 
-static float vwin128[64] = {
+static const float vwin128[64] = {
   0.0002365472F, 0.0021280687F, 0.0059065254F, 0.0115626550F, 
   0.0190823442F, 0.0284463735F, 0.0396300935F, 0.0526030430F, 
   0.0673285281F, 0.0837631763F, 0.1018564887F, 0.1215504095F, 
   0.1427789367F, 0.1654677960F, 0.1895342001F, 0.2148867160F, 
   0.2414252576F, 0.2690412240F, 0.2976177952F, 0.3270303960F, 
   0.3571473350F, 0.3878306189F, 0.4189369387F, 0.4503188188F, 
   0.4818259135F, 0.5133064334F, 0.5446086751F, 0.5755826278F, 
   0.6060816248F, 0.6359640047F, 0.6650947483F, 0.6933470543F, 
@@ -45,17 +45,17 @@ static float vwin128[64] = {
   0.8928678298F, 0.9080153310F, 0.9217306608F, 0.9340480615F, 
   0.9450138200F, 0.9546851041F, 0.9631286621F, 0.9704194171F, 
   0.9766389810F, 0.9818741197F, 0.9862151938F, 0.9897546035F, 
   0.9925852598F, 0.9947991032F, 0.9964856900F, 0.9977308602F, 
   0.9986155015F, 0.9992144193F, 0.9995953200F, 0.9998179155F, 
   0.9999331503F, 0.9999825563F, 0.9999977357F, 0.9999999720F, 
 };
 
-static float vwin256[128] = {
+static const float vwin256[128] = {
   0.0000591390F, 0.0005321979F, 0.0014780301F, 0.0028960636F, 
   0.0047854363F, 0.0071449926F, 0.0099732775F, 0.0132685298F, 
   0.0170286741F, 0.0212513119F, 0.0259337111F, 0.0310727950F, 
   0.0366651302F, 0.0427069140F, 0.0491939614F, 0.0561216907F, 
   0.0634851102F, 0.0712788035F, 0.0794969160F, 0.0881331402F, 
   0.0971807028F, 0.1066323515F, 0.1164803426F, 0.1267164297F, 
   0.1373318534F, 0.1483173323F, 0.1596630553F, 0.1713586755F, 
   0.1833933062F, 0.1957555184F, 0.2084333404F, 0.2214142599F, 
@@ -80,17 +80,17 @@ static float vwin256[128] = {
   0.9919389832F, 0.9931929973F, 0.9942985174F, 0.9952667537F, 
   0.9961087037F, 0.9968351119F, 0.9974564312F, 0.9979827858F, 
   0.9984239359F, 0.9987892441F, 0.9990876435F, 0.9993276081F, 
   0.9995171241F, 0.9996636648F, 0.9997741654F, 0.9998550016F, 
   0.9999119692F, 0.9999502656F, 0.9999744742F, 0.9999885497F, 
   0.9999958064F, 0.9999989077F, 0.9999998584F, 0.9999999983F, 
 };
 
-static float vwin512[256] = {
+static const float vwin512[256] = {
   0.0000147849F, 0.0001330607F, 0.0003695946F, 0.0007243509F, 
   0.0011972759F, 0.0017882983F, 0.0024973285F, 0.0033242588F, 
   0.0042689632F, 0.0053312973F, 0.0065110982F, 0.0078081841F, 
   0.0092223540F, 0.0107533880F, 0.0124010466F, 0.0141650703F, 
   0.0160451800F, 0.0180410758F, 0.0201524373F, 0.0223789233F, 
   0.0247201710F, 0.0271757958F, 0.0297453914F, 0.0324285286F, 
   0.0352247556F, 0.0381335972F, 0.0411545545F, 0.0442871045F, 
   0.0475306997F, 0.0508847676F, 0.0543487103F, 0.0579219038F, 
@@ -147,17 +147,17 @@ static float vwin512[256] = {
   0.9994740570F, 0.9995575079F, 0.9996306699F, 0.9996944099F, 
   0.9997495605F, 0.9997969190F, 0.9998372465F, 0.9998712678F, 
   0.9998996704F, 0.9999231041F, 0.9999421807F, 0.9999574732F, 
   0.9999695157F, 0.9999788026F, 0.9999857885F, 0.9999908879F, 
   0.9999944746F, 0.9999968817F, 0.9999984010F, 0.9999992833F, 
   0.9999997377F, 0.9999999317F, 0.9999999911F, 0.9999999999F, 
 };
 
-static float vwin1024[512] = {
+static const float vwin1024[512] = {
   0.0000036962F, 0.0000332659F, 0.0000924041F, 0.0001811086F, 
   0.0002993761F, 0.0004472021F, 0.0006245811F, 0.0008315063F, 
   0.0010679699F, 0.0013339631F, 0.0016294757F, 0.0019544965F, 
   0.0023090133F, 0.0026930125F, 0.0031064797F, 0.0035493989F, 
   0.0040217533F, 0.0045235250F, 0.0050546946F, 0.0056152418F, 
   0.0062051451F, 0.0068243817F, 0.0074729278F, 0.0081507582F, 
   0.0088578466F, 0.0095941655F, 0.0103596863F, 0.0111543789F, 
   0.0119782122F, 0.0128311538F, 0.0137131701F, 0.0146242260F, 
@@ -278,17 +278,17 @@ static float vwin1024[512] = {
   0.9999667820F, 0.9999720773F, 0.9999767136F, 0.9999807479F, 
   0.9999842344F, 0.9999872249F, 0.9999897688F, 0.9999919127F, 
   0.9999937009F, 0.9999951749F, 0.9999963738F, 0.9999973342F, 
   0.9999980900F, 0.9999986724F, 0.9999991103F, 0.9999994297F, 
   0.9999996543F, 0.9999998049F, 0.9999999000F, 0.9999999552F, 
   0.9999999836F, 0.9999999957F, 0.9999999994F, 1.0000000000F, 
 };
 
-static float vwin2048[1024] = {
+static const float vwin2048[1024] = {
   0.0000009241F, 0.0000083165F, 0.0000231014F, 0.0000452785F, 
   0.0000748476F, 0.0001118085F, 0.0001561608F, 0.0002079041F, 
   0.0002670379F, 0.0003335617F, 0.0004074748F, 0.0004887765F, 
   0.0005774661F, 0.0006735427F, 0.0007770054F, 0.0008878533F, 
   0.0010060853F, 0.0011317002F, 0.0012646969F, 0.0014050742F, 
   0.0015528307F, 0.0017079650F, 0.0018704756F, 0.0020403610F, 
   0.0022176196F, 0.0024022497F, 0.0025942495F, 0.0027936173F, 
   0.0030003511F, 0.0032144490F, 0.0034359088F, 0.0036647286F, 
@@ -537,17 +537,17 @@ static float vwin2048[1024] = {
   0.9999979185F, 0.9999982507F, 0.9999985414F, 0.9999987944F, 
   0.9999990129F, 0.9999992003F, 0.9999993596F, 0.9999994939F, 
   0.9999996059F, 0.9999996981F, 0.9999997732F, 0.9999998333F, 
   0.9999998805F, 0.9999999170F, 0.9999999444F, 0.9999999643F, 
   0.9999999784F, 0.9999999878F, 0.9999999937F, 0.9999999972F, 
   0.9999999990F, 0.9999999997F, 1.0000000000F, 1.0000000000F, 
 };
 
-static float vwin4096[2048] = {
+static const float vwin4096[2048] = {
   0.0000002310F, 0.0000020791F, 0.0000057754F, 0.0000113197F, 
   0.0000187121F, 0.0000279526F, 0.0000390412F, 0.0000519777F, 
   0.0000667623F, 0.0000833949F, 0.0001018753F, 0.0001222036F, 
   0.0001443798F, 0.0001684037F, 0.0001942754F, 0.0002219947F, 
   0.0002515616F, 0.0002829761F, 0.0003162380F, 0.0003513472F, 
   0.0003883038F, 0.0004271076F, 0.0004677584F, 0.0005102563F, 
   0.0005546011F, 0.0006007928F, 0.0006488311F, 0.0006987160F, 
   0.0007504474F, 0.0008040251F, 0.0008594490F, 0.0009167191F, 
@@ -1052,17 +1052,17 @@ static float vwin4096[2048] = {
   0.9999998698F, 0.9999998906F, 0.9999999088F, 0.9999999246F, 
   0.9999999383F, 0.9999999500F, 0.9999999600F, 0.9999999684F, 
   0.9999999754F, 0.9999999811F, 0.9999999858F, 0.9999999896F, 
   0.9999999925F, 0.9999999948F, 0.9999999965F, 0.9999999978F, 
   0.9999999986F, 0.9999999992F, 0.9999999996F, 0.9999999998F, 
   0.9999999999F, 1.0000000000F, 1.0000000000F, 1.0000000000F, 
 };
 
-static float vwin8192[4096] = {
+static const float vwin8192[4096] = {
   0.0000000578F, 0.0000005198F, 0.0000014438F, 0.0000028299F, 
   0.0000046780F, 0.0000069882F, 0.0000097604F, 0.0000129945F, 
   0.0000166908F, 0.0000208490F, 0.0000254692F, 0.0000305515F, 
   0.0000360958F, 0.0000421021F, 0.0000485704F, 0.0000555006F, 
   0.0000628929F, 0.0000707472F, 0.0000790635F, 0.0000878417F, 
   0.0000970820F, 0.0001067842F, 0.0001169483F, 0.0001275744F, 
   0.0001386625F, 0.0001502126F, 0.0001622245F, 0.0001746984F, 
   0.0001876343F, 0.0002010320F, 0.0002148917F, 0.0002292132F, 
@@ -2079,39 +2079,39 @@ static float vwin8192[4096] = {
   0.9999999919F, 0.9999999932F, 0.9999999943F, 0.9999999953F, 
   0.9999999961F, 0.9999999969F, 0.9999999975F, 0.9999999980F, 
   0.9999999985F, 0.9999999988F, 0.9999999991F, 0.9999999993F, 
   0.9999999995F, 0.9999999997F, 0.9999999998F, 0.9999999999F, 
   0.9999999999F, 1.0000000000F, 1.0000000000F, 1.0000000000F, 
   1.0000000000F, 1.0000000000F, 1.0000000000F, 1.0000000000F, 
 };
 
-static float *vwin[8] = {
+static const float *const vwin[8] = {
   vwin64,
   vwin128,
   vwin256,
   vwin512,
   vwin1024,
   vwin2048,
   vwin4096,
   vwin8192,
 };
 
-float *_vorbis_window_get(int n){
+const float *_vorbis_window_get(int n){
   return vwin[n];
 }
 
 void _vorbis_apply_window(float *d,int *winno,long *blocksizes,
-			  int lW,int W,int nW){
+                          int lW,int W,int nW){
   lW=(W?lW:0);
   nW=(W?nW:0);
   
   {
-    float *windowLW=vwin[winno[lW]];
-    float *windowNW=vwin[winno[nW]];
+    const float *windowLW=vwin[winno[lW]];
+    const float *windowNW=vwin[winno[nW]];
 
     long n=blocksizes[W];
     long ln=blocksizes[lW];
     long rn=blocksizes[nW];
     
     long leftbegin=n/4-ln/4;
     long leftend=leftbegin+ln/2;
     
--- a/media/libvorbis/lib/window.h
+++ b/media/libvorbis/lib/window.h
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: window functions
- last mod: $Id: window.h 13293 2007-07-24 00:09:47Z xiphmont $
+ last mod: $Id$
 
  ********************************************************************/
 
 #ifndef _V_WINDOW_
 #define _V_WINDOW_
 
 extern float *_vorbis_window_get(int n);
 extern void _vorbis_apply_window(float *d,int *winno,long *blocksizes,
--- a/media/libvorbis/update.sh
+++ b/media/libvorbis/update.sh
@@ -44,11 +44,9 @@ cp $1/lib/block.c ./lib/vorbis_block.c
 cp $1/include/vorbis/codec.h ./include/vorbis/codec.h
 cp $1/todo.txt ./todo.txt
 cp $1/COPYING ./COPYING
 cp $1/README ./README
 cp $1/AUTHORS ./AUTHORS
 patch -p3 < ./alloca.diff
 patch -p3 <./bug481601.patch
 patch -p3 <bug487519.patch
-patch -p3 <bug498827.patch
 patch -p3 <bug498855.patch
-patch -p3 <bug498853.patch