Commit 32939197 authored by Monty's avatar Monty

More fixes to handle the null-entry codebook case. It appears the

failure to handle this case affects more of the code than thought;
many of the old low-bitrate crash cases trace back to this problem.

This also affects tremor.  These changes are not yet thoroughly
tested.


svn path=/trunk/vorbis/; revision=13172
parent a527fa59
......@@ -350,6 +350,7 @@ STIN long decode_packed_entry_number(codebook *book, oggpack_buffer *b){
}
oggpack_adv(b, read);
return(-1);
}
......@@ -369,16 +370,19 @@ STIN long decode_packed_entry_number(codebook *book, oggpack_buffer *b){
/* returns the [original, not compacted] entry number or -1 on eof *********/
long vorbis_book_decode(codebook *book, oggpack_buffer *b){
if(book->used_entries>0){
long packed_entry=decode_packed_entry_number(book,b);
if(packed_entry>=0)
return(book->dec_index[packed_entry]);
}
/* if there's no dec_index, the codebook unpacking isn't collapsed */
return(packed_entry);
return(-1);
}
/* returns 0 on OK or -1 on eof *************************************/
long vorbis_book_decodevs_add(codebook *book,float *a,oggpack_buffer *b,int n){
if(book->used_entries>0){
int step=n/book->dim;
long *entry = alloca(sizeof(*entry)*step);
float **t = alloca(sizeof(*t)*step);
......@@ -392,10 +396,12 @@ long vorbis_book_decodevs_add(codebook *book,float *a,oggpack_buffer *b,int n){
for(i=0,o=0;i<book->dim;i++,o+=step)
for (j=0;j<step;j++)
a[o+j]+=t[j][i];
}
return(0);
}
long vorbis_book_decodev_add(codebook *book,float *a,oggpack_buffer *b,int n){
if(book->used_entries>0){
int i,j,entry;
float *t;
......@@ -435,10 +441,12 @@ long vorbis_book_decodev_add(codebook *book,float *a,oggpack_buffer *b,int n){
}
}
}
}
return(0);
}
long vorbis_book_decodev_set(codebook *book,float *a,oggpack_buffer *b,int n){
if(book->used_entries>0){
int i,j,entry;
float *t;
......@@ -449,14 +457,23 @@ long vorbis_book_decodev_set(codebook *book,float *a,oggpack_buffer *b,int n){
for (j=0;j<book->dim;)
a[i++]=t[j++];
}
}else{
int i,j;
for(i=0;i<n;){
for (j=0;j<book->dim;)
a[i++]=0.f;
}
}
return(0);
}
long vorbis_book_decodevv_add(codebook *book,float **a,long offset,int ch,
oggpack_buffer *b,int n){
long i,j,entry;
int chptr=0;
if(book->used_entries>0){
for(i=offset/ch;i<(offset+n)/ch;){
entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1);
......@@ -471,6 +488,7 @@ long vorbis_book_decodevv_add(codebook *book,float **a,long offset,int ch,
}
}
}
}
return(0);
}
......
......@@ -11,7 +11,7 @@
********************************************************************
function: basic shared codebook operations
last mod: $Id: sharedbook.c,v 1.29 2002/10/11 07:44:28 xiphmont Exp $
last mod: $Id$
********************************************************************/
......@@ -329,6 +329,8 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
c->used_entries=n;
c->dim=s->dim;
if(n>0){
/* two different remappings go on here.
First, we collapse the likely sparse codebook down only to
......@@ -339,7 +341,6 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
Second, we reorder all vectors, including the entry index above,
by sorted bitreversed codeword to allow treeless decode. */
{
/* perform sort */
ogg_uint32_t *codes=_make_words(s->lengthlist,s->entries,c->used_entries);
ogg_uint32_t **codep=alloca(sizeof(*codep)*n);
......@@ -364,7 +365,7 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
for(i=0;i<n;i++)
c->codelist[sortindex[i]]=codes[i];
_ogg_free(codes);
}
c->valuelist=_book_unquantize(s,n,sortindex);
c->dec_index=_ogg_malloc(n*sizeof(*c->dec_index));
......@@ -423,7 +424,7 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
}
}
}
}
return(0);
err_out:
......
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