[xiph-cvs] cvs commit: Tremor misc.c Makefile.am bitwise.c block.c codebook.c codebook.h codec_internal.h floor0.c floor1.c info.c misc.h res012.c sharedbook.c

Monty xiphmont at xiph.org
Fri Apr 4 17:45:16 PST 2003



xiphmont    03/04/04 20:45:16

  Modified:    .        Tag: lowmem-branch Makefile.am bitwise.c block.c
                        codebook.c codebook.h codec_internal.h floor0.c
                        floor1.c info.c misc.h res012.c
  Added:       .        Tag: lowmem-branch misc.c
  Removed:     .        Tag: lowmem-branch sharedbook.c
  Log:
  Beginning of utralow memory footprint branch

Revision  Changes    Path
No                   revision

<p>No                   revision

<p>1.8.2.1   +2 -2      Tremor/Makefile.am

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/Tremor/Makefile.am,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -u -r1.8 -r1.8.2.1
--- Makefile.am	30 Mar 2003 23:40:56 -0000	1.8
+++ Makefile.am	5 Apr 2003 01:45:15 -0000	1.8.2.1
@@ -5,10 +5,10 @@
 lib_LTLIBRARIES = libvorbisidec.la
 
 libvorbisidec_la_SOURCES = mdct.c block.c window.c \
-                        synthesis.c info.c \
+                        synthesis.c info.c misc.c \
                         floor1.c floor0.c vorbisfile.c \
                         res012.c mapping0.c registry.c codebook.c \
-			sharedbook.c framing.c bitwise.c \
+			framing.c bitwise.c \
                         codebook.h misc.h mdct_lookup.h\
                         os.h mdct.h ivorbisfile.h lsp_lookup.h\
                         registry.h window.h window_lookup.h\

<p><p>1.4.2.1   +1 -0      Tremor/bitwise.c

Index: bitwise.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/bitwise.c,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- bitwise.c	29 Mar 2003 03:07:21 -0000	1.4
+++ bitwise.c	5 Apr 2003 01:45:15 -0000	1.4.2.1
@@ -20,6 +20,7 @@
 
 #include <string.h>
 #include <stdlib.h>
+#include "misc.h"
 #include "ogg.h"
 
 static unsigned long mask[]=

<p><p>1.4.2.1   +0 -11     Tremor/block.c

Index: block.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/block.c,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- block.c	29 Mar 2003 03:07:21 -0000	1.4
+++ block.c	5 Apr 2003 01:45:15 -0000	1.4.2.1
@@ -158,17 +158,6 @@
   b->window[0]=_vorbis_window(0,ci->blocksizes[0]/2);
   b->window[1]=_vorbis_window(0,ci->blocksizes[1]/2);
 
-  /* finish the codebooks */
-  if(!ci->fullbooks){
-    ci->fullbooks=(codebook *)_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;
-    }
-  }
-
   v->pcm_storage=ci->blocksizes[1];
   v->pcm=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->pcm));
   v->pcmret=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->pcmret));

<p><p>1.2.6.1   +335 -42   Tremor/codebook.c

Index: codebook.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/codebook.c,v
retrieving revision 1.2
retrieving revision 1.2.6.1
diff -u -r1.2 -r1.2.6.1
--- codebook.c	3 Sep 2002 03:15:19 -0000	1.2
+++ codebook.c	5 Apr 2003 01:45:15 -0000	1.2.6.1
@@ -24,10 +24,162 @@
 #include "misc.h"
 #include "os.h"
 
