[vorbis-dev] vq diffs

Erik Kruus kruus at on2.com
Wed Nov 8 12:06:19 PST 2000



please add the following diffs to the vorbis/vq dir.
- include files changed so things actually compile in new scheme
- _ogg_...alloc cleanups caught a half-dozen typos or so
- minor Makefile touchup.
(stuff is still not tested, but this will compile at least)

Would someone with cvs write access commit them for me please?

Erik

diffs:
------------------------
diff -bBu2r vorbis/vq/Makefile vorbis-ejk/vq/Makefile
--- vorbis/vq/Makefile	Tue Oct 31 03:25:17 2000
+++ vorbis-ejk/vq/Makefile	Wed Nov  8 14:40:16 2000
@@ -10,5 +10,5 @@
 ###############################################################################
 
-FLAGS=-I. -I../include 
+FLAGS=-I. -I../include -I../lib
 OPT=-O20 $(FLAGS)
 DEBUG=-g -Wall $(FLAGS)
@@ -17,7 +17,7 @@
 LD=gcc
 LDFLAGS=$(FLAGS)
-LIBS=-lm 
+LIBS=-lm -logg
 
-HFILES =	../include/vorbis/codebook.h vqgen.h vqext.h bookutil.h
+HFILES =	../lib/codebook.h vqgen.h vqext.h bookutil.h
 
 OFILES = 	vqgen.o vqsplit.o bookutil.o ../lib/sharedbook.o
@@ -85,5 +85,5 @@
                 lspvqtrain genericvqtrain residuevqtrain\
                 vqbuild vqmetrics latticebuild vqcascade latticepare\
-		huffbuild residuesplit
+		huffbuild residuesplit latticehint latticetune
 
 distclean:	clean
diff -bBu2r vorbis/vq/bookutil.c vorbis-ejk/vq/bookutil.c
--- vorbis/vq/bookutil.c	Sat Nov  4 01:43:55 2000
+++ vorbis-ejk/vq/bookutil.c	Wed Nov  8 14:00:20 2000
@@ -22,7 +22,7 @@
 #include <string.h>
 #include <errno.h>
-#include "vorbis/codebook.h"
-#include "../lib/sharedbook.h"
+#include "misc.h"	/* ogg_malloc, etc. */
 #include "bookutil.h"
+#include "codebook.h"
 
 /* A few little utils for reading files */
@@ -41,8 +41,8 @@
         if(!lbufsize){  
           lbufsize=1024;
-          linebuffer=_ogg_malloc(lbufsize);
+	  linebuffer=(char*)_ogg_malloc(lbufsize);
         }else{
           lbufsize*=2;
-          linebuffer=_ogg_realloc(linebuffer,lbufsize);
+	  linebuffer=(char*)_ogg_realloc(linebuffer,lbufsize);
         }
       }
