Commit 5d3dbdf2 authored by Monty's avatar Monty

Fix bug #340 for lowmem branch



git-svn-id: https://svn.xiph.org/branches/lowmem-branch/Tremor@13181 0101bb08-14d6-0310-b084-bc0e0c8e3800
parent 384501d0
......@@ -557,7 +557,11 @@ static inline ogg_uint32_t decode_packed_entry_number(codebook *book,
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){
......@@ -636,7 +640,7 @@ static inline ogg_uint32_t decode_packed_entry_number(codebook *book,
/* 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 @@ int decode_map(codebook *s, oggpack_buffer *b, ogg_int32_t *v, int point){
/* 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_decodev_set(codebook *book,ogg_int32_t *a,
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){
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++;
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;
}
......@@ -127,7 +127,7 @@ int res_inverse(vorbis_dsp_state *vd,vorbis_info_residue *info,
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 @@ int res_inverse(vorbis_dsp_state *vd,vorbis_info_residue *info,
/* 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 */
......
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