[xiph-commits] r13181 - branches/lowmem-branch/Tremor

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Sat Jun 23 01:21:01 PDT 2007


Author: xiphmont
Date: 2007-06-23 01:21:01 -0700 (Sat, 23 Jun 2007)
New Revision: 13181

Modified:
   branches/lowmem-branch/Tremor/codebook.c
   branches/lowmem-branch/Tremor/res012.c
Log:
Fix bug #340 for lowmem branch



Modified: branches/lowmem-branch/Tremor/codebook.c
===================================================================
--- branches/lowmem-branch/Tremor/codebook.c	2007-06-23 08:20:29 UTC (rev 13180)
+++ branches/lowmem-branch/Tremor/codebook.c	2007-06-23 08:21:01 UTC (rev 13181)
@@ -557,8 +557,12 @@
   
   while(lok<0 && read>1)
     lok = oggpack_look(b, --read);
-  if(lok<0)return -1;
 
+  if(lok<0){
+    oggpack_adv(b,1); /* force eop */
+    return -1;
+  }
+
   /* chase the tree with the bits we got */
   if(book->dec_nodeb==1){
     if(book->dec_leafw==1){
@@ -636,7 +640,7 @@
 /* returns the [original, not compacted] entry number or -1 on eof *********/
 long vorbis_book_decode(codebook *book, oggpack_buffer *b){
   if(book->dec_type)return -1;
-  return decode_packed_entry_number(book,b);
+ return decode_packed_entry_number(book,b);
 }
 
 int decode_map(codebook *s, oggpack_buffer *b, ogg_int32_t *v, int point){
@@ -711,41 +715,53 @@
 /* returns 0 on OK or -1 on eof *************************************/
 long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a,
 			      oggpack_buffer *b,int n,int point){
-  int step=n/book->dim;
-  ogg_int32_t *v = (ogg_int32_t *)alloca(sizeof(*v)*book->dim);
-  int i,j,o;
-
-  for (j=0;j<step;j++){
-    if(decode_map(book,b,v,point))return -1;
-    for(i=0,o=j;i<book->dim;i++,o+=step)
-      a[o]+=v[i];
+  if(book->used_entries>0){
+    int step=n/book->dim;
+    ogg_int32_t *v = (ogg_int32_t *)alloca(sizeof(*v)*book->dim);
+    int i,j,o;
+    
+    for (j=0;j<step;j++){
+      if(decode_map(book,b,v,point))return -1;
+      for(i=0,o=j;i<book->dim;i++,o+=step)
+	a[o]+=v[i];
+    }
   }
   return 0;
 }
 
 long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a,
 			     oggpack_buffer *b,int n,int point){
-  ogg_int32_t *v = (ogg_int32_t *)alloca(sizeof(*v)*book->dim);
-  int i,j;
-  
-  for(i=0;i<n;){
-    if(decode_map(book,b,v,point))return -1;
-    for (j=0;j<book->dim;j++)
-      a[i++]+=v[j];
+  if(book->used_entries>0){
+    ogg_int32_t *v = (ogg_int32_t *)alloca(sizeof(*v)*book->dim);
+    int i,j;
+    
+    for(i=0;i<n;){
+      if(decode_map(book,b,v,point))return -1;
+      for (j=0;j<book->dim;j++)
+	a[i++]+=v[j];
+    }
   }
-  
   return 0;
 }
 
 long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a,
 			     oggpack_buffer *b,int n,int point){
-  ogg_int32_t *v = (ogg_int32_t *)alloca(sizeof(*v)*book->dim);
-  int i,j;
-
-  for(i=0;i<n;){
-    if(decode_map(book,b,v,point))return -1;
-    for (j=0;j<book->dim;j++)
-      a[i++]=v[j];
+  if(book->used_entries>0){
+    ogg_int32_t *v = (ogg_int32_t *)alloca(sizeof(*v)*book->dim);
+    int i,j;
+    
+    for(i=0;i<n;){
+      if(decode_map(book,b,v,point))return -1;
+      for (j=0;j<book->dim;j++)
+	a[i++]=v[j];
+    }
+  }else{
+    int i,j;
+    
+    for(i=0;i<n;){
+      for (j=0;j<book->dim;j++)
+	a[i++]=0;
+    }
   }
 
   return 0;
@@ -754,21 +770,23 @@
 long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,
 			      long offset,int ch,
 			      oggpack_buffer *b,int n,int point){
-
-  ogg_int32_t *v = (ogg_int32_t *)alloca(sizeof(*v)*book->dim);
-  long i,j;
-  int chptr=0;
+  if(book->used_entries>0){
     
-  for(i=offset;i<offset+n;){
-    if(decode_map(book,b,v,point))return -1;
-    for (j=0;j<book->dim;j++){
-      a[chptr++][i]+=v[j];
-      if(chptr==ch){
-	chptr=0;
-	i++;
+    ogg_int32_t *v = (ogg_int32_t *)alloca(sizeof(*v)*book->dim);
+    long i,j;
+    int chptr=0;
+    
+    for(i=offset;i<offset+n;){
+      if(decode_map(book,b,v,point))return -1;
+      for (j=0;j<book->dim;j++){
+	a[chptr++][i]+=v[j];
+	if(chptr==ch){
+	  chptr=0;
+	  i++;
+	}
       }
     }
   }
-  
+
   return 0;
 }

Modified: branches/lowmem-branch/Tremor/res012.c
===================================================================
--- branches/lowmem-branch/Tremor/res012.c	2007-06-23 08:20:29 UTC (rev 13180)
+++ branches/lowmem-branch/Tremor/res012.c	2007-06-23 08:21:01 UTC (rev 13181)
@@ -127,7 +127,7 @@
 	      
 	      for(j=0;j<ch;j++){
 		int temp=vorbis_book_decode(phrasebook,&vd->opb);
-		if(oggpack_eop(&vd->opb))goto eopbreak;
+		if(temp==-1)goto eopbreak;
 		
 		/* this can be done quickly in assembly due to the quotient
 		   always being at most six bits */
@@ -191,7 +191,7 @@
 	    
 	    /* fetch the partition word */
 	    temp=vorbis_book_decode(phrasebook,&vd->opb);
-	    if(oggpack_eop(&vd->opb))goto eopbreak;
+	    if(temp==-1)goto eopbreak;
 	    
 	    /* this can be done quickly in assembly due to the quotient
 	       always being at most six bits */



More information about the commits mailing list