@@ -179,6 +179,7 @@
 
 codebook *codebook_load(char *filename){
-  codebook *b=_ogg_calloc(1,sizeof(codebook));
-  static_codebook *c=(static_codebook *)(b->c=_ogg_calloc(1,sizeof(static_codebook)));
+  codebook *b=(codebook*)_ogg_calloc(1,sizeof(codebook));
+  static_codebook *c=(static_codebook*)
+      (b->c=(const static_codebook*)_ogg_calloc(1,sizeof(static_codebook)));
   encode_aux_nearestmatch *a=NULL;
   encode_aux_threshmatch *t=NULL;
@@ -216,5 +217,5 @@
   if(find_seek_to(in,"static encode_aux_nearestmatch _vq_aux")){
     /* how big? */
-    c->nearest_tree=a=_ogg_calloc(1,sizeof(encode_aux_nearestmatch));
+    c->nearest_tree=a=(encode_aux_nearestmatch*)_ogg_calloc(1,sizeof(encode_aux_nearestmatch));
     line=get_line(in);
     line=get_line(in);
@@ -230,5 +231,5 @@
     find_seek_to(in,"static long _vq_ptr0");
     reset_next_value();
-    a->ptr0=_ogg_malloc(sizeof(long)*a->aux);
+    a->ptr0=(long*)_ogg_malloc(sizeof(long)*a->aux);
     for(i=0;i<a->aux;i++)
       if(get_next_ivalue(in,a->ptr0+i)){
@@ -240,5 +241,5 @@
     find_seek_to(in,"static long _vq_ptr1");
     reset_next_value();
-    a->ptr1=_ogg_malloc(sizeof(long)*a->aux);
+    a->ptr1=(long*)_ogg_malloc(sizeof(long)*a->aux);
     for(i=0;i<a->aux;i++)
       if(get_next_ivalue(in,a->ptr1+i)){
@@ -251,5 +252,5 @@
     find_seek_to(in,"static long _vq_p_");
     reset_next_value();
-    a->p=_ogg_malloc(sizeof(long)*a->aux);
+    a->p=(long*)_ogg_malloc(sizeof(long)*a->aux);
     for(i=0;i<a->aux;i++)
       if(get_next_ivalue(in,a->p+i)){
@@ -261,5 +262,5 @@
     find_seek_to(in,"static long _vq_q_");
     reset_next_value();
-    a->q=_ogg_malloc(sizeof(long)*a->aux);
+    a->q=(long*)_ogg_malloc(sizeof(long)*a->aux);
     for(i=0;i<a->aux;i++)
       if(get_next_ivalue(in,a->q+i)){
@@ -271,5 +272,5 @@
   if(find_seek_to(in,"static encode_aux_threshmatch _vq_aux")){
     /* how big? */
-    c->thresh_tree=t=_ogg_calloc(1,sizeof(encode_aux_threshmatch));
+    c->thresh_tree=t=(encode_aux_threshmatch*)_ogg_calloc(1,sizeof(encode_aux_threshmatch));
     line=get_line(in);
     line=get_line(in);
@@ -287,5 +288,5 @@
     find_seek_to(in,"static float _vq_quantthresh_");
     reset_next_value();
-    t->quantthresh=_ogg_malloc(sizeof(float)*t->threshvals);
+    t->quantthresh=(float*)_ogg_malloc(sizeof(float)*t->threshvals);
     for(i=0;i<t->threshvals-1;i++)
       if(get_next_value(in,t->quantthresh+i)){
@@ -296,5 +297,5 @@
     find_seek_to(in,"static long _vq_quantmap_");
     reset_next_value();
-    t->quantmap=_ogg_malloc(sizeof(long)*t->threshvals);
+    t->quantmap=(long*)_ogg_malloc(sizeof(long)*t->threshvals);
     for(i=0;i<t->threshvals;i++)
       if(get_next_ivalue(in,t->quantmap+i)){
@@ -307,5 +308,5 @@
     int pigeons=1,i;
     /* how big? */
-    c->pigeon_tree=p=_ogg_calloc(1,sizeof(encode_aux_pigeonhole));
+    c->pigeon_tree=p=(encode_aux_pigeonhole*)_ogg_calloc(1,sizeof(encode_aux_pigeonhole));
     line=get_line(in);
     if(sscanf(line,"%f, %f, %d, %d",&(p->min),&(p->del),
@@ -323,5 +324,5 @@
     find_seek_to(in,"static long _vq_pigeonmap_");
     reset_next_value();
-    p->pigeonmap=_ogg_malloc(sizeof(long)*p->mapentries);
+    p->pigeonmap=(long*)_ogg_malloc(sizeof(long)*p->mapentries);
     for(i=0;i<p->mapentries;i++)
       if(get_next_ivalue(in,p->pigeonmap+i)){
@@ -332,5 +333,5 @@
     find_seek_to(in,"static long _vq_fitlist_");
     reset_next_value();
-    p->fitlist=_ogg_malloc(sizeof(long)*p->fittotal);
+    p->fitlist=(long*)_ogg_malloc(sizeof(long)*p->fittotal);
     for(i=0;i<p->fittotal;i++)
       if(get_next_ivalue(in,p->fitlist+i)){
@@ -342,5 +343,5 @@
     reset_next_value();
     for(i=0;i<c->dim;i++)pigeons*=p->quantvals;
-    p->fitmap=_ogg_malloc(sizeof(long)*pigeons);
+    p->fitmap=(long*)_ogg_malloc(sizeof(long)*pigeons);
     for(i=0;i<pigeons;i++)
       if(get_next_ivalue(in,p->fitmap+i)){
@@ -352,5 +353,5 @@
     find_seek_to(in,"static long _vq_fitlength_");
     reset_next_value();
-    p->fitlength=_ogg_malloc(sizeof(long)*pigeons);
+    p->fitlength=(long*)_ogg_malloc(sizeof(long)*pigeons);
     for(i=0;i<pigeons;i++)
       if(get_next_ivalue(in,p->fitlength+i)){
@@ -375,5 +376,5 @@
   find_seek_to(in,"static long _vq_quantlist_");
   reset_next_value();
-  c->quantlist=_ogg_malloc(sizeof(long)*quant_to_read);
+  c->quantlist=(long*)_ogg_malloc(sizeof(long)*quant_to_read);
   for(i=0;i<quant_to_read;i++)
     if(get_next_ivalue(in,c->quantlist+i)){
@@ -385,5 +386,5 @@
   find_seek_to(in,"static long _vq_lengthlist");
   reset_next_value();
-  c->lengthlist=_ogg_malloc(sizeof(long)*c->entries);
+  c->lengthlist=(long*)_ogg_malloc(sizeof(long)*c->entries);
   for(i=0;i<c->entries;i++)
     if(get_next_ivalue(in,c->lengthlist+i)){
@@ -434,5 +435,5 @@
 void build_tree_from_lengths(int vals, long *hist, long *lengths){
   int i,j;
-  long *membership=_ogg_malloc(vals*sizeof(long));
+  long *membership=(long*)_ogg_malloc(vals*sizeof(long));
   long *histsave=alloca(vals*sizeof(long));
   memcpy(histsave,hist,vals*sizeof(long));
@@ -507,5 +508,5 @@
 
   int upper=0,i;
-  long *lengthlist=_ogg_calloc(vals,sizeof(long));
+  long *lengthlist=(long*)_ogg_calloc(vals,sizeof(long));
   long *newhist=alloca(vals*sizeof(long));
 
diff -bBu2r vorbis/vq/build.c vorbis-ejk/vq/build.c
--- vorbis/vq/build.c	Sat Nov  4 01:43:55 2000
+++ vorbis-ejk/vq/build.c	Wed Nov  8 14:04:02 2000
@@ -22,7 +22,7 @@
 #include <string.h>
 #include <errno.h>
-#include "vorbis/codebook.h"
-#include "../lib/sharedbook.h"
+#include "misc.h"
 #include "bookutil.h"
+#include "codebook.h"
 
 #include "vqgen.h"
diff -bBu2r vorbis/vq/cascade.c vorbis-ejk/vq/cascade.c
--- vorbis/vq/cascade.c	Sat Nov  4 01:22:10 2000
+++ vorbis-ejk/vq/cascade.c	Wed Nov  8 14:05:52 2000
@@ -22,7 +22,7 @@
 #include <unistd.h>
 #include <math.h>
-#include "vorbis/codebook.h"
-#include "../lib/sharedbook.h"
+#include "misc.h"
 #include "bookutil.h"
+#include "codebook.h"
 
 /* set up metrics */
diff -bBu2r vorbis/vq/huffbuild.c vorbis-ejk/vq/huffbuild.c
--- vorbis/vq/huffbuild.c	Sat Nov  4 01:43:55 2000
+++ vorbis-ejk/vq/huffbuild.c	Wed Nov  8 14:34:53 2000
@@ -21,4 +21,5 @@
 #include <math.h>
 #include <stdio.h>
+#include "misc.h"
 #include "bookutil.h"
 
@@ -113,6 +114,6 @@
   {
     long vals=pow(maxval,subn);
-    long *hist=_ogg_malloc(vals*sizeof(long));
-    long *lengths=_ogg_malloc(vals*sizeof(long));
+    long *hist=(long*)_ogg_malloc(vals*sizeof(long));
+    long *lengths=(long*)_ogg_malloc(vals*sizeof(long));
     
     for(j=0;j<vals;j++)hist[j]=guard;
diff -bBu2r vorbis/vq/latticebuild.c vorbis-ejk/vq/latticebuild.c
--- vorbis/vq/latticebuild.c	Sat Nov  4 01:43:55 2000
+++ vorbis-ejk/vq/latticebuild.c	Wed Nov  8 14:11:53 2000
@@ -22,7 +22,7 @@
 #include <string.h>
 #include <errno.h>
-#include "vorbis/codebook.h"
-#include "../lib/sharedbook.h"
+#include "misc.h"
 #include "bookutil.h"
+#include "codebook.h"
 
 /* The purpose of this util is just to finish packaging the
@@ -78,5 +78,5 @@
   {
     char *ptr;
-    char *filename=_ogg_calloc(strlen(argv[1])+4,1);
+    char *filename=(char*)_ogg_calloc(strlen(argv[1])+4,1);
 
     strcpy(filename,argv[1]);
@@ -108,11 +108,11 @@
   c.dim=dim;
   c.entries=entries;
-  c.lengthlist=_ogg_malloc(entries*sizeof(long));
+  c.lengthlist=(long*)_ogg_malloc(entries*sizeof(long));
   c.maptype=1;
   c.q_sequencep=sequencep;
-  c.quantlist=_ogg_calloc(quantvals,sizeof(long));
+  c.quantlist=(long*)_ogg_calloc(quantvals,sizeof(long));
 
-  quantlist=_ogg_malloc(sizeof(long)*c.dim*c.entries);
-  hits=_ogg_malloc(c.entries*sizeof(long));
+  quantlist=(float*)_ogg_malloc(sizeof(float)*c.dim*c.entries);
+  hits=(long*)_ogg_malloc(c.entries*sizeof(long));
   for(j=0;j<entries;j++)hits[j]=1;
   for(j=0;j<entries;j++)c.lengthlist[j]=1;
diff -bBu2r vorbis/vq/latticehint.c vorbis-ejk/vq/latticehint.c
--- vorbis/vq/latticehint.c	Sat Nov  4 01:43:55 2000
+++ vorbis-ejk/vq/latticehint.c	Wed Nov  8 14:33:15 2000
@@ -22,8 +22,8 @@
 #include <string.h>
 #include <errno.h>
-#include "vorbis/codebook.h"
-#include "../lib/sharedbook.h"
-#include "../lib/scales.h"
+#include "misc.h"
 #include "bookutil.h"
+#include "codebook.h"
+#include "../lib/scales.h"
 #include "vqgen.h"
 #include "vqsplit.h"
@@ -59,8 +59,8 @@
     while(i--)
       if(*ptr++==add)return(0);
-    tempstack[entry]=_ogg_realloc(tempstack[entry],
+    tempstack[entry]=(long*)_ogg_realloc(tempstack[entry],
                              (tempcount[entry]+1)*sizeof(long));
   }else{
-    tempstack[entry]=_ogg_malloc(sizeof(long));
+    tempstack[entry]=(long*)_ogg_malloc(sizeof(long));
   }
 
@@ -167,5 +167,5 @@
     long quantvals=_book_maptype1_quantvals(c);
     long **quantsort=alloca(quantvals*sizeof(long *));
-    encode_aux_threshmatch *t=_ogg_calloc(1,sizeof(encode_aux_threshmatch));
+    encode_aux_threshmatch *t=(encode_aux_threshmatch*)_ogg_calloc(1,sizeof(encode_aux_threshmatch));
     c->thresh_tree=t;
 
@@ -173,6 +173,6 @@
 
     /* simplest possible threshold hint only */
-    t->quantthresh=_ogg_calloc(quantvals-1,sizeof(float));
-    t->quantmap=_ogg_calloc(quantvals,sizeof(int));
+    t->quantthresh=(float*)_ogg_calloc(quantvals-1,sizeof(float));
+    t->quantmap=(long*)_ogg_calloc(quantvals,sizeof(long));
     t->threshvals=quantvals;
     t->quantvals=quantvals;
@@ -213,5 +213,5 @@
     int changep=1,factor;
 
-    encode_aux_pigeonhole *p=_ogg_calloc(1,sizeof(encode_aux_pigeonhole));
+    encode_aux_pigeonhole *p=(encode_aux_pigeonhole*)_ogg_calloc(1,sizeof(encode_aux_pigeonhole));
     c->pigeon_tree=p;
 
@@ -238,5 +238,5 @@
       p->mapentries=max;
     }
-    p->pigeonmap=_ogg_malloc(p->mapentries*sizeof(long));
+    p->pigeonmap=(long*)_ogg_malloc(p->mapentries*sizeof(long));
     p->quantvals=(quantvals+factor-1)/factor;
 
@@ -275,9 +275,9 @@
     for(i=0;i<dim;i++)subpigeons*=p->mapentries;
     for(i=0;i<dim;i++)pigeons*=p->quantvals;
-    temptrack=_ogg_calloc(dim,sizeof(long));
-    tempmin=_ogg_calloc(dim,sizeof(float));
-    tempmax=_ogg_calloc(dim,sizeof(float));
-    tempstack=_ogg_calloc(pigeons,sizeof(long *));
-    tempcount=_ogg_calloc(pigeons,sizeof(long));
+    temptrack=(long*)_ogg_calloc(dim,sizeof(long));
+    tempmin=(float*)_ogg_calloc(dim,sizeof(float));
+    tempmax=(float*)_ogg_calloc(dim,sizeof(float));
+    tempstack=(long**)_ogg_calloc(pigeons,sizeof(long *));
+    tempcount=(long*)_ogg_calloc(pigeons,sizeof(long));
 
     while(1){
@@ -339,5 +339,5 @@
     /* pare the list of shortlists; merge contained and similar lists
        together */
-    p->fitmap=_ogg_malloc(pigeons*sizeof(long));
+    p->fitmap=(long*)_ogg_malloc(pigeons*sizeof(long));
     for(i=0;i<pigeons;i++)p->fitmap[i]=-1;
     while(changep){
@@ -389,6 +389,6 @@
 
     p->fittotal=totalstack;
-    p->fitlist=_ogg_malloc((totalstack+1)*sizeof(long));
-    p->fitlength=_ogg_malloc(pigeons*sizeof(long));
+    p->fitlist=(long*)_ogg_malloc((totalstack+1)*sizeof(long));
+    p->fitlength=(long*)_ogg_malloc(pigeons*sizeof(long));
     {
       long usage=0;
diff -bBu2r vorbis/vq/latticepare.c vorbis-ejk/vq/latticepare.c
--- vorbis/vq/latticepare.c	Sat Nov  4 01:43:55 2000
+++ vorbis-ejk/vq/latticepare.c	Wed Nov  8 14:29:42 2000
@@ -22,11 +22,11 @@
 #include <string.h>
 #include <errno.h>
-#include "vorbis/codebook.h"
-#include "../lib/sharedbook.h"
-#include "../lib/scales.h"
+#include "misc.h"
 #include "bookutil.h"
+#include "codebook.h"
 #include "vqgen.h"
 #include "vqsplit.h"
 #include "../lib/os.h"
+#include "../lib/scales.h"
 
 /* Lattice codebooks have two strengths: important fetaures that are
@@ -249,5 +249,5 @@
               line=setup_line(in);
             }
-	    pointlist=_ogg_malloc((cols*lines+entries*dim)*sizeof(float));
+	    pointlist=(float*)_ogg_malloc((cols*lines+entries*dim)*sizeof(float));
             
             rewind(in);
@@ -313,13 +313,13 @@
     long *entryindex;
     long *reventry;
-    long *membership=_ogg_malloc(points*sizeof(long));
-    long *firsthead=_ogg_malloc(entries*sizeof(long));
-    long *secondary=_ogg_malloc(points*sizeof(long));
-    long *secondhead=_ogg_malloc(entries*sizeof(long));
-
-    long *cellcount=_ogg_calloc(entries,sizeof(long));
-    long *cellcount2=_ogg_calloc(entries,sizeof(long));
-    float *cellerror=_ogg_calloc(entries,sizeof(float));
-    float *cellerrormax=_ogg_calloc(entries,sizeof(float));
+    long *membership=(long*)_ogg_malloc(points*sizeof(long));
+    long *firsthead=(long*)_ogg_malloc(entries*sizeof(long));
+    long *secondary=(long*)_ogg_malloc(points*sizeof(long));
+    long *secondhead=(long*)_ogg_malloc(entries*sizeof(long));
+
+    long *cellcount=(long*)_ogg_calloc(entries,sizeof(long));
+    long *cellcount2=(long*)_ogg_calloc(entries,sizeof(long));
+    float *cellerror=(float*)_ogg_calloc(entries,sizeof(float));
+    float *cellerrormax=(float*)_ogg_calloc(entries,sizeof(float));
     long cellsleft=entries;
     for(i=0;i<points;i++)membership[i]=-1;
@@ -356,5 +356,5 @@
        dispersal as the user has requested */
     {
-      long **countindex=_ogg_calloc(entries,sizeof(long *));
+      long **countindex=(long**)_ogg_calloc(entries,sizeof(long *));
       for(i=0;i<entries;i++)countindex[i]=cellcount+i;
       qsort(countindex,entries,sizeof(long *),longsort);
@@ -492,5 +492,5 @@
     free(secondary);
 
-    pointindex=_ogg_malloc(points*sizeof(long));
+    pointindex=(long*)_ogg_malloc(points*sizeof(long));
     /* make a point index of fall-through points */
     for(i=0;i<points;i++){
@@ -502,5 +502,5 @@
 
     /* make an entry index */
-    entryindex=_ogg_malloc(entries*sizeof(long));
+    entryindex=(long*)_ogg_malloc(entries*sizeof(long));
     target=0;
     for(i=0;i<entries;i++){
@@ -510,15 +510,15 @@
 
     /* make working space for a reverse entry index */
-    reventry=_ogg_malloc(entries*sizeof(long));
+    reventry=(long*)_ogg_malloc(entries*sizeof(long));
 
     /* do the split */
-    nt=b->c->nearest_tree=
-      _ogg_calloc(1,sizeof(encode_aux_nearestmatch));
+    nt = b->c->nearest_tree=
+      (encode_aux_nearestmatch*)_ogg_calloc(1,sizeof(encode_aux_nearestmatch));
 
     nt->alloc=4096;
-    nt->ptr0=_ogg_malloc(sizeof(long)*nt->alloc);
-    nt->ptr1=_ogg_malloc(sizeof(long)*nt->alloc);
-    nt->p=_ogg_malloc(sizeof(long)*nt->alloc);
-    nt->q=_ogg_malloc(sizeof(long)*nt->alloc);
+    nt->ptr0=(long*)_ogg_malloc(sizeof(long)*nt->alloc);
+    nt->ptr1=(long*)_ogg_malloc(sizeof(long)*nt->alloc);
+    nt->p=(long*)_ogg_malloc(sizeof(long)*nt->alloc);
+    nt->q=(long*)_ogg_malloc(sizeof(long)*nt->alloc);
     nt->aux=0;
 
@@ -559,5 +559,5 @@
     {
       int upper=0;
-      long *lengthlist=_ogg_calloc(entries,sizeof(long));
+      long *lengthlist=(long*)_ogg_calloc(entries,sizeof(long));
       for(i=0;i<entries;i++){
         if(b->c->lengthlist[i]>0)
diff -bBu2r vorbis/vq/latticetune.c vorbis-ejk/vq/latticetune.c
--- vorbis/vq/latticetune.c	Sat Nov  4 01:43:55 2000
+++ vorbis-ejk/vq/latticetune.c	Wed Nov  8 14:33:57 2000
@@ -23,7 +23,7 @@
 #include <string.h>
 #include <errno.h>
-#include "vorbis/codebook.h"
-#include "../lib/sharedbook.h"
+#include "misc.h"
 #include "bookutil.h"
+#include "codebook.h"
 
 /* This util takes a training-collected file listing codewords used in
@@ -81,6 +81,6 @@
   dim=b->dim;
 
-  hits=_ogg_malloc(entries*sizeof(long));
-  lengths=_ogg_calloc(entries,sizeof(long));
+  hits=(long*)_ogg_malloc(entries*sizeof(long));
+  lengths=(long*)_ogg_calloc(entries,sizeof(long));
   for(j=0;j<entries;j++)hits[j]=guard;
 
diff -bBu2r vorbis/vq/lspdata.c vorbis-ejk/vq/lspdata.c
--- vorbis/vq/lspdata.c	Sat Nov  4 01:43:55 2000
+++ vorbis-ejk/vq/lspdata.c	Wed Nov  8 14:01:06 2000
@@ -20,7 +20,9 @@
 #include <math.h>
 #include <stdio.h>
+#include "misc.h"	/* ogg_malloc, etc. */
 #include "vqgen.h"
 #include "vqext.h"
-#include "../lib/sharedbook.h"
+#include "bookutil.h"
+#include "codebook.h"
 
 char *vqext_booktype="LSPdata";  
@@ -154,5 +156,5 @@
   }
 
-  weight=_ogg_malloc(sizeof(float)*v->elements);
+  weight=(float*)_ogg_malloc(sizeof(float)*v->elements);
 }
 
diff -bBu2r vorbis/vq/metrics.c vorbis-ejk/vq/metrics.c
--- vorbis/vq/metrics.c	Sat Nov  4 01:43:55 2000
+++ vorbis-ejk/vq/metrics.c	Wed Nov  8 14:08:22 2000
@@ -21,7 +21,7 @@
 #include <unistd.h>
 #include <math.h>
-#include "vorbis/codebook.h"
-#include "../lib/sharedbook.h"
+#include "misc.h"
 #include "bookutil.h"
+#include "codebook.h"
 
 /* collect the following metrics:
@@ -64,9 +64,9 @@
   
   if(books){
-    histogram=_ogg_calloc(books,sizeof(float *));
-    histogram_error=_ogg_calloc(books,sizeof(float *));
-    histogram_errorsq=_ogg_calloc(books,sizeof(float *));
-    histogram_hi=_ogg_calloc(books,sizeof(float *));
-    histogram_lo=_ogg_calloc(books,sizeof(float *));
+    histogram=(float**)_ogg_calloc(books,sizeof(float *));
+    histogram_error=(float**)_ogg_calloc(books,sizeof(float *));
+    histogram_errorsq=(float**)_ogg_calloc(books,sizeof(float *));
+    histogram_hi=(float**)_ogg_calloc(books,sizeof(float *));
+    histogram_lo=(float**)_ogg_calloc(books,sizeof(float *));
   }else{
     fprintf(stderr,"Specify at least one codebook\n");
@@ -76,9 +76,9 @@
   for(i=0;i<books;i++){
     codebook *b=bs[i];
-    histogram[i]=_ogg_calloc(b->entries,sizeof(float));
-    histogram_error[i]=_ogg_calloc(b->entries*b->dim,sizeof(float));
-    histogram_errorsq[i]=_ogg_calloc(b->entries*b->dim,sizeof(float));
-    histogram_hi[i]=_ogg_calloc(b->entries*b->dim,sizeof(float));
-    histogram_lo[i]=_ogg_calloc(b->entries*b->dim,sizeof(float));
+    histogram[i]=(float*)_ogg_calloc(b->entries,sizeof(float));
+    histogram_error[i]=(float*)_ogg_calloc(b->entries*b->dim,sizeof(float));
+    histogram_errorsq[i]=(float*)_ogg_calloc(b->entries*b->dim,sizeof(float));
+    histogram_hi[i]=(float*)_ogg_calloc(b->entries*b->dim,sizeof(float));
+    histogram_lo[i]=(float*)_ogg_calloc(b->entries*b->dim,sizeof(float));
   }
 }
diff -bBu2r vorbis/vq/residuedata.c vorbis-ejk/vq/residuedata.c
--- vorbis/vq/residuedata.c	Sat Nov  4 01:43:55 2000
+++ vorbis-ejk/vq/residuedata.c	Wed Nov  8 14:02:59 2000
@@ -21,7 +21,8 @@
 #include <stdio.h>
 #include <string.h>
+#include "misc.h"	/* ogg_malloc, etc. */
 #include "vqgen.h"
 #include "bookutil.h"
-#include "../lib/sharedbook.h"
+#include "codebook.h"
 #include "../lib/scales.h"
 #include "vqext.h"
diff -bBu2r vorbis/vq/residuesplit.c vorbis-ejk/vq/residuesplit.c
--- vorbis/vq/residuesplit.c	Sat Nov  4 01:43:56 2000
+++ vorbis-ejk/vq/residuesplit.c	Wed Nov  8 14:36:53 2000
@@ -21,6 +21,7 @@
 #include <math.h>
 #include <stdio.h>
-#include "../vq/bookutil.h"
-#include "../lib/sharedbook.h"
+#include "misc.h"
+#include "bookutil.h"
+#include "codebook.h"
 
 /* does not guard against invalid settings; eg, a subn of 16 and a
@@ -163,7 +164,7 @@
   parts=argc-3;
   
-  ebound=_ogg_malloc(sizeof(float)*parts);
-  mbound=_ogg_malloc(sizeof(float)*parts);
-  subgrp=_ogg_malloc(sizeof(int)*parts);
+  ebound=(float*)_ogg_malloc(sizeof(float)*parts);
+  mbound=(float*)_ogg_malloc(sizeof(float)*parts);
+  subgrp=(int*)_ogg_malloc(sizeof(int)*parts);
   
   for(i=0;i<parts-1;i++){
@@ -218,5 +219,5 @@
   }
   
-  vec=_ogg_malloc(sizeof(float)*n);
+  vec=(float*)_ogg_malloc(sizeof(float)*n);
   /* get the input line by line and process it */
   while(!feof(res)){
diff -bBu2r vorbis/vq/run.c vorbis-ejk/vq/run.c
--- vorbis/vq/run.c	Sat Nov  4 01:43:56 2000
+++ vorbis-ejk/vq/run.c	Wed Nov  8 14:06:14 2000
@@ -27,4 +27,5 @@
 #include <fcntl.h>
 
+#include "misc.h"
 #include "bookutil.h"
 
@@ -45,6 +46,6 @@
 int main(int argc,char *argv[]){
   char *basename;
-  codebook **b=_ogg_calloc(1,sizeof(codebook *));
-  int *addmul=_ogg_calloc(1,sizeof(int));
+  codebook **b=(codebook**)_ogg_calloc(1,sizeof(codebook *));
+  int *addmul=(int*)_ogg_calloc(1,sizeof(int));
   int books=0;
   int input=0;
@@ -116,7 +117,7 @@
         if(dot)*dot='\0';
 
-	b=_ogg_realloc(b,sizeof(codebook *)*(books+2));
+	b=(codebook**)_ogg_realloc(b,sizeof(codebook *)*(books+2));
         b[books]=codebook_load(name);
-	addmul=_ogg_realloc(addmul,sizeof(int)*(books+1));
+	addmul=(int*)_ogg_realloc(addmul,sizeof(int)*(books+1));
         addmul[books++]=multp;
         b[books]=NULL;
diff -bBu2r vorbis/vq/vqgen.c vorbis-ejk/vq/vqgen.c
--- vorbis/vq/vqgen.c	Sat Nov  4 01:43:56 2000
+++ vorbis-ejk/vq/vqgen.c	Wed Nov  8 14:01:27 2000
@@ -31,7 +31,8 @@
 #include <string.h>
 
+#include "misc.h"	/* ogg_malloc, etc. */
 #include "vqgen.h"
 #include "bookutil.h"
-#include "../lib/sharedbook.h"
+//#include "../lib/codebook.h"
 
 /* Codebook generation happens in two steps: 
@@ -251,11 +252,11 @@
   v->mindist=mindist;
   v->allocated=32768;
-  v->pointlist=_ogg_malloc(v->allocated*(v->elements+v->aux)*sizeof(float));
+  v->pointlist=(float *)_ogg_malloc(v->allocated*(v->elements+v->aux)*sizeof(float));
 
   v->entries=entries;
-  v->entrylist=_ogg_malloc(v->entries*v->elements*sizeof(float));
-  v->assigned=_ogg_malloc(v->entries*sizeof(long));
-  v->bias=_ogg_calloc(v->entries,sizeof(float));
-  v->max=_ogg_calloc(v->entries,sizeof(float));
+  v->entrylist=(float *)_ogg_malloc(v->entries*v->elements*sizeof(float));
+  v->assigned=(long *)_ogg_malloc(v->entries*sizeof(long));
+  v->bias=(float *)_ogg_calloc(v->entries,sizeof(float));
+  v->max=(float *)_ogg_calloc(v->entries,sizeof(float));
   if(metric)
     v->metric_func=metric;
@@ -280,5 +281,5 @@
   if(v->points>=v->allocated){
     v->allocated*=2;
-    v->pointlist=_ogg_realloc(v->pointlist,v->allocated*(v->elements+v->aux)*
+    v->pointlist=(float *)_ogg_realloc(v->pointlist,v->allocated*(v->elements+v->aux)*
                          sizeof(float));
   }
@@ -372,8 +373,8 @@
   desired=fdesired;
   desired2=desired*2;
-  new=_ogg_malloc(sizeof(float)*v->entries*v->elements);
-  new2=_ogg_malloc(sizeof(float)*v->entries*v->elements);
-  nearcount=_ogg_malloc(v->entries*sizeof(long));
-  nearbias=_ogg_malloc(v->entries*desired2*sizeof(float));
+  new=(float *)_ogg_malloc(sizeof(float)*v->entries*v->elements);
+  new2=(float *)_ogg_malloc(sizeof(float)*v->entries*v->elements);
+  nearcount=(long *)_ogg_malloc(v->entries*sizeof(long));
+  nearbias=(float *)_ogg_malloc(v->entries*desired2*sizeof(float));
 
   /* fill in nearest points for entry biasing */
diff -bBu2r vorbis/vq/vqsplit.c vorbis-ejk/vq/vqsplit.c
--- vorbis/vq/vqsplit.c	Sat Nov  4 01:43:56 2000
+++ vorbis-ejk/vq/vqsplit.c	Wed Nov  8 14:01:15 2000
@@ -32,8 +32,9 @@
 #include <sys/time.h>
 
+#include "misc.h"	/* ogg_malloc, etc. */
 #include "vqgen.h"
 #include "vqsplit.h"
 #include "bookutil.h"
-#include "../lib/sharedbook.h"
+#include "codebook.h"
 
 /* Codebook generation happens in two steps: 
@@ -99,6 +100,6 @@
   
   if(splitp){
-    temppointsA=_ogg_malloc(points*sizeof(long));
-    temppointsB=_ogg_malloc(points*sizeof(long));
+    temppointsA=(long *)_ogg_malloc(points*sizeof(long));
+    temppointsB=(long *)_ogg_malloc(points*sizeof(long));
   }
 
@@ -175,6 +176,6 @@
   float *entrylist=b->valuelist;
   long ret;
-  long *entryA=_ogg_calloc(entries,sizeof(long));
-  long *entryB=_ogg_calloc(entries,sizeof(long));
+  long *entryA=(long *)_ogg_calloc(entries,sizeof(long));
+  long *entryB=(long *)_ogg_calloc(entries,sizeof(long));
   long entriesA=0;
   long entriesB=0;
@@ -321,8 +322,8 @@
     if(t->aux>=t->alloc){
       t->alloc*=2;
-      t->ptr0=_ogg_realloc(t->ptr0,sizeof(long)*t->alloc);
-      t->ptr1=_ogg_realloc(t->ptr1,sizeof(long)*t->alloc);
-      t->p=_ogg_realloc(t->p,sizeof(long)*t->alloc);
-      t->q=_ogg_realloc(t->q,sizeof(long)*t->alloc);
+      t->ptr0=(long*)_ogg_realloc(t->ptr0,sizeof(long)*t->alloc);
+      t->ptr1=(long*)_ogg_realloc(t->ptr1,sizeof(long)*t->alloc);
+      t->p=(long*)_ogg_realloc(t->p,sizeof(long)*t->alloc);
+      t->q=(long*)_ogg_realloc(t->q,sizeof(long)*t->alloc);
     }
     
@@ -379,5 +380,5 @@
   memset(c,0,sizeof(static_codebook));
   b->c=c;
-  t=c->nearest_tree=_ogg_calloc(1,sizeof(encode_aux_nearestmatch));
+  t=c->nearest_tree=(encode_aux_nearestmatch*)_ogg_calloc(1,sizeof(encode_aux_nearestmatch));
   c->maptype=2;
 
@@ -401,5 +402,5 @@
 
   {
-    v->assigned=_ogg_calloc(v->entries,sizeof(long));
+    v->assigned=(long*)_ogg_calloc(v->entries,sizeof(long));
     for(i=0;i<v->points;i++){
       float *ppt=_point(v,i);
@@ -437,8 +438,8 @@
 
   {
-    long *entryindex=_ogg_malloc(v->entries*sizeof(long *));
-    long *pointindex=_ogg_malloc(v->points*sizeof(long));
-    long *membership=_ogg_malloc(v->points*sizeof(long));
-    long *reventry=_ogg_malloc(v->entries*sizeof(long));
+    long *entryindex=(long*)_ogg_malloc(v->entries*sizeof(long));
+    long *pointindex=(long*)_ogg_malloc(v->points*sizeof(long));
+    long *membership=(long*)_ogg_malloc(v->points*sizeof(long));
+    long *reventry=(long*)_ogg_malloc(v->entries*sizeof(long));
     long pointssofar=0;
       
@@ -447,12 +448,12 @@
 
     t->alloc=4096;
-    t->ptr0=_ogg_malloc(sizeof(long)*t->alloc);
-    t->ptr1=_ogg_malloc(sizeof(long)*t->alloc);
-    t->p=_ogg_malloc(sizeof(long)*t->alloc);
-    t->q=_ogg_malloc(sizeof(long)*t->alloc);
+    t->ptr0=(long*)_ogg_malloc(sizeof(long)*t->alloc);
+    t->ptr1=(long*)_ogg_malloc(sizeof(long)*t->alloc);
+    t->p=(long*)_ogg_malloc(sizeof(long)*t->alloc);
+    t->q=(long*)_ogg_malloc(sizeof(long)*t->alloc);
     t->aux=0;
     c->dim=v->elements;
     c->entries=v->entries;
-    c->lengthlist=_ogg_calloc(c->entries,sizeof(long));
+    c->lengthlist=(long*)_ogg_calloc(c->entries,sizeof(long));
     b->valuelist=v->entrylist; /* temporary; replaced later */
     b->dim=c->dim;
@@ -547,5 +548,5 @@
      probability count */
   {
-    long *probability=_ogg_malloc(c->entries*sizeof(long));
+    long *probability=(long*)_ogg_malloc(c->entries*sizeof(long));
     for(i=0;i<c->entries;i++)probability[i]=1; /* trivial guard */
     b->dim=c->dim;
@@ -574,6 +575,6 @@
   {
     long *wordlen=c->lengthlist;
-    long *index=_ogg_malloc(c->entries*sizeof(long));
-    long *revindex=_ogg_malloc(c->entries*sizeof(long));
+    long *index=(long*)_ogg_malloc(c->entries*sizeof(long));
+    long *revindex=(long*)_ogg_malloc(c->entries*sizeof(long));
     int k;
     for(i=0;i<c->entries;i++)index[i]=i;
@@ -595,7 +596,7 @@
 
     /* map lengthlist and vallist with index */
-    c->lengthlist=_ogg_calloc(c->entries,sizeof(long));
-    b->valuelist=_ogg_malloc(sizeof(float)*c->entries*c->dim);
-    c->quantlist=_ogg_malloc(sizeof(long)*c->entries*c->dim);
+    c->lengthlist=(long*)_ogg_calloc(c->entries,sizeof(long));
+    b->valuelist=(float*)_ogg_malloc(sizeof(float)*c->entries*c->dim);
+    c->quantlist=(long*)_ogg_malloc(sizeof(long)*c->entries*c->dim);
     for(i=0;i<c->entries;i++){
       long e=index[i];

--- >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 'vorbis-dev-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 Vorbis-dev mailing list