From a359a8ad3ed36159af74b10d0c66e2ff44924c82 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 22 Jun 2007 03:01:47 +0000 Subject: [PATCH] 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 --- lib/codebook.c | 3 ++- lib/info.c | 2 +- lib/res0.c | 8 +++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/codebook.c b/lib/codebook.c index ea36032..e689756 100644 --- a/lib/codebook.c +++ b/lib/codebook.c @@ -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 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){ /* 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]); } diff --git a/lib/info.c b/lib/info.c index 61b3792..f6cf568 100644 --- a/lib/info.c +++ b/lib/info.c @@ -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){ - char temp[]="Xiph.Org libVorbis I 20070621"; + char temp[]="Xiph.Org libVorbis I 20070622"; int bytes = strlen(temp); /* preamble */ diff --git a/lib/res0.c b/lib/res0.c index 5720bac..8a78981 100644 --- a/lib/res0.c +++ b/lib/res0.c @@ -336,7 +336,7 @@ static int local_book_besterror(codebook *book,float *a){ } } - { + if(best>-1){ float *ptr=book->valuelist+best*dim; for(i=0;i0) + acc[entry]++; #endif - + bits+=vorbis_book_encode(book,entry,opb); + } return(bits); -- 2.7.4