Fixes for three issues:
authorMonty <xiphmont@xiph.org>
Wed, 23 Aug 2000 06:38:49 +0000 (06:38 +0000)
committerMonty <xiphmont@xiph.org>
Wed, 23 Aug 2000 06:38:49 +0000 (06:38 +0000)
Borland needs malloc.h, and this is a cleaner fix for MSVC too (rather than Define alloca...)

Fix sqrt of small negative numbers in smoothing is psy.c

Uninitialized space in floor0.c lookup struct could cause lpc_clear to
trigger on garbage.

Monty

svn path=/trunk/vorbis/; revision=598

lib/floor0.c
lib/os.h
lib/psy.c

index ce30444..6e45cfa 100644 (file)
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: floor backend 0 implementation
- last mod: $Id: floor0.c,v 1.21 2000/08/19 11:46:28 xiphmont Exp $
+ last mod: $Id: floor0.c,v 1.22 2000/08/23 06:38:49 xiphmont Exp $
 
  ********************************************************************/
 
@@ -142,7 +142,7 @@ static vorbis_look_floor *look (vorbis_dsp_state *vd,vorbis_info_mode *mi,
   double scale;
   vorbis_info        *vi=vd->vi;
   vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
-  vorbis_look_floor0 *look=malloc(sizeof(vorbis_look_floor0));
+  vorbis_look_floor0 *look=calloc(1,sizeof(vorbis_look_floor0));
   look->m=info->order;
   look->n=vi->blocksizes[mi->blockflag]/2;
   look->ln=info->barkmap;
index 5b65c21..71586f5 100644 (file)
--- a/lib/os.h
+++ b/lib/os.h
@@ -14,7 +14,7 @@
  ********************************************************************
 
  function: #ifdef jail to whip a few platforms into the UNIX ideal.
- last mod: $Id: os.h,v 1.8 2000/07/07 00:48:19 xiphmont Exp $
+ last mod: $Id: os.h,v 1.9 2000/08/23 06:38:49 xiphmont Exp $
 
  ********************************************************************/
 
@@ -28,7 +28,7 @@
 
 #ifndef __GNUC__
 #ifdef _WIN32
-#  define alloca(x) (_alloca(x))
+#  include <malloc.h>
 #  define rint(x)   (floor((x)+0.5)) 
 #endif
 #endif
index 0be9c1c..38f5cfe 100644 (file)
--- a/lib/psy.c
+++ b/lib/psy.c
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: psychoacoustics not including preecho
- last mod: $Id: psy.c,v 1.25 2000/08/15 11:53:18 xiphmont Exp $
+ last mod: $Id: psy.c,v 1.26 2000/08/23 06:38:49 xiphmont Exp $
 
  ********************************************************************/
 
@@ -631,6 +631,7 @@ void _vp_compute_mask(vorbis_look_psy *p,double *f,
     for(i=1;i<n-1;i++){
       double this=smooth[i];
       acc+=smooth[i+1]*smooth[i+1];
+      if(acc<0)acc=0; /* it can happen due to finite precision */
       smooth[i]=sqrt(acc);
       acc-=prev*prev;
       prev=this;