[xiph-cvs] cvs commit: vorbis/vq vqgen.c

Monty xiphmont at xiph.org
Fri Oct 11 00:44:28 PDT 2002



xiphmont    02/10/11 03:44:28

  Modified:    lib      lsp.c psy.c sharedbook.c
               vq       vqgen.c
  Log:
  Fix sort comparison functions to return -1,0,1 as per spec

Revision  Changes    Path
1.23      +2 -5      vorbis/lib/lsp.c

Index: lsp.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/lsp.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- lsp.c	17 Jul 2002 21:28:37 -0000	1.22
+++ lsp.c	11 Oct 2002 07:44:28 -0000	1.23
@@ -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 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,

<p><p>1.77      +2 -4      vorbis/lib/psy.c

Index: psy.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/psy.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -r1.76 -r1.77
--- psy.c	30 Jul 2002 10:43:07 -0000	1.76
+++ psy.c	11 Oct 2002 07:44:28 -0000	1.77
@@ -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 @@
 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,

<p><p>1.29      +3 -2      vorbis/lib/sharedbook.c

Index: sharedbook.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/sharedbook.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- sharedbook.c	28 Jun 2002 22:19:37 -0000	1.28
+++ sharedbook.c	11 Oct 2002 07:44:28 -0000	1.29
@@ -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 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 */

<p><p>1.41      +2 -3      vorbis/vq/vqgen.c

Index: vqgen.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/vq/vqgen.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- vqgen.c	20 Dec 2001 01:00:40 -0000	1.40
+++ vqgen.c	11 Oct 2002 07:44:28 -0000	1.41
@@ -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 @@
 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){

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list