Commit a359a8ad authored by Monty's avatar Monty

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.


svn path=/trunk/vorbis/; revision=13169
parent 01a261bf
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
******************************************************************** ********************************************************************
function: basic codebook pack/unpack/code/decode operations 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 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){ ...@@ -255,6 +255,7 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
/* returns the number of bits ************************************************/ /* returns the number of bits ************************************************/
int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b){ 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]); oggpack_write(b,book->codelist[a],book->c->lengthlist[a]);
return(book->c->lengthlist[a]); return(book->c->lengthlist[a]);
} }
......
...@@ -425,7 +425,7 @@ static int _vorbis_pack_info(oggpack_buffer *opb,vorbis_info *vi){ ...@@ -425,7 +425,7 @@ static int _vorbis_pack_info(oggpack_buffer *opb,vorbis_info *vi){
} }
static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){ 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); int bytes = strlen(temp);
/* preamble */ /* preamble */
......
...@@ -336,7 +336,7 @@ static int local_book_besterror(codebook *book,float *a){ ...@@ -336,7 +336,7 @@ static int local_book_besterror(codebook *book,float *a){
} }
} }
{ if(best>-1){
float *ptr=book->valuelist+best*dim; float *ptr=book->valuelist+best*dim;
for(i=0;i<dim;i++) for(i=0;i<dim;i++)
*a++ -= *ptr++; *a++ -= *ptr++;
...@@ -355,10 +355,12 @@ static int _encodepart(oggpack_buffer *opb,float *vec, int n, ...@@ -355,10 +355,12 @@ static int _encodepart(oggpack_buffer *opb,float *vec, int n,
int entry=local_book_besterror(book,vec+i*dim); int entry=local_book_besterror(book,vec+i*dim);
#ifdef TRAIN_RES #ifdef TRAIN_RES
acc[entry]++; if(entry>0)
acc[entry]++;
#endif #endif
bits+=vorbis_book_encode(book,entry,opb); bits+=vorbis_book_encode(book,entry,opb);
} }
return(bits); return(bits);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment