[xiph-commits] r13169 - trunk/vorbis/lib

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Thu Jun 21 20:01:47 PDT 2007


Author: xiphmont
Date: 2007-06-21 20:01:47 -0700 (Thu, 21 Jun 2007)
New Revision: 13169

Modified:
   trunk/vorbis/lib/codebook.c
   trunk/vorbis/lib/info.c
   trunk/vorbis/lib/res0.c
Log:
Add additional check when attempting to encode values through
codebooks with no entries.  Ideally that wouldn't happen, but it looks
like the automated codebook training ended up with a few 'null' books.



Modified: trunk/vorbis/lib/codebook.c
===================================================================
--- trunk/vorbis/lib/codebook.c	2007-06-22 01:02:19 UTC (rev 13168)
+++ trunk/vorbis/lib/codebook.c	2007-06-22 03:01:47 UTC (rev 13169)
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: basic codebook pack/unpack/code/decode operations
- last mod: $Id: codebook.c,v 1.39 2002/06/28 22:19:35 xiphmont Exp $
+ last mod: $Id$
 
  ********************************************************************/
 
@@ -255,6 +255,7 @@
 
 /* returns the number of bits ************************************************/
 int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b){
+  if(a<0 || a>=book->c->entries)return(0);
   oggpack_write(b,book->codelist[a],book->c->lengthlist[a]);
   return(book->c->lengthlist[a]);
 }

Modified: trunk/vorbis/lib/info.c
===================================================================
--- trunk/vorbis/lib/info.c	2007-06-22 01:02:19 UTC (rev 13168)
+++ trunk/vorbis/lib/info.c	2007-06-22 03:01:47 UTC (rev 13169)
@@ -425,7 +425,7 @@
 }
 
 static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){
-  char temp[]="Xiph.Org libVorbis I 20070621";
+  char temp[]="Xiph.Org libVorbis I 20070622";
   int bytes = strlen(temp);
 
   /* preamble */  

Modified: trunk/vorbis/lib/res0.c
===================================================================
--- trunk/vorbis/lib/res0.c	2007-06-22 01:02:19 UTC (rev 13168)
+++ trunk/vorbis/lib/res0.c	2007-06-22 03:01:47 UTC (rev 13169)
@@ -336,7 +336,7 @@
     }
   }
 
-  {
+  if(best>-1){
     float *ptr=book->valuelist+best*dim;
     for(i=0;i<dim;i++)
       *a++ -= *ptr++;
@@ -355,10 +355,12 @@
     int entry=local_book_besterror(book,vec+i*dim);
 
 #ifdef TRAIN_RES
-    acc[entry]++;
+    if(entry>0)
+      acc[entry]++;
 #endif
-
+      
     bits+=vorbis_book_encode(book,entry,opb);
+  
   }
 
   return(bits);



More information about the commits mailing list