-/* unpacks a codebook from the packet buffer into the codebook struct,
-   readies the codebook auxiliary structures for decode *************/
-int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
-  long i,j;
+/**** pack/unpack helpers ******************************************/
+int _ilog(unsigned int v){
+  int ret=0;
+  while(v){
+    ret++;
+    v>>=1;
+  }
+  return(ret);
+}
+
+/* 32 bit float (not IEEE; nonnormalized mantissa +
+   biased exponent) : neeeeeee eeemmmmm mmmmmmmm mmmmmmmm 
+   Why not IEEE?  It's just not that important here. */
+
+static ogg_int32_t _float32_unpack(long val,int *point){
+  long   mant=val&0x1fffff;
+  int    sign=val&0x80000000;
+  long   exp =((val&0x7fe00000L)>>21)-788;
+
+  if(mant){
+    while(!(mant&0x40000000)){
+      mant<<=1;
+      exp-=1;
+    }
+    if(sign)mant= -mant;
+  }else{
+    sign=0;
+    exp=-9999;
+  }
+
+  *point=exp;
+  return mant;
+}
+
+/* given a list of word lengths, generate a list of codewords.  Works
+   for length ordered or unordered, always assigns the lowest valued
+   codewords first.  Extended to handle unused entries (length 0) */
+int _make_words(char *l,long n,ogg_uint32_t *r){
+  long i,j,count=0;
+  ogg_uint32_t marker[33];
+  memset(marker,0,sizeof(marker));
+
+  for(i=0;i<n;i++){
+    long length=l[i];
+    if(length){
+      ogg_uint32_t entry=marker[length];
+      if(count && !entry)return -1; /* overpopulated tree! */
+      r[count++]=entry;
+      
+      /* Look to see if the next shorter marker points to the node
+	 above. if so, update it and repeat.  */
+      for(j=length;j>0;j--){          
+	if(marker[j]&1){
+	  marker[j]=marker[j-1]<<1;
+	  break;
+	}
+	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. */
+      for(j=length+1;j<33;j++)
+	if((marker[j]>>1) == entry){
+	  entry=marker[j];
+	  marker[j]=marker[j-1]<<1;
+	}else
+	  break;
+    }
+  }
+  
+  /* 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(l[i])
+      r[count++]=temp;
+  }
+  
+  return 0;
+}
+
+
+/* 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 */
+/* there might be a straightforward one-line way to do the below
+   that's portable and totally safe against roundoff, but I haven't
+   thought of it.  Therefore, we opt on the side of caution */
+long _book_maptype1_quantvals(codebook *b){
+  /* get us a starting hint, we'll polish it below */
+  int bits=_ilog(b->entries);
+  int vals=b->entries>>((bits-1)*(b->dim-1)/b->dim);
+
+  while(1){
+    long acc=1;
+    long acc1=1;
+    int i;
+    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--;
+      }else{
+        vals++;
+      }
+    }
+  }
+}
+
+void vorbis_book_clear(codebook *b){
+  /* static book is not cleared; we're likely called on the lookup and
+     the static codebook belongs to the info struct */
+  if(b->valuelist)_ogg_free(b->valuelist);
+  if(b->codelist)_ogg_free(b->codelist);
+
+  if(b->dec_index)_ogg_free(b->dec_index);
+  if(b->dec_codelengths)_ogg_free(b->dec_codelengths);
+  if(b->dec_firsttable)_ogg_free(b->dec_firsttable);
+
+  memset(b,0,sizeof(*b));
+}
+
+static ogg_uint32_t bitreverse(ogg_uint32_t x){
+  x=    ((x>>16)&0x0000ffffUL) | ((x<<16)&0xffff0000UL);
+  x=    ((x>> 8)&0x00ff00ffUL) | ((x<< 8)&0xff00ff00UL);
+  x=    ((x>> 4)&0x0f0f0f0fUL) | ((x<< 4)&0xf0f0f0f0UL);
+  x=    ((x>> 2)&0x33333333UL) | ((x<< 2)&0xccccccccUL);
+  return((x>> 1)&0x55555555UL) | ((x<< 1)&0xaaaaaaaaUL);
+}
+
+static int sort32a(const void *a,const void *b){
+  return (**(ogg_uint32_t **)a>**(ogg_uint32_t **)b)-
+    (**(ogg_uint32_t **)a<**(ogg_uint32_t **)b);
+}
+
+int vorbis_book_unpack(oggpack_buffer *opb,codebook *s){
+  char    *lengthlist=NULL;
+  int      quantvals=0;
+  long    *quantlist=NULL;
+  int     *sortindex;
+  long     i,j,k;
+
   memset(s,0,sizeof(*s));
 
   /* make sure alignment is correct */
@@ -42,7 +194,7 @@
   switch((int)oggpack_read(opb,1)){
   case 0:
     /* unordered */
-    s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries);
+    lengthlist=(char *)alloca(sizeof(*lengthlist)*s->entries);
 
     /* allocated but unused entries? */
     if(oggpack_read(opb,1)){
@@ -52,16 +204,18 @@
         if(oggpack_read(opb,1)){
           long num=oggpack_read(opb,5);
           if(num==-1)goto _eofout;
-	  s->lengthlist[i]=num+1;
+	  lengthlist[i]=num+1;
+	  s->used_entries++;
         }else
-	  s->lengthlist[i]=0;
+	  lengthlist[i]=0;
       }
     }else{
       /* all entries used; no tagging */
+      s->used_entries=s->entries;
       for(i=0;i<s->entries;i++){
         long num=oggpack_read(opb,5);
         if(num==-1)goto _eofout;
-	s->lengthlist[i]=num+1;
+	lengthlist[i]=num+1;
       }
     }
     
