Fix sort comparison functions to return -1,0,1 as per spec
authorMonty <xiphmont@xiph.org>
Fri, 11 Oct 2002 07:44:28 +0000 (07:44 +0000)
committerMonty <xiphmont@xiph.org>
Fri, 11 Oct 2002 07:44:28 +0000 (07:44 +0000)
svn path=/trunk/vorbis/; revision=3993

lib/lsp.c
lib/psy.c
lib/sharedbook.c
vq/vqgen.c

index 0048aaa..83b1bee 100644 (file)
--- a/lib/lsp.c
+++ b/lib/lsp.c
@@ -11,7 +11,7 @@
  ********************************************************************
 
   function: LSP (also called LSF) conversion routines
-  last mod: $Id: lsp.c,v 1.22 2002/07/17 21:28:37 xiphmont Exp $
+  last mod: $Id: lsp.c,v 1.23 2002/10/11 07:44:28 xiphmont Exp $
 
   The LSP generation code is taken (with minimal modification and a
   few bugfixes) from "On the Computation of the LSP Frequencies" by
@@ -294,10 +294,7 @@ static void cheby(float *g, int ord) {
 }
 
 static int comp(const void *a,const void *b){
-  if(*(float *)a<*(float *)b)
-    return(1);
-  else
-    return(-1);
+  return (*(float *)a<*(float *)b)-(*(float *)a>*(float *)b);
 }
 
 /* Newton-Raphson-Maehly actually functioned as a decent root finder,
index cbfc245..48a8600 100644 (file)
--- a/lib/psy.c
+++ b/lib/psy.c
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: psychoacoustics not including preecho
- last mod: $Id: psy.c,v 1.76 2002/07/30 10:43:07 msmith Exp $
+ last mod: $Id: psy.c,v 1.77 2002/10/11 07:44:28 xiphmont Exp $
 
  ********************************************************************/
 
@@ -952,9 +952,7 @@ float **_vp_quantize_couple_memo(vorbis_block *vb,
 static int apsort(const void *a, const void *b){
   float f1=fabs(**(float**)a);
   float f2=fabs(**(float**)b);
-  if(f1>f2)return -1;
-  else if(f1==f2)return 0;
-  else return 1;
+  return (f1<f2)-(f1>f2);
 }
 
 int **_vp_quantize_couple_sort(vorbis_block *vb,
index 47142e0..11c02f6 100644 (file)
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: basic shared codebook operations
- last mod: $Id: sharedbook.c,v 1.28 2002/06/28 22:19:37 xiphmont Exp $
+ last mod: $Id: sharedbook.c,v 1.29 2002/10/11 07:44:28 xiphmont Exp $
 
  ********************************************************************/
 
@@ -310,7 +310,8 @@ static ogg_uint32_t bitreverse(ogg_uint32_t x){
 }
 
 static int sort32a(const void *a,const void *b){
-  return ( (**(ogg_uint32_t **)a>**(ogg_uint32_t **)b)<<1)-1;
+  return ( **(ogg_uint32_t **)a>**(ogg_uint32_t **)b)- 
+    ( **(ogg_uint32_t **)a<**(ogg_uint32_t **)b);
 }
 
 /* decode codebook arrangement is more heavily optimized than encode */
index 3407c6f..c32da24 100644 (file)
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: train a VQ codebook 
- last mod: $Id: vqgen.c,v 1.40 2001/12/20 01:00:40 segher Exp $
+ last mod: $Id: vqgen.c,v 1.41 2002/10/11 07:44:28 xiphmont Exp $
 
  ********************************************************************/
 
@@ -83,8 +83,7 @@ void _vqgen_seed(vqgen *v){
 int directdsort(const void *a, const void *b){
   float av=*((float *)a);
   float bv=*((float *)b);
-  if(av>bv)return(-1);
-  return(1);
+  return (av<bv)-(av>bv);
 }
 
 void vqgen_cellmetric(vqgen *v){