summaryrefslogtreecommitdiff
path: root/apps/codecs/libtremor/codebook.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libtremor/codebook.c')
-rw-r--r--apps/codecs/libtremor/codebook.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/apps/codecs/libtremor/codebook.c b/apps/codecs/libtremor/codebook.c
index 561b597aeb..860cf07bad 100644
--- a/apps/codecs/libtremor/codebook.c
+++ b/apps/codecs/libtremor/codebook.c
@@ -279,7 +279,7 @@ static long decode_packed_block(codebook *book, oggpack_buffer *b,
279 long *bufend = buf + n; 279 long *bufend = buf + n;
280 280
281 while (bufptr<bufend) { 281 while (bufptr<bufend) {
282 if (b->headend > 8) { 282 if(b->endbyte < b->storage - 8) {
283 ogg_uint32_t *ptr; 283 ogg_uint32_t *ptr;
284 unsigned long bit, bitend; 284 unsigned long bit, bitend;
285 unsigned long adr; 285 unsigned long adr;
@@ -292,10 +292,10 @@ static long decode_packed_block(codebook *book, oggpack_buffer *b,
292 const ogg_uint32_t *book_codelist = book->codelist; 292 const ogg_uint32_t *book_codelist = book->codelist;
293 const char *book_dec_codelengths = book->dec_codelengths; 293 const char *book_dec_codelengths = book->dec_codelengths;
294 294
295 adr = (unsigned long)b->headptr; 295 adr = (unsigned long)b->ptr;
296 bit = (adr&3)*8+b->headbit; 296 bit = (adr&3)*8+b->endbit;
297 ptr = (ogg_uint32_t*)(adr&~3); 297 ptr = (ogg_uint32_t*)(adr&~3);
298 bitend = ((adr&3)+b->headend)*8; 298 bitend = ((adr&3)+(b->storage-b->endbyte))*8;
299 while (bufptr<bufend){ 299 while (bufptr<bufend){
300 if (UNLIKELY(cachesize<book_dec_maxlength)) { 300 if (UNLIKELY(cachesize<book_dec_maxlength)) {
301 if (bit-cachesize+32>=bitend) 301 if (bit-cachesize+32>=bitend)
@@ -323,11 +323,11 @@ static long decode_packed_block(codebook *book, oggpack_buffer *b,
323 cache >>= l; 323 cache >>= l;
324 } 324 }
325 325
326 adr=(unsigned long)b->headptr; 326 adr=(unsigned long)b->ptr;
327 bit-=(adr&3)*8+cachesize; 327 bit-=(adr&3)*8+cachesize;
328 b->headend-=(bit/8); 328 b->endbyte+=bit/8;
329 b->headptr+=bit/8; 329 b->ptr+=bit/8;
330 b->headbit=bit%8; 330 b->endbit=bit&7;
331 } else { 331 } else {
332 long r = decode_packed_entry_number(book, b); 332 long r = decode_packed_entry_number(book, b);
333 if (r == -1) return bufptr-buf; 333 if (r == -1) return bufptr-buf;
@@ -337,7 +337,6 @@ static long decode_packed_block(codebook *book, oggpack_buffer *b,
337 return n; 337 return n;
338} 338}
339 339
340
341/* Decode side is specced and easier, because we don't need to find 340/* Decode side is specced and easier, because we don't need to find
342 matches using different criteria; we simply read and map. There are 341 matches using different criteria; we simply read and map. There are
343 two things we need to do 'depending': 342 two things we need to do 'depending':
@@ -570,3 +569,4 @@ long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,
570 } 569 }
571 return(0); 570 return(0);
572} 571}
572