@@ -70,13 +224,15 @@
     /* ordered */
     {
       long length=oggpack_read(opb,5)+1;
-      s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries);
 
+      s->used_entries=s->entries;
+      lengthlist=(char *)alloca(sizeof(*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;
+	  lengthlist[i]=length;
         length++;
       }
     }
@@ -85,6 +241,31 @@
     /* EOF */
     return(-1);
   }
+
+  {
+    /* perform codebook sort */
+    ogg_uint32_t *codes=(ogg_uint32_t *)alloca(s->used_entries*sizeof(*codes));
+    ogg_uint32_t **codep=(ogg_uint32_t **)alloca(sizeof(*codep)*s->used_entries);
+    if(_make_words(lengthlist,s->entries,codes)) goto _errout;
+    
+    for(i=0;i<s->used_entries;i++){
+      codes[i]=bitreverse(codes[i]);
+      codep[i]=codes+i;
+    }
+    
+    qsort(codep,s->used_entries,sizeof(*codep),sort32a);
+    
+    sortindex=(int *)alloca(s->used_entries*sizeof(*sortindex));
+    s->codelist=(ogg_uint32_t *)_ogg_malloc(s->used_entries*sizeof(*s->codelist));
+    /* the index is a reverse index */
+    for(i=0;i<s->used_entries;i++){
+      int position=codep[i]-codes;
+      sortindex[position]=i;
+    }
+    
+    for(i=0;i<s->used_entries;i++)
+      s->codelist[sortindex[i]]=codes[i];
+  }
   
   /* Do we have a mapping to unpack? */
   switch((s->maptype=oggpack_read(opb,4))){
@@ -92,16 +273,14 @@
     /* no mapping */
     break;
   case 1: case 2:
-    /* implicitly populated value mapping */
-    /* explicitly populated value mapping */
-
-    s->q_min=oggpack_read(opb,32);
-    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;
+      int        *rp=(int *)alloca(s->used_entries*s->dim*sizeof(*rp));
+      int         minpoint,delpoint,count=0;
+      ogg_int32_t mindel=_float32_unpack(oggpack_read(opb,32),&minpoint);
+      ogg_int32_t delta =_float32_unpack(oggpack_read(opb,32),&delpoint);
+      int         q_quant=oggpack_read(opb,4)+1;
+      int         q_sequencep=oggpack_read(opb,1);
+
       switch(s->maptype){
       case 1:
         quantvals=_book_maptype1_quantvals(s);
@@ -112,40 +291,154 @@
       }
       
       /* quantized values */
-      s->quantlist=(long *)_ogg_malloc(sizeof(*s->quantlist)*quantvals);
+      quantlist=(long *)alloca(sizeof(*quantlist)*quantvals);
       for(i=0;i<quantvals;i++)
-	s->quantlist[i]=oggpack_read(opb,s->q_quant);
+	quantlist[i]=oggpack_read(opb,q_quant);
+      
+      if(quantvals && quantlist[quantvals-1]==-1)goto _eofout;
+      s->binarypoint=minpoint;
+      s->valuelist=(ogg_int32_t *)_ogg_calloc(s->used_entries*s->dim,
+					      sizeof(*s->valuelist));
+      
+      /* maptype 1 and 2 both use a quantized value vector, but
+	 different sizes */
+      switch(s->maptype){
+      case 1:
+	for(j=0;j<s->entries;j++){
+	  if(lengthlist[j]){
+	    ogg_int32_t last=0;
+	    int lastpoint=0;
+	    int indexdiv=1;
+	    for(k=0;k<s->dim;k++){
+	      int index= (j/indexdiv)%quantvals;
+	      int point;
+	      int val=VFLOAT_MULTI(delta,delpoint,
+				   abs(quantlist[index]),&point);
+	      
+	      val=VFLOAT_ADD(mindel,minpoint,val,point,&point);
+	      val=VFLOAT_ADD(last,lastpoint,val,point,&point);
+	      
+	      if(q_sequencep){
+		last=val;   
+		lastpoint=point;
+	      }
+	      
+	      s->valuelist[sortindex[count]*s->dim+k]=val;
+              rp[sortindex[count]*s->dim+k]=point;
+	      if(s->binarypoint<point)s->binarypoint=point;
+	      indexdiv*=quantvals;
+	    }
+	    count++;
+	  }
+	  
+	}
+	break;
+      case 2:
+	for(j=0;j<s->entries;j++){
+	  if(lengthlist[j]){
+	    ogg_int32_t last=0;
+	    int         lastpoint=0;
+	    
+	    for(k=0;k<s->dim;k++){
+	      int point;
+	      int val=VFLOAT_MULTI(delta,delpoint,
+				   abs(quantlist[j*s->dim+k]),&point);
+	      
+	      val=VFLOAT_ADD(mindel,minpoint,val,point,&point);
+	      val=VFLOAT_ADD(last,lastpoint,val,point,&point);
+	      
+	      if(q_sequencep){
+		last=val;   
+		lastpoint=point;
+	      }
+	      
+	      s->valuelist[sortindex[count]*s->dim+k]=val;
+              rp[sortindex[count]*s->dim+k]=point;
+	      if(s->binarypoint<point)s->binarypoint=point;
+	    }
+	    count++;
+	  }
+	}
+	break;
+      }
       
-      if(quantvals&&s->quantlist[quantvals-1]==-1)goto _eofout;
+      for(j=0;j<s->used_entries*s->dim;j++)
+	if(rp[j]<s->binarypoint)
+	  s->valuelist[j]>>=s->binarypoint-rp[j];
     }
     break;
   default:
     goto _errout;
   }
 
-  /* all set */
-  return(0);
+  /* decode side optimization lookups */
+  {
+    int n,tabn;
+    long lo=0,hi=0;
+    ogg_uint32_t mask;
+
+    s->dec_index=(int *)_ogg_malloc(s->used_entries*sizeof(*s->dec_index));
+    
+    for(n=0,i=0;i<s->entries;i++)
+      if(lengthlist[i]>0)
+	s->dec_index[sortindex[n++]]=i;
+    
+    s->dec_codelengths=(char *)_ogg_malloc(n*sizeof(*s->dec_codelengths));
+    for(n=0,i=0;i<s->entries;i++)
+      if(lengthlist[i]>0)
+	s->dec_codelengths[sortindex[n++]]=lengthlist[i];
+    
+    s->dec_firsttablen=_ilog(s->used_entries)-4; /* this is magic */
+    if(s->dec_firsttablen<5)s->dec_firsttablen=5;
+    if(s->dec_firsttablen>8)s->dec_firsttablen=8;
+    
+    tabn=1<<s->dec_firsttablen;
+    s->dec_firsttable=
+      (ogg_uint32_t *)_ogg_calloc(tabn,sizeof(*s->dec_firsttable));
+    s->dec_maxlength=0;
+    
+    for(i=0;i<n;i++){
+      if(s->dec_maxlength<s->dec_codelengths[i])
+	s->dec_maxlength=s->dec_codelengths[i];
+      if(s->dec_codelengths[i]<=s->dec_firsttablen){
+	ogg_uint32_t orig=bitreverse(s->codelist[i]);
+	for(j=0;j<(1<<(s->dec_firsttablen-s->dec_codelengths[i]));j++)
+	  s->dec_firsttable[orig|(j<<s->dec_codelengths[i])]=i+1;
+      }
+    }
   
+    /* now fill in 'unused' entries in the firsttable with hi/lo search
+       hints for the non-direct-hits */
+
+    mask=0xfffffffeUL<<(31-s->dec_firsttablen);
+    
+    for(i=0;i<tabn;i++){
+      ogg_uint32_t word=i<<(32-s->dec_firsttablen);
+      if(s->dec_firsttable[bitreverse(word)]==0){
+        while((lo+1)<n && s->codelist[lo+1]<=word)lo++;
+        while(    hi<n && word>=(s->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;
+          s->dec_firsttable[bitreverse(word)]=
+            0x80000000UL | (loval<<15) | hival;
+        }
+      }
+    }
+  }
+  
+  return 0;
  _errout:
  _eofout:
-  vorbis_staticbook_clear(s);
-  return(-1); 
-}
-
-/* the 'eliminate the decode tree' optimization actually requires the
-   codewords to be MSb first, not LSb.  This is an annoying inelegancy
-   (and one of the first places where carefully thought out design
-   turned out to be wrong; Vorbis II and future Ogg codecs should go
-   to an MSb bitpacker), but not actually the huge hit it appears to
-   be.  The first-stage decode table catches most words so that
-   bitreverse is not in the main execution path. */
-
-static ogg_uint32_t bitreverse(ogg_uint32_t x){
-  x=    ((x>>16)&0x0000ffff) | ((x<<16)&0xffff0000);
-  x=    ((x>> 8)&0x00ff00ff) | ((x<< 8)&0xff00ff00);
-  x=    ((x>> 4)&0x0f0f0f0f) | ((x<< 4)&0xf0f0f0f0);
-  x=    ((x>> 2)&0x33333333) | ((x<< 2)&0xcccccccc);
-  return((x>> 1)&0x55555555) | ((x<< 1)&0xaaaaaaaa);
+  vorbis_book_clear(s);
+  return -1;
 }
 
 static inline long decode_packed_entry_number(codebook *book, 

<p><p>1.2.6.1   +5 -44     Tremor/codebook.h

Index: codebook.h
===================================================================
RCS file: /usr/local/cvsroot/Tremor/codebook.h,v
retrieving revision 1.2
retrieving revision 1.2.6.1
diff -u -r1.2 -r1.2.6.1
--- codebook.h	3 Sep 2002 03:15:19 -0000	1.2
+++ codebook.h	5 Apr 2003 01:45:15 -0000	1.2.6.1
@@ -20,45 +20,15 @@
 
 #include "ogg.h"
 
-/* This structure encapsulates huffman and VQ style encoding books; it
-   doesn't do anything specific to either.
-
-   valuelist/quantlist are nonNULL (and q_* significant) only if
-   there's entry->value mapping to be done.
-
-   If encode-side mapping must be done (and thus the entry needs to be
-   hunted), the auxiliary encode pointer will point to a decision
-   tree.  This is true of both VQ and huffman, but is mostly useful
-   with VQ.
-
-*/
-
-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 */
-
-  /* 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
-			*/
-} static_codebook;
-
 typedef struct codebook{
   long dim;           /* codebook dimensions (elements per vector) */
   long entries;       /* codebook entries */
   long used_entries;  /* populated codebook entries */
 
+  int  maptype;        /* 0=none
+			  1=implicitly populated values from map column 
+			  2=listed arbitrary values */
+
   /* the below are ordered by bitreversed codeword and only used
      entries are populated */
   int           binarypoint;
@@ -71,19 +41,10 @@
   int           dec_firsttablen;
   int           dec_maxlength;
 
-  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 */
-
 } codebook;
 
-extern void vorbis_staticbook_clear(static_codebook *b);
-extern void vorbis_staticbook_destroy(static_codebook *b);
-extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source);
-
 extern void vorbis_book_clear(codebook *b);
-extern long _book_maptype1_quantvals(const static_codebook *b);
-
-extern int vorbis_staticbook_unpack(oggpack_buffer *b,static_codebook *c);
+extern int  vorbis_book_unpack(oggpack_buffer *b,codebook *c);
 
 extern long vorbis_book_decode(codebook *book, oggpack_buffer *b);
 extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a, 

<p><p>1.5.6.1   +1 -2      Tremor/codec_internal.h

Index: codec_internal.h
===================================================================
RCS file: /usr/local/cvsroot/Tremor/codec_internal.h,v
retrieving revision 1.5
retrieving revision 1.5.6.1
diff -u -r1.5 -r1.5.6.1
--- codec_internal.h	16 Oct 2002 09:07:00 -0000	1.5
+++ codec_internal.h	5 Apr 2003 01:45:15 -0000	1.5.6.1
@@ -82,8 +82,7 @@
   vorbis_info_floor      *floor_param[64];
   int                     residue_type[64];
   vorbis_info_residue    *residue_param[64];
-  static_codebook        *book_param[256];
-  codebook               *fullbooks;
+  codebook               *book_param;
 
   int    passlimit[32];     /* iteration limit per couple/quant pass */
   int    coupling_passes;

<p><p>1.4.6.1   +1 -1      Tremor/floor0.c

Index: floor0.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/floor0.c,v
retrieving revision 1.4
retrieving revision 1.4.6.1
diff -u -r1.4 -r1.4.6.1
--- floor0.c	16 Oct 2002 09:07:00 -0000	1.4
+++ floor0.c	5 Apr 2003 01:45:15 -0000	1.4.6.1
@@ -390,7 +390,7 @@
     
     if(booknum!=-1 && booknum<info->numbooks){ /* be paranoid */
       codec_setup_info  *ci=(codec_setup_info *)vb->vd->vi->codec_setup;
-      codebook *b=ci->fullbooks+info->books[booknum];
+      codebook *b=ci->book_param+info->books[booknum];
       ogg_int32_t last=0;
       ogg_int32_t *lsp=(ogg_int32_t *)_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+1));
             

<p><p>1.6.6.1   +1 -1      Tremor/floor1.c

Index: floor1.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/floor1.c,v
retrieving revision 1.6
retrieving revision 1.6.6.1
diff -u -r1.6 -r1.6.6.1
--- floor1.c	25 Nov 2002 20:20:21 -0000	1.6
+++ floor1.c	5 Apr 2003 01:45:15 -0000	1.6.6.1
@@ -313,7 +313,7 @@
   codec_setup_info   *ci=(codec_setup_info *)vb->vd->vi->codec_setup;
   
   int i,j,k;
-  codebook *books=ci->fullbooks;   
+  codebook *books=ci->book_param;   
   
   /* unpack wrapped/predicted values from stream */
   if(oggpack_read(&vb->opb,1)==1){

<p><p>1.3.2.1   +8 -26     Tremor/info.c

Index: info.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/info.c,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- info.c	29 Mar 2003 03:07:21 -0000	1.3
+++ info.c	5 Apr 2003 01:45:15 -0000	1.3.2.1
@@ -132,16 +132,11 @@
     for(i=0;i<ci->residues;i++) /* unpack does the range checking */
       _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]);
-      }
-      if(ci->fullbooks)
-	vorbis_book_clear(ci->fullbooks+i);
+    if(ci->book_param){
+      for(i=0;i<ci->books;i++)
+	vorbis_book_clear(ci->book_param+i);
+      _ogg_free(ci->book_param);
     }
-    if(ci->fullbooks)
-	_ogg_free(ci->fullbooks);
     
     _ogg_free(ci);
   }
@@ -217,28 +212,20 @@
 
   /* codebooks */
   ci->books=oggpack_read(opb,8)+1;
-  /*ci->book_param=_ogg_calloc(ci->books,sizeof(*ci->book_param));*/
-  for(i=0;i<ci->books;i++){
-    ci->book_param[i]=(static_codebook *)_ogg_calloc(1,sizeof(*ci->book_param[i]));
-    if(vorbis_staticbook_unpack(opb,ci->book_param[i]))goto err_out;
-  }
+  ci->book_param=(codebook *)
+    _ogg_calloc(ci->books,sizeof(*ci->book_param));
+  for(i=0;i<ci->books;i++)
+    if(vorbis_book_unpack(opb,ci->book_param+i))goto err_out;
 
   /* time backend settings */
   ci->times=oggpack_read(opb,6)+1;
-  /*ci->time_type=_ogg_malloc(ci->times*sizeof(*ci->time_type));*/
-  /*ci->time_param=_ogg_calloc(ci->times,sizeof(void *));*/
   for(i=0;i<ci->times;i++){
     ci->time_type[i]=oggpack_read(opb,16);
     if(ci->time_type[i]<0 || ci->time_type[i]>=VI_TIMEB)goto err_out;
-    /* ci->time_param[i]=_time_P[ci->time_type[i]]->unpack(vi,opb);
-       Vorbis I has no time backend */
-    /*if(!ci->time_param[i])goto err_out;*/
   }
 
   /* floor backend settings */
   ci->floors=oggpack_read(opb,6)+1;
-  /*ci->floor_type=_ogg_malloc(ci->floors*sizeof(*ci->floor_type));*/
-  /*ci->floor_param=_ogg_calloc(ci->floors,sizeof(void *));*/
   for(i=0;i<ci->floors;i++){
     ci->floor_type[i]=oggpack_read(opb,16);
     if(ci->floor_type[i]<0 || ci->floor_type[i]>=VI_FLOORB)goto err_out;
@@ -248,8 +235,6 @@
 
   /* residue backend settings */
   ci->residues=oggpack_read(opb,6)+1;
-  /*ci->residue_type=_ogg_malloc(ci->residues*sizeof(*ci->residue_type));*/
-  /*ci->residue_param=_ogg_calloc(ci->residues,sizeof(void *));*/
   for(i=0;i<ci->residues;i++){
     ci->residue_type[i]=oggpack_read(opb,16);
     if(ci->residue_type[i]<0 || ci->residue_type[i]>=VI_RESB)goto err_out;
@@ -259,8 +244,6 @@
 
   /* map backend settings */
   ci->maps=oggpack_read(opb,6)+1;
-  /*ci->map_type=_ogg_malloc(ci->maps*sizeof(*ci->map_type));*/
-  /*ci->map_param=_ogg_calloc(ci->maps,sizeof(void *));*/
   for(i=0;i<ci->maps;i++){
     ci->map_type[i]=oggpack_read(opb,16);
     if(ci->map_type[i]<0 || ci->map_type[i]>=VI_MAPB)goto err_out;
@@ -270,7 +253,6 @@
   
   /* mode settings */
   ci->modes=oggpack_read(opb,6)+1;
-  /*vi->mode_param=_ogg_calloc(vi->modes,sizeof(void *));*/
   for(i=0;i<ci->modes;i++){
     ci->mode_param[i]=(vorbis_info_mode *)_ogg_calloc(1,sizeof(*ci->mode_param[i]));
     ci->mode_param[i]->blockflag=oggpack_read(opb,1);

<p><p>1.8.2.1   +14 -0     Tremor/misc.h

Index: misc.h
===================================================================
RCS file: /usr/local/cvsroot/Tremor/misc.h,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -u -r1.8 -r1.8.2.1
--- misc.h	30 Mar 2003 23:40:56 -0000	1.8
+++ misc.h	5 Apr 2003 01:45:15 -0000	1.8.2.1
@@ -20,6 +20,20 @@
 #include "ivorbiscodec.h"
 #include "os_types.h"
 
+#define _VDBG_GRAPHFILE "_0.m"
+extern void *_VDBG_malloc(void *ptr,long bytes,char *file,long line); 
+extern void _VDBG_free(void *ptr,char *file,long line); 
+
+#undef _ogg_malloc
+#undef _ogg_calloc
+#undef _ogg_realloc
+#undef _ogg_free
+
+#define _ogg_malloc(x) _VDBG_malloc(NULL,(x),__FILE__,__LINE__)
+#define _ogg_calloc(x,y) _VDBG_malloc(NULL,(x)*(y),__FILE__,__LINE__)
+#define _ogg_realloc(x,y) _VDBG_malloc((x),(y),__FILE__,__LINE__)
+#define _ogg_free(x) _VDBG_free((x),__FILE__,__LINE__)
+
 #include "asm_arm.h"
   
 #ifndef _V_WIDE_MATH

<p><p>1.2.6.1   +3 -3      Tremor/res012.c

Index: res012.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/res012.c,v
retrieving revision 1.2
retrieving revision 1.2.6.1
diff -u -r1.2 -r1.2.6.1
--- res012.c	3 Sep 2002 03:15:19 -0000	1.2
+++ res012.c	5 Apr 2003 01:45:15 -0000	1.2.6.1
@@ -131,8 +131,8 @@
   look->map=vm->mapping;
 
   look->parts=info->partitions;
-  look->fullbooks=ci->fullbooks;
-  look->phrasebook=ci->fullbooks+info->groupbook;
+  look->fullbooks=ci->book_param;
+  look->phrasebook=ci->book_param+info->groupbook;
   dim=look->phrasebook->dim;
 
   look->partbooks=(codebook ***)_ogg_calloc(look->parts,sizeof(*look->partbooks));
@@ -144,7 +144,7 @@
       look->partbooks[j]=(codebook **)_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++];
+	  look->partbooks[j][k]=ci->book_param+info->booklist[acc++];
 #ifdef TRAIN_RES
           look->training_data[k][j]=calloc(look->partbooks[j][k]->entries,
                                            sizeof(***look->training_data));

<p><p>No                   revision

<p>No                   revision

<p>1.1.2.1   +209 -0    Tremor/Attic/misc.c

<p><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