summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2010-03-05 09:48:07 +0000
committerNils Wallménius <nils@rockbox.org>2010-03-05 09:48:07 +0000
commitb382d8334bcfff7fe49ba3ab850b069a6fd95505 (patch)
tree68b47fc848036894d73063a2ad17f81ad6c45cca
parent3c878249705755d1dfb6c5320302f1670dd87a67 (diff)
downloadrockbox-b382d8334bcfff7fe49ba3ab850b069a6fd95505.tar.gz
rockbox-b382d8334bcfff7fe49ba3ab850b069a6fd95505.zip
Fix broken whitespace after r24862
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25031 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/libtremor/asm_arm.h74
-rw-r--r--apps/codecs/libtremor/backends.h10
-rw-r--r--apps/codecs/libtremor/codebook.c214
-rw-r--r--apps/codecs/libtremor/codebook.h18
-rw-r--r--apps/codecs/libtremor/floor0.c36
-rw-r--r--apps/codecs/libtremor/framing.c4
-rw-r--r--apps/codecs/libtremor/info.c64
-rw-r--r--apps/codecs/libtremor/ivorbiscodec.h4
-rw-r--r--apps/codecs/libtremor/ivorbisfile.h6
-rw-r--r--apps/codecs/libtremor/lsp_lookup.h104
-rw-r--r--apps/codecs/libtremor/misc.h32
-rw-r--r--apps/codecs/libtremor/sharedbook.c236
-rw-r--r--apps/codecs/libtremor/window.h4
13 files changed, 399 insertions, 407 deletions
diff --git a/apps/codecs/libtremor/asm_arm.h b/apps/codecs/libtremor/asm_arm.h
index 8da7ed75cc..95f3bef0fc 100644
--- a/apps/codecs/libtremor/asm_arm.h
+++ b/apps/codecs/libtremor/asm_arm.h
@@ -35,11 +35,11 @@ static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
35static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) { 35static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
36 int lo,hi; 36 int lo,hi;
37 asm volatile("smull %0, %1, %2, %3\n\t" 37 asm volatile("smull %0, %1, %2, %3\n\t"
38 "movs %0, %0, lsr #15\n\t" 38 "movs %0, %0, lsr #15\n\t"
39 "adc %1, %0, %1, lsl #17\n\t" 39 "adc %1, %0, %1, lsl #17\n\t"
40 : "=&r"(lo),"=&r"(hi) 40 : "=&r"(lo),"=&r"(hi)
41 : "%r"(x),"r"(y) 41 : "%r"(x),"r"(y)
42 : "cc"); 42 : "cc");
43 return(hi); 43 return(hi);
44} 44}
45 45
@@ -47,42 +47,42 @@ static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
47{ \ 47{ \
48 long l; \ 48 long l; \
49 asm( "smull %0, %1, %4, %6\n\t" \ 49 asm( "smull %0, %1, %4, %6\n\t" \
50 "rsb %3, %4, #0\n\t" \ 50 "rsb %3, %4, #0\n\t" \
51 "smlal %0, %1, %5, %7\n\t" \ 51 "smlal %0, %1, %5, %7\n\t" \
52 "smull %0, %2, %5, %6\n\t" \ 52 "smull %0, %2, %5, %6\n\t" \
53 "smlal %0, %2, %3, %7" \ 53 "smlal %0, %2, %3, %7" \
54 : "=&r" (l), "=&r" (x), "=&r" (y), "=r" ((a)) \ 54 : "=&r" (l), "=&r" (x), "=&r" (y), "=r" ((a)) \
55 : "3" ((a)), "r" ((b)), "r" ((t)), "r" ((v)) ); \ 55 : "3" ((a)), "r" ((b)), "r" ((t)), "r" ((v)) ); \
56} 56}
57 57
58static inline void XPROD31(ogg_int32_t a, ogg_int32_t b, 58static inline void XPROD31(ogg_int32_t a, ogg_int32_t b,
59 ogg_int32_t t, ogg_int32_t v, 59 ogg_int32_t t, ogg_int32_t v,
60 ogg_int32_t *x, ogg_int32_t *y) 60 ogg_int32_t *x, ogg_int32_t *y)
61{ 61{
62 int x1, y1, l; 62 int x1, y1, l;
63 asm( "smull %0, %1, %4, %6\n\t" 63 asm( "smull %0, %1, %4, %6\n\t"
64 "rsb %3, %4, #0\n\t" 64 "rsb %3, %4, #0\n\t"
65 "smlal %0, %1, %5, %7\n\t" 65 "smlal %0, %1, %5, %7\n\t"
66 "smull %0, %2, %5, %6\n\t" 66 "smull %0, %2, %5, %6\n\t"
67 "smlal %0, %2, %3, %7" 67 "smlal %0, %2, %3, %7"
68 : "=&r" (l), "=&r" (x1), "=&r" (y1), "=r" (a) 68 : "=&r" (l), "=&r" (x1), "=&r" (y1), "=r" (a)
69 : "3" (a), "r" (b), "r" (t), "r" (v) ); 69 : "3" (a), "r" (b), "r" (t), "r" (v) );
70 *x = x1 << 1; 70 *x = x1 << 1;
71 *y = y1 << 1; 71 *y = y1 << 1;
72} 72}
73 73
74static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b, 74static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b,
75 ogg_int32_t t, ogg_int32_t v, 75 ogg_int32_t t, ogg_int32_t v,
76 ogg_int32_t *x, ogg_int32_t *y) 76 ogg_int32_t *x, ogg_int32_t *y)
77{ 77{
78 int x1, y1, l; 78 int x1, y1, l;
79 asm( "smull %0, %1, %3, %5\n\t" 79 asm( "smull %0, %1, %3, %5\n\t"
80 "rsb %2, %4, #0\n\t" 80 "rsb %2, %4, #0\n\t"
81 "smlal %0, %1, %2, %6\n\t" 81 "smlal %0, %1, %2, %6\n\t"
82 "smull %0, %2, %4, %5\n\t" 82 "smull %0, %2, %4, %5\n\t"
83 "smlal %0, %2, %3, %6" 83 "smlal %0, %2, %3, %6"
84 : "=&r" (l), "=&r" (x1), "=&r" (y1) 84 : "=&r" (l), "=&r" (x1), "=&r" (y1)
85 : "r" (a), "r" (b), "r" (t), "r" (v) ); 85 : "r" (a), "r" (b), "r" (t), "r" (v) );
86 *x = x1 << 1; 86 *x = x1 << 1;
87 *y = y1 << 1; 87 *y = y1 << 1;
88} 88}
@@ -217,13 +217,13 @@ static inline void vect_copy(ogg_int32_t *x, const ogg_int32_t *y, int n)
217static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) { 217static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
218 int tmp; 218 int tmp;
219 asm volatile("subs %1, %0, #32768\n\t" 219 asm volatile("subs %1, %0, #32768\n\t"
220 "movpl %0, #0x7f00\n\t" 220 "movpl %0, #0x7f00\n\t"
221 "orrpl %0, %0, #0xff\n" 221 "orrpl %0, %0, #0xff\n"
222 "adds %1, %0, #32768\n\t" 222 "adds %1, %0, #32768\n\t"
223 "movmi %0, #0x8000" 223 "movmi %0, #0x8000"
224 : "+r"(x),"=r"(tmp) 224 : "+r"(x),"=r"(tmp)
225 : 225 :
226 : "cc"); 226 : "cc");
227 return(x); 227 return(x);
228} 228}
229 229
@@ -233,9 +233,9 @@ static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
233#define _V_LSP_MATH_ASM 233#define _V_LSP_MATH_ASM
234 234
235static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip, 235static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip,
236 ogg_int32_t *qexpp, 236 ogg_int32_t *qexpp,
237 ogg_int32_t *ilsp,ogg_int32_t wi, 237 ogg_int32_t *ilsp,ogg_int32_t wi,
238 ogg_int32_t m){ 238 ogg_int32_t m){
239 239
240 ogg_uint32_t qi=*qip,pi=*pip; 240 ogg_uint32_t qi=*qip,pi=*pip;
241 ogg_int32_t qexp=*qexpp; 241 ogg_int32_t qexp=*qexpp;
@@ -289,9 +289,9 @@ static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip,
289 //qi=(pi>>shift)*labs(ilsp[j]-wi); 289 //qi=(pi>>shift)*labs(ilsp[j]-wi);
290 //pi=(qi>>shift)*labs(ilsp[j+1]-wi); 290 //pi=(qi>>shift)*labs(ilsp[j+1]-wi);
291 //qexp+=shift; 291 //qexp+=shift;
292 292
293 //} 293 //}
294 294
295 /* normalize to max 16 sig figs */ 295 /* normalize to max 16 sig figs */
296 "2:" 296 "2:"
297 "mov r2,#0;" 297 "mov r2,#0;"
diff --git a/apps/codecs/libtremor/backends.h b/apps/codecs/libtremor/backends.h
index 677bc8fdc2..29ab935993 100644
--- a/apps/codecs/libtremor/backends.h
+++ b/apps/codecs/libtremor/backends.h
@@ -34,12 +34,12 @@
34typedef struct{ 34typedef struct{
35 vorbis_info_floor *(*unpack)(vorbis_info *,oggpack_buffer *); 35 vorbis_info_floor *(*unpack)(vorbis_info *,oggpack_buffer *);
36 vorbis_look_floor *(*look) (vorbis_dsp_state *,vorbis_info_mode *, 36 vorbis_look_floor *(*look) (vorbis_dsp_state *,vorbis_info_mode *,
37 vorbis_info_floor *); 37 vorbis_info_floor *);
38 void (*free_info) (vorbis_info_floor *); 38 void (*free_info) (vorbis_info_floor *);
39 void (*free_look) (vorbis_look_floor *); 39 void (*free_look) (vorbis_look_floor *);
40 void *(*inverse1) (struct vorbis_block *,vorbis_look_floor *); 40 void *(*inverse1) (struct vorbis_block *,vorbis_look_floor *);
41 int (*inverse2) (struct vorbis_block *,vorbis_look_floor *, 41 int (*inverse2) (struct vorbis_block *,vorbis_look_floor *,
42 void *buffer,ogg_int32_t *); 42 void *buffer,ogg_int32_t *);
43} vorbis_func_floor; 43} vorbis_func_floor;
44 44
45typedef struct{ 45typedef struct{
@@ -77,11 +77,11 @@ typedef struct{
77typedef struct{ 77typedef struct{
78 vorbis_info_residue *(*unpack)(vorbis_info *,oggpack_buffer *); 78 vorbis_info_residue *(*unpack)(vorbis_info *,oggpack_buffer *);
79 vorbis_look_residue *(*look) (vorbis_dsp_state *,vorbis_info_mode *, 79 vorbis_look_residue *(*look) (vorbis_dsp_state *,vorbis_info_mode *,
80 vorbis_info_residue *); 80 vorbis_info_residue *);
81 void (*free_info) (vorbis_info_residue *); 81 void (*free_info) (vorbis_info_residue *);
82 void (*free_look) (vorbis_look_residue *); 82 void (*free_look) (vorbis_look_residue *);
83 int (*inverse) (struct vorbis_block *,vorbis_look_residue *, 83 int (*inverse) (struct vorbis_block *,vorbis_look_residue *,
84 ogg_int32_t **,int *,int); 84 ogg_int32_t **,int *,int);
85} vorbis_func_residue; 85} vorbis_func_residue;
86 86
87typedef struct vorbis_info_residue0{ 87typedef struct vorbis_info_residue0{
@@ -101,7 +101,7 @@ typedef struct vorbis_info_residue0{
101typedef struct{ 101typedef struct{
102 vorbis_info_mapping *(*unpack)(vorbis_info *,oggpack_buffer *); 102 vorbis_info_mapping *(*unpack)(vorbis_info *,oggpack_buffer *);
103 vorbis_look_mapping *(*look) (vorbis_dsp_state *,vorbis_info_mode *, 103 vorbis_look_mapping *(*look) (vorbis_dsp_state *,vorbis_info_mode *,
104 vorbis_info_mapping *); 104 vorbis_info_mapping *);
105 void (*free_info) (vorbis_info_mapping *); 105 void (*free_info) (vorbis_info_mapping *);
106 void (*free_look) (vorbis_look_mapping *); 106 void (*free_look) (vorbis_look_mapping *);
107 int (*inverse) (struct vorbis_block *vb,vorbis_look_mapping *); 107 int (*inverse) (struct vorbis_block *vb,vorbis_look_mapping *);
diff --git a/apps/codecs/libtremor/codebook.c b/apps/codecs/libtremor/codebook.c
index 6ed6a08672..8d34b6df03 100644
--- a/apps/codecs/libtremor/codebook.c
+++ b/apps/codecs/libtremor/codebook.c
@@ -49,19 +49,19 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
49 /* yes, unused entries */ 49 /* yes, unused entries */
50 50
51 for(i=0;i<s->entries;i++){ 51 for(i=0;i<s->entries;i++){
52 if(oggpack_read(opb,1)){ 52 if(oggpack_read(opb,1)){
53 long num=oggpack_read(opb,5); 53 long num=oggpack_read(opb,5);
54 if(num==-1)goto _eofout; 54 if(num==-1)goto _eofout;
55 s->lengthlist[i]=num+1; 55 s->lengthlist[i]=num+1;
56 }else 56 }else
57 s->lengthlist[i]=0; 57 s->lengthlist[i]=0;
58 } 58 }
59 }else{ 59 }else{
60 /* all entries used; no tagging */ 60 /* all entries used; no tagging */
61 for(i=0;i<s->entries;i++){ 61 for(i=0;i<s->entries;i++){
62 long num=oggpack_read(opb,5); 62 long num=oggpack_read(opb,5);
63 if(num==-1)goto _eofout; 63 if(num==-1)goto _eofout;
64 s->lengthlist[i]=num+1; 64 s->lengthlist[i]=num+1;
65 } 65 }
66 } 66 }
67 67
@@ -73,11 +73,11 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
73 s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries); 73 s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries);
74 74
75 for(i=0;i<s->entries;){ 75 for(i=0;i<s->entries;){
76 long num=oggpack_read(opb,_ilog(s->entries-i)); 76 long num=oggpack_read(opb,_ilog(s->entries-i));
77 if(num==-1)goto _eofout; 77 if(num==-1)goto _eofout;
78 for(j=0;j<num && i<s->entries;j++,i++) 78 for(j=0;j<num && i<s->entries;j++,i++)
79 s->lengthlist[i]=length; 79 s->lengthlist[i]=length;
80 length++; 80 length++;
81 } 81 }
82 } 82 }
83 break; 83 break;
@@ -104,17 +104,17 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
104 int quantvals=0; 104 int quantvals=0;
105 switch(s->maptype){ 105 switch(s->maptype){
106 case 1: 106 case 1:
107 quantvals=_book_maptype1_quantvals(s); 107 quantvals=_book_maptype1_quantvals(s);
108 break; 108 break;
109 case 2: 109 case 2:
110 quantvals=s->entries*s->dim; 110 quantvals=s->entries*s->dim;
111 break; 111 break;
112 } 112 }
113 113
114 /* quantized values */ 114 /* quantized values */
115 s->quantlist=(long *)_ogg_malloc(sizeof(*s->quantlist)*quantvals); 115 s->quantlist=(long *)_ogg_malloc(sizeof(*s->quantlist)*quantvals);
116 for(i=0;i<quantvals;i++) 116 for(i=0;i<quantvals;i++)
117 s->quantlist[i]=oggpack_read(opb,s->q_quant); 117 s->quantlist[i]=oggpack_read(opb,s->q_quant);
118 118
119 if(quantvals&&s->quantlist[quantvals-1]==-1)goto _eofout; 119 if(quantvals&&s->quantlist[quantvals-1]==-1)goto _eofout;
120 } 120 }
@@ -216,7 +216,7 @@ static inline ogg_uint32_t bitreverse(register ogg_uint32_t x)
216} 216}
217 217
218STIN long decode_packed_entry_number(codebook *book, 218STIN long decode_packed_entry_number(codebook *book,
219 oggpack_buffer *b){ 219 oggpack_buffer *b){
220 int read=book->dec_maxlength; 220 int read=book->dec_maxlength;
221 long lo,hi; 221 long lo,hi;
222 long lok = oggpack_look(b,book->dec_firsttablen); 222 long lok = oggpack_look(b,book->dec_firsttablen);
@@ -284,43 +284,39 @@ static long decode_packed_block(codebook *book, oggpack_buffer *b,
284 ptr = (ogg_uint32_t *)(adr&~3); 284 ptr = (ogg_uint32_t *)(adr&~3);
285 bitend = ((adr&3)+b->headend)*8; 285 bitend = ((adr&3)+b->headend)*8;
286 while (bufptr<bufend){ 286 while (bufptr<bufend){
287 long entry, lo, hi; 287 long entry, lo, hi;
288 if (UNLIKELY(cachesize<book->dec_maxlength)) { 288 if (UNLIKELY(cachesize<book->dec_maxlength)) {
289 if (bit-cachesize+32>=bitend) 289 if (bit-cachesize+32>=bitend)
290 break; 290 break;
291 bit-=cachesize; 291 bit-=cachesize;
292 cache=letoh32(ptr[bit>>5]) >> (bit&31); 292 cache=letoh32(ptr[bit>>5]) >> (bit&31);
293 if (bit&31) 293 if (bit&31)
294 cache|=letoh32(ptr[(bit>>5)+1]) << (32-(bit&31)); 294 cache|=letoh32(ptr[(bit>>5)+1]) << (32-(bit&31));
295 cachesize=32; 295 cachesize=32;
296 bit+=32; 296 bit+=32;
297 } 297 }
298 298
299 entry=book->dec_firsttable[cache&((1<<book->dec_firsttablen)-1)]; 299 entry=book->dec_firsttable[cache&((1<<book->dec_firsttablen)-1)];
300 if(UNLIKELY(entry&0x80000000UL)){ 300 if(UNLIKELY(entry&0x80000000UL)){
301 lo=(entry>>15)&0x7fff; 301 lo=(entry>>15)&0x7fff;
302 hi=book->used_entries-(entry&0x7fff); 302 hi=book->used_entries-(entry&0x7fff);
303 { 303 ogg_uint32_t testword=bitreverse((ogg_uint32_t)cache);
304 ogg_uint32_t testword=bitreverse((ogg_uint32_t)cache); 304
305 305 while(LIKELY(hi-lo>1)){
306 while(LIKELY(hi-lo>1)){ 306 long p=(hi-lo)>>1;
307 long p=(hi-lo)>>1; 307 if (book->codelist[lo+p]>testword)
308 if (book->codelist[lo+p]>testword) 308 hi-=p;
309 hi-=p; 309 else
310 else 310 lo+=p;
311 lo+=p;
312 }
313 entry=lo;
314 } 311 }
315 }else 312 entry=lo;
316 entry--; 313 }else
317 314 entry--;
318 *bufptr++=entry; 315
319 { 316 *bufptr++=entry;
320 int l=book->dec_codelengths[entry]; 317 int l=book->dec_codelengths[entry];
321 cachesize-=l; 318 cachesize-=l;
322 cache>>=l; 319 cache>>=l;
323 }
324 } 320 }
325 321
326 adr=(unsigned long)b->headptr; 322 adr=(unsigned long)b->headptr;
@@ -366,7 +362,7 @@ long vorbis_book_decode(codebook *book, oggpack_buffer *b){
366 362
367/* returns 0 on OK or -1 on eof *************************************/ 363/* returns 0 on OK or -1 on eof *************************************/
368long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a, 364long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a,
369 oggpack_buffer *b,int n,int point){ 365 oggpack_buffer *b,int n,int point){
370 if(book->used_entries>0){ 366 if(book->used_entries>0){
371 int step=n/book->dim; 367 int step=n/book->dim;
372 long *entry = (long *)alloca(sizeof(*entry)*step); 368 long *entry = (long *)alloca(sizeof(*entry)*step);
@@ -376,29 +372,29 @@ long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a,
376 372
377 if(shift>=0){ 373 if(shift>=0){
378 for (i = 0; i < step; i++) { 374 for (i = 0; i < step; i++) {
379 entry[i]=decode_packed_entry_number(book,b); 375 entry[i]=decode_packed_entry_number(book,b);
380 if(entry[i]==-1)return(-1); 376 if(entry[i]==-1)return(-1);
381 t[i] = book->valuelist+entry[i]*book->dim; 377 t[i] = book->valuelist+entry[i]*book->dim;
382 } 378 }
383 for(i=0,o=0;i<book->dim;i++,o+=step) 379 for(i=0,o=0;i<book->dim;i++,o+=step)
384 for (j=0;j<step;j++) 380 for (j=0;j<step;j++)
385 a[o+j]+=t[j][i]>>shift; 381 a[o+j]+=t[j][i]>>shift;
386 }else{ 382 }else{
387 for (i = 0; i < step; i++) { 383 for (i = 0; i < step; i++) {
388 entry[i]=decode_packed_entry_number(book,b); 384 entry[i]=decode_packed_entry_number(book,b);
389 if(entry[i]==-1)return(-1); 385 if(entry[i]==-1)return(-1);
390 t[i] = book->valuelist+entry[i]*book->dim; 386 t[i] = book->valuelist+entry[i]*book->dim;
391 } 387 }
392 for(i=0,o=0;i<book->dim;i++,o+=step) 388 for(i=0,o=0;i<book->dim;i++,o+=step)
393 for (j=0;j<step;j++) 389 for (j=0;j<step;j++)
394 a[o+j]+=t[j][i]<<-shift; 390 a[o+j]+=t[j][i]<<-shift;
395 } 391 }
396 } 392 }
397 return(0); 393 return(0);
398} 394}
399 395
400long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a, 396long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a,
401 oggpack_buffer *b,int n,int point){ 397 oggpack_buffer *b,int n,int point){
402 if(book->used_entries>0){ 398 if(book->used_entries>0){
403 int i,j,entry; 399 int i,j,entry;
404 ogg_int32_t *t; 400 ogg_int32_t *t;
@@ -406,20 +402,20 @@ long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a,
406 402
407 if(shift>=0){ 403 if(shift>=0){
408 for(i=0;i<n;){ 404 for(i=0;i<n;){
409 entry = decode_packed_entry_number(book,b); 405 entry = decode_packed_entry_number(book,b);
410 if(entry==-1)return(-1); 406 if(entry==-1)return(-1);
411 t = book->valuelist+entry*book->dim; 407 t = book->valuelist+entry*book->dim;
412 for (j=0;j<book->dim;) 408 for (j=0;j<book->dim;)
413 a[i++]+=t[j++]>>shift; 409 a[i++]+=t[j++]>>shift;
414 } 410 }
415 }else{ 411 }else{
416 shift = -shift; 412 shift = -shift;
417 for(i=0;i<n;){ 413 for(i=0;i<n;){
418 entry = decode_packed_entry_number(book,b); 414 entry = decode_packed_entry_number(book,b);
419 if(entry==-1)return(-1); 415 if(entry==-1)return(-1);
420 t = book->valuelist+entry*book->dim; 416 t = book->valuelist+entry*book->dim;
421 for (j=0;j<book->dim;) 417 for (j=0;j<book->dim;)
422 a[i++]+=t[j++]<<shift; 418 a[i++]+=t[j++]<<shift;
423 } 419 }
424 } 420 }
425 } 421 }
@@ -427,7 +423,7 @@ long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a,
427} 423}
428 424
429long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a, 425long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a,
430 oggpack_buffer *b,int n,int point){ 426 oggpack_buffer *b,int n,int point){
431 if(book->used_entries>0){ 427 if(book->used_entries>0){
432 int i,j,entry; 428 int i,j,entry;
433 ogg_int32_t *t; 429 ogg_int32_t *t;
@@ -436,22 +432,22 @@ long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a,
436 if(shift>=0){ 432 if(shift>=0){
437 433
438 for(i=0;i<n;){ 434 for(i=0;i<n;){
439 entry = decode_packed_entry_number(book,b); 435 entry = decode_packed_entry_number(book,b);
440 if(entry==-1)return(-1); 436 if(entry==-1)return(-1);
441 t = book->valuelist+entry*book->dim; 437 t = book->valuelist+entry*book->dim;
442 for (j=0;j<book->dim;){ 438 for (j=0;j<book->dim;){
443 a[i++]=t[j++]>>shift; 439 a[i++]=t[j++]>>shift;
444 } 440 }
445 } 441 }
446 }else{ 442 }else{
447 shift = -shift; 443 shift = -shift;
448 for(i=0;i<n;){ 444 for(i=0;i<n;){
449 entry = decode_packed_entry_number(book,b); 445 entry = decode_packed_entry_number(book,b);
450 if(entry==-1)return(-1); 446 if(entry==-1)return(-1);
451 t = book->valuelist+entry*book->dim; 447 t = book->valuelist+entry*book->dim;
452 for (j=0;j<book->dim;){ 448 for (j=0;j<book->dim;){
453 a[i++]=t[j++]<<shift; 449 a[i++]=t[j++]<<shift;
454 } 450 }
455 } 451 }
456 } 452 }
457 }else{ 453 }else{
@@ -459,7 +455,7 @@ long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a,
459 int i,j; 455 int i,j;
460 for(i=0;i<n;){ 456 for(i=0;i<n;){
461 for (j=0;j<book->dim;){ 457 for (j=0;j<book->dim;){
462 a[i++]=0; 458 a[i++]=0;
463 } 459 }
464 } 460 }
465 } 461 }
@@ -516,8 +512,8 @@ static long vorbis_book_decodevv_add_2ch_even(codebook *book,ogg_int32_t **a,
516} 512}
517 513
518long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a, 514long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,
519 long offset,int ch, 515 long offset,int ch,
520 oggpack_buffer *b,int n,int point){ 516 oggpack_buffer *b,int n,int point){
521 if(LIKELY(book->used_entries>0)){ 517 if(LIKELY(book->used_entries>0)){
522 long i,j,k,chunk,read; 518 long i,j,k,chunk,read;
523 int chptr=0; 519 int chptr=0;
@@ -535,14 +531,14 @@ long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,
535 chunk=((offset+n-i)*ch+book->dim-1)/book->dim; 531 chunk=((offset+n-i)*ch+book->dim-1)/book->dim;
536 read = decode_packed_block(book,b,entries,chunk); 532 read = decode_packed_block(book,b,entries,chunk);
537 for(k=0;k<read;k++){ 533 for(k=0;k<read;k++){
538 const ogg_int32_t *t = book->valuelist+entries[k]*book->dim; 534 const ogg_int32_t *t = book->valuelist+entries[k]*book->dim;
539 for (j=0;j<book->dim;j++){ 535 for (j=0;j<book->dim;j++){
540 a[chptr++][i]+=t[j]>>shift; 536 a[chptr++][i]+=t[j]>>shift;
541 if(chptr==ch){ 537 if(chptr==ch){
542 chptr=0; 538 chptr=0;
543 i++; 539 i++;
544 } 540 }
545 } 541 }
546 } 542 }
547 if (read<chunk)return-1; 543 if (read<chunk)return-1;
548 } 544 }
@@ -554,14 +550,14 @@ long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,
554 chunk=((offset+n-i)*ch+book->dim-1)/book->dim; 550 chunk=((offset+n-i)*ch+book->dim-1)/book->dim;
555 read = decode_packed_block(book,b,entries,chunk); 551 read = decode_packed_block(book,b,entries,chunk);
556 for(k=0;k<read;k++){ 552 for(k=0;k<read;k++){
557 const ogg_int32_t *t = book->valuelist+entries[k]*book->dim; 553 const ogg_int32_t *t = book->valuelist+entries[k]*book->dim;
558 for (j=0;j<book->dim;j++){ 554 for (j=0;j<book->dim;j++){
559 a[chptr++][i]+=t[j]<<shift; 555 a[chptr++][i]+=t[j]<<shift;
560 if(chptr==ch){ 556 if(chptr==ch){
561 chptr=0; 557 chptr=0;
562 i++; 558 i++;
563 } 559 }
564 } 560 }
565 } 561 }
566 if (read<chunk)return-1; 562 if (read<chunk)return-1;
567 } 563 }
diff --git a/apps/codecs/libtremor/codebook.h b/apps/codecs/libtremor/codebook.h
index 0fc6834daa..b13334d8d7 100644
--- a/apps/codecs/libtremor/codebook.h
+++ b/apps/codecs/libtremor/codebook.h
@@ -40,8 +40,8 @@ typedef struct static_codebook{
40 40
41 /* mapping ***************************************************************/ 41 /* mapping ***************************************************************/
42 int maptype; /* 0=none 42 int maptype; /* 0=none
43 1=implicitly populated values from map column 43 1=implicitly populated values from map column
44 2=listed arbitrary values */ 44 2=listed arbitrary values */
45 45
46 /* The below does a linear, single monotonic sequence mapping. */ 46 /* The below does a linear, single monotonic sequence mapping. */
47 long q_min; /* packed 32 bit float; quant value 0 maps to minval */ 47 long q_min; /* packed 32 bit float; quant value 0 maps to minval */
@@ -50,8 +50,8 @@ typedef struct static_codebook{
50 int q_sequencep; /* bitflag */ 50 int q_sequencep; /* bitflag */
51 51
52 long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map 52 long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map
53 map == 2: list of dim*entries quantized entry vals 53 map == 2: list of dim*entries quantized entry vals
54 */ 54 */
55} static_codebook; 55} static_codebook;
56 56
57typedef struct codebook{ 57typedef struct codebook{
@@ -87,14 +87,14 @@ extern int vorbis_staticbook_unpack(oggpack_buffer *b,static_codebook *c);
87 87
88extern long vorbis_book_decode(codebook *book, oggpack_buffer *b); 88extern long vorbis_book_decode(codebook *book, oggpack_buffer *b);
89extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a, 89extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a,
90 oggpack_buffer *b,int n,int point); 90 oggpack_buffer *b,int n,int point);
91extern long vorbis_book_decodev_set(codebook *book, ogg_int32_t *a, 91extern long vorbis_book_decodev_set(codebook *book, ogg_int32_t *a,
92 oggpack_buffer *b,int n,int point); 92 oggpack_buffer *b,int n,int point);
93extern long vorbis_book_decodev_add(codebook *book, ogg_int32_t *a, 93extern long vorbis_book_decodev_add(codebook *book, ogg_int32_t *a,
94 oggpack_buffer *b,int n,int point); 94 oggpack_buffer *b,int n,int point);
95extern long vorbis_book_decodevv_add(codebook *book, ogg_int32_t **a, 95extern long vorbis_book_decodevv_add(codebook *book, ogg_int32_t **a,
96 long off,int ch, 96 long off,int ch,
97 oggpack_buffer *b,int n,int point); 97 oggpack_buffer *b,int n,int point);
98 98
99extern int _ilog(unsigned int v); 99extern int _ilog(unsigned int v);
100 100
diff --git a/apps/codecs/libtremor/floor0.c b/apps/codecs/libtremor/floor0.c
index 9c890e6bad..5062450748 100644
--- a/apps/codecs/libtremor/floor0.c
+++ b/apps/codecs/libtremor/floor0.c
@@ -74,7 +74,7 @@ static inline ogg_int32_t vorbis_coslook_i(long a){
74 int i=a>>COS_LOOKUP_I_SHIFT; 74 int i=a>>COS_LOOKUP_I_SHIFT;
75 int d=a&COS_LOOKUP_I_MASK; 75 int d=a&COS_LOOKUP_I_MASK;
76 return COS_LOOKUP_I[i]- ((d*(COS_LOOKUP_I[i]-COS_LOOKUP_I[i+1]))>> 76 return COS_LOOKUP_I[i]- ((d*(COS_LOOKUP_I[i]-COS_LOOKUP_I[i+1]))>>
77 COS_LOOKUP_I_SHIFT); 77 COS_LOOKUP_I_SHIFT);
78} 78}
79 79
80/* interpolated lookup based cos function */ 80/* interpolated lookup based cos function */
@@ -181,7 +181,7 @@ static void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
181 qi=((qi*qi)>>16); 181 qi=((qi*qi)>>16);
182 182
183 if(m&1){ 183 if(m&1){
184 qexp= qexp*2-28*((m+1)>>1)+m; 184 qexp= qexp*2-28*((m+1)>>1)+m;
185 pi*=(1<<14)-((wi*wi)>>14); 185 pi*=(1<<14)-((wi*wi)>>14);
186 qi+=pi>>14; 186 qi+=pi>>14;
187 }else{ 187 }else{
@@ -205,15 +205,15 @@ static void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
205 205
206 for(j=3;j<m;j+=2){ 206 for(j=3;j<m;j+=2){
207 if(!(shift=MLOOP_1[(pi|qi)>>25])) 207 if(!(shift=MLOOP_1[(pi|qi)>>25]))
208 if(!(shift=MLOOP_2[(pi|qi)>>19])) 208 if(!(shift=MLOOP_2[(pi|qi)>>19]))
209 shift=MLOOP_3[(pi|qi)>>16]; 209 shift=MLOOP_3[(pi|qi)>>16];
210 qi=(qi>>shift)*labs(ilsp[j-1]-wi); 210 qi=(qi>>shift)*labs(ilsp[j-1]-wi);
211 pi=(pi>>shift)*labs(ilsp[j]-wi); 211 pi=(pi>>shift)*labs(ilsp[j]-wi);
212 qexp+=shift; 212 qexp+=shift;
213 } 213 }
214 if(!(shift=MLOOP_1[(pi|qi)>>25])) 214 if(!(shift=MLOOP_1[(pi|qi)>>25]))
215 if(!(shift=MLOOP_2[(pi|qi)>>19])) 215 if(!(shift=MLOOP_2[(pi|qi)>>19]))
216 shift=MLOOP_3[(pi|qi)>>16]; 216 shift=MLOOP_3[(pi|qi)>>16];
217 217
218 /* pi,qi normalized collectively, both tracked using qexp */ 218 /* pi,qi normalized collectively, both tracked using qexp */
219 219
@@ -225,8 +225,8 @@ static void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
225 qexp+=shift; 225 qexp+=shift;
226 226
227 if(!(shift=MLOOP_1[(pi|qi)>>25])) 227 if(!(shift=MLOOP_1[(pi|qi)>>25]))
228 if(!(shift=MLOOP_2[(pi|qi)>>19])) 228 if(!(shift=MLOOP_2[(pi|qi)>>19]))
229 shift=MLOOP_3[(pi|qi)>>16]; 229 shift=MLOOP_3[(pi|qi)>>16];
230 230
231 pi>>=shift; 231 pi>>=shift;
232 qi>>=shift; 232 qi>>=shift;
@@ -243,7 +243,7 @@ static void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
243 /* even order filter; still symmetric */ 243 /* even order filter; still symmetric */
244 244
245 /* p*=p(1-w), q*=q(1+w), let normalization drift because it isn't 245 /* p*=p(1-w), q*=q(1+w), let normalization drift because it isn't
246 worth tracking step by step */ 246 worth tracking step by step */
247 247
248 pi>>=shift; 248 pi>>=shift;
249 qi>>=shift; 249 qi>>=shift;
@@ -268,15 +268,15 @@ static void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
268 qi>>=1; qexp++; 268 qi>>=1; qexp++;
269 }else 269 }else
270 while(qi && !(qi&0x8000)){ /* checks for 0.0xxxxxxxxxxxxxxx or less*/ 270 while(qi && !(qi&0x8000)){ /* checks for 0.0xxxxxxxxxxxxxxx or less*/
271 qi<<=1; qexp--; 271 qi<<=1; qexp--;
272 } 272 }
273 273
274#endif 274#endif
275 275
276 amp=vorbis_fromdBlook_i(ampi* /* n.4 */ 276 amp=vorbis_fromdBlook_i(ampi* /* n.4 */
277 vorbis_invsqlook_i(qi,qexp)- 277 vorbis_invsqlook_i(qi,qexp)-
278 /* m.8, m+n<=8 */ 278 /* m.8, m+n<=8 */
279 ampoffseti); /* 8.12[0] */ 279 ampoffseti); /* 8.12[0] */
280 280
281#ifdef _LOW_ACCURACY_ 281#ifdef _LOW_ACCURACY_
282 amp>>=9; 282 amp>>=9;
@@ -366,7 +366,7 @@ static vorbis_look_floor *floor0_look (vorbis_dsp_state *vd,vorbis_info_mode *mi
366 for(j=0;j<look->n;j++){ 366 for(j=0;j<look->n;j++){
367 367
368 int val=(look->ln* 368 int val=(look->ln*
369 ((toBARK(info->rate/2*j/look->n)<<11)/toBARK(info->rate/2)))>>11; 369 ((toBARK(info->rate/2*j/look->n)<<11)/toBARK(info->rate/2)))>>11;
370 370
371 if(val>=look->ln)val=look->ln-1; /* guard against the approximation */ 371 if(val>=look->ln)val=look->ln-1; /* guard against the approximation */
372 look->linearmap[j]=val; 372 look->linearmap[j]=val;
@@ -398,10 +398,10 @@ static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){
398 ogg_int32_t *lsp=(ogg_int32_t *)_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+1)); 398 ogg_int32_t *lsp=(ogg_int32_t *)_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+1));
399 399
400 for(j=0;j<look->m;j+=b->dim) 400 for(j=0;j<look->m;j+=b->dim)
401 if(vorbis_book_decodev_set(b,lsp+j,&vb->opb,b->dim,-24)==-1)goto eop; 401 if(vorbis_book_decodev_set(b,lsp+j,&vb->opb,b->dim,-24)==-1)goto eop;
402 for(j=0;j<look->m;){ 402 for(j=0;j<look->m;){
403 for(k=0;k<b->dim;k++,j++)lsp[j]+=last; 403 for(k=0;k<b->dim;k++,j++)lsp[j]+=last;
404 last=lsp[j-1]; 404 last=lsp[j-1];
405 } 405 }
406 406
407 lsp[look->m]=amp; 407 lsp[look->m]=amp;
@@ -413,7 +413,7 @@ static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){
413} 413}
414 414
415static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i, 415static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i,
416 void *memo,ogg_int32_t *out){ 416 void *memo,ogg_int32_t *out){
417 vorbis_look_floor0 *look=(vorbis_look_floor0 *)i; 417 vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
418 vorbis_info_floor0 *info=look->vi; 418 vorbis_info_floor0 *info=look->vi;
419 (void)vb; 419 (void)vb;
@@ -424,7 +424,7 @@ static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i,
424 424
425 /* take the coefficients back to a spectral envelope curve */ 425 /* take the coefficients back to a spectral envelope curve */
426 vorbis_lsp_to_curve(out,look->linearmap,look->n,look->ln, 426 vorbis_lsp_to_curve(out,look->linearmap,look->n,look->ln,
427 lsp,look->m,amp,info->ampdB,look->lsp_look); 427 lsp,look->m,amp,info->ampdB,look->lsp_look);
428 return(1); 428 return(1);
429 } 429 }
430 memset(out,0,sizeof(*out)*look->n); 430 memset(out,0,sizeof(*out)*look->n);
diff --git a/apps/codecs/libtremor/framing.c b/apps/codecs/libtremor/framing.c
index 0b08167da8..ac95831d5d 100644
--- a/apps/codecs/libtremor/framing.c
+++ b/apps/codecs/libtremor/framing.c
@@ -1003,11 +1003,11 @@ STATICIRAM_NOT_MDCT int _packetout(ogg_stream_state *os,ogg_packet *op,int adv){
1003 /* split the body contents off */ 1003 /* split the body contents off */
1004 if(op){ 1004 if(op){
1005 op->packet=ogg_buffer_split(&os->body_tail,&os->body_head, 1005 op->packet=ogg_buffer_split(&os->body_tail,&os->body_head,
1006 os->body_fill&FINMASK); 1006 os->body_fill&FINMASK);
1007 op->bytes=os->body_fill&FINMASK; 1007 op->bytes=os->body_fill&FINMASK;
1008 }else{ 1008 }else{
1009 os->body_tail=ogg_buffer_pretruncate(os->body_tail, 1009 os->body_tail=ogg_buffer_pretruncate(os->body_tail,
1010 os->body_fill&FINMASK); 1010 os->body_fill&FINMASK);
1011 if(os->body_tail==0)os->body_head=0; 1011 if(os->body_tail==0)os->body_head=0;
1012 } 1012 }
1013 1013
diff --git a/apps/codecs/libtremor/info.c b/apps/codecs/libtremor/info.c
index 935fa03269..9bfa7d03b0 100644
--- a/apps/codecs/libtremor/info.c
+++ b/apps/codecs/libtremor/info.c
@@ -47,7 +47,7 @@ void vorbis_comment_clear(vorbis_comment *vc){
47 for(i=0;i<vc->comments;i++) 47 for(i=0;i<vc->comments;i++)
48 if(vc->user_comments[i])_ogg_free(vc->user_comments[i]); 48 if(vc->user_comments[i])_ogg_free(vc->user_comments[i]);
49 if(vc->user_comments)_ogg_free(vc->user_comments); 49 if(vc->user_comments)_ogg_free(vc->user_comments);
50 if(vc->comment_lengths)_ogg_free(vc->comment_lengths); 50 if(vc->comment_lengths)_ogg_free(vc->comment_lengths);
51 if(vc->vendor)_ogg_free(vc->vendor); 51 if(vc->vendor)_ogg_free(vc->vendor);
52 memset(vc,0,sizeof(*vc)); 52 memset(vc,0,sizeof(*vc));
53 } 53 }
@@ -77,26 +77,26 @@ void vorbis_info_clear(vorbis_info *vi){
77 77
78 for(i=0;i<ci->maps;i++) /* unpack does the range checking */ 78 for(i=0;i<ci->maps;i++) /* unpack does the range checking */
79 if(ci->map_param[i]) 79 if(ci->map_param[i])
80 _mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]); 80 _mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]);
81 81
82 for(i=0;i<ci->floors;i++) /* unpack does the range checking */ 82 for(i=0;i<ci->floors;i++) /* unpack does the range checking */
83 if(ci->floor_param[i]) 83 if(ci->floor_param[i])
84 _floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]); 84 _floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]);
85 85
86 for(i=0;i<ci->residues;i++) /* unpack does the range checking */ 86 for(i=0;i<ci->residues;i++) /* unpack does the range checking */
87 if(ci->residue_param[i]) 87 if(ci->residue_param[i])
88 _residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]); 88 _residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]);
89 89
90 for(i=0;i<ci->books;i++){ 90 for(i=0;i<ci->books;i++){
91 if(ci->book_param[i]){ 91 if(ci->book_param[i]){
92 /* knows if the book was not alloced */ 92 /* knows if the book was not alloced */
93 vorbis_staticbook_destroy(ci->book_param[i]); 93 vorbis_staticbook_destroy(ci->book_param[i]);
94 } 94 }
95 if(ci->fullbooks) 95 if(ci->fullbooks)
96 vorbis_book_clear(ci->fullbooks+i); 96 vorbis_book_clear(ci->fullbooks+i);
97 } 97 }
98 if(ci->fullbooks) 98 if(ci->fullbooks)
99 _ogg_free(ci->fullbooks); 99 _ogg_free(ci->fullbooks);
100 100
101 _ogg_free(ci); 101 _ogg_free(ci);
102 } 102 }
@@ -278,42 +278,42 @@ int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,ogg_packet *op)
278 memset(buffer,0,6); 278 memset(buffer,0,6);
279 _v_readstring(&opb,buffer,6); 279 _v_readstring(&opb,buffer,6);
280 if(memcmp(buffer,"vorbis",6)){ 280 if(memcmp(buffer,"vorbis",6)){
281 /* not a vorbis header */ 281 /* not a vorbis header */
282 return(OV_ENOTVORBIS); 282 return(OV_ENOTVORBIS);
283 } 283 }
284 switch(packtype){ 284 switch(packtype){
285 case 0x01: /* least significant *bit* is read first */ 285 case 0x01: /* least significant *bit* is read first */
286 if(!op->b_o_s){ 286 if(!op->b_o_s){
287 /* Not the initial packet */ 287 /* Not the initial packet */
288 return(OV_EBADHEADER); 288 return(OV_EBADHEADER);
289 } 289 }
290 if(vi->rate!=0){ 290 if(vi->rate!=0){
291 /* previously initialized info header */ 291 /* previously initialized info header */
292 return(OV_EBADHEADER); 292 return(OV_EBADHEADER);
293 } 293 }
294 294
295 return(_vorbis_unpack_info(vi,&opb)); 295 return(_vorbis_unpack_info(vi,&opb));
296 296
297 case 0x03: /* least significant *bit* is read first */ 297 case 0x03: /* least significant *bit* is read first */
298 if(vi->rate==0){ 298 if(vi->rate==0){
299 /* um... we didn't get the initial header */ 299 /* um... we didn't get the initial header */
300 return(OV_EBADHEADER); 300 return(OV_EBADHEADER);
301 } 301 }
302 302
303 return(_vorbis_unpack_comment(vc,&opb)); 303 return(_vorbis_unpack_comment(vc,&opb));
304 304
305 case 0x05: /* least significant *bit* is read first */ 305 case 0x05: /* least significant *bit* is read first */
306 if(vi->rate==0 || vc->vendor==NULL){ 306 if(vi->rate==0 || vc->vendor==NULL){
307 /* um... we didn;t get the initial header or comments yet */ 307 /* um... we didn;t get the initial header or comments yet */
308 return(OV_EBADHEADER); 308 return(OV_EBADHEADER);
309 } 309 }
310 310
311 return(_vorbis_unpack_books(vi,&opb)); 311 return(_vorbis_unpack_books(vi,&opb));
312 312
313 default: 313 default:
314 /* Not a valid vorbis header type */ 314 /* Not a valid vorbis header type */
315 return(OV_EBADHEADER); 315 return(OV_EBADHEADER);
316 break; 316 break;
317 } 317 }
318 } 318 }
319 } 319 }
diff --git a/apps/codecs/libtremor/ivorbiscodec.h b/apps/codecs/libtremor/ivorbiscodec.h
index 0f3c940216..561c5d8732 100644
--- a/apps/codecs/libtremor/ivorbiscodec.h
+++ b/apps/codecs/libtremor/ivorbiscodec.h
@@ -157,7 +157,7 @@ extern int vorbis_info_blocksize(vorbis_info *vi,int zo);
157extern void vorbis_comment_init(vorbis_comment *vc); 157extern void vorbis_comment_init(vorbis_comment *vc);
158extern void vorbis_comment_add(vorbis_comment *vc, char *comment); 158extern void vorbis_comment_add(vorbis_comment *vc, char *comment);
159extern void vorbis_comment_add_tag(vorbis_comment *vc, 159extern void vorbis_comment_add_tag(vorbis_comment *vc,
160 char *tag, char *contents); 160 char *tag, char *contents);
161extern void vorbis_comment_clear(vorbis_comment *vc); 161extern void vorbis_comment_clear(vorbis_comment *vc);
162 162
163extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb); 163extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);
@@ -167,7 +167,7 @@ extern void vorbis_dsp_clear(vorbis_dsp_state *v);
167/* Vorbis PRIMITIVES: synthesis layer *******************************/ 167/* Vorbis PRIMITIVES: synthesis layer *******************************/
168extern int vorbis_synthesis_idheader(ogg_packet *op); 168extern int vorbis_synthesis_idheader(ogg_packet *op);
169extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc, 169extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,
170 ogg_packet *op); 170 ogg_packet *op);
171 171
172extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi); 172extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi);
173extern int vorbis_synthesis_restart(vorbis_dsp_state *v); 173extern int vorbis_synthesis_restart(vorbis_dsp_state *v);
diff --git a/apps/codecs/libtremor/ivorbisfile.h b/apps/codecs/libtremor/ivorbisfile.h
index 4aa82cf9a0..39a648961a 100644
--- a/apps/codecs/libtremor/ivorbisfile.h
+++ b/apps/codecs/libtremor/ivorbisfile.h
@@ -89,11 +89,11 @@ typedef struct OggVorbis_File {
89extern int ov_clear(OggVorbis_File *vf); 89extern int ov_clear(OggVorbis_File *vf);
90 //extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); 90 //extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
91extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf, 91extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf,
92 char *initial, long ibytes, ov_callbacks callbacks); 92 char *initial, long ibytes, ov_callbacks callbacks);
93 93
94 //extern int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); 94 //extern int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
95extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf, 95extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf,
96 char *initial, long ibytes, ov_callbacks callbacks); 96 char *initial, long ibytes, ov_callbacks callbacks);
97extern int ov_test_open(OggVorbis_File *vf); 97extern int ov_test_open(OggVorbis_File *vf);
98 98
99extern long ov_bitrate(OggVorbis_File *vf,int i); 99extern long ov_bitrate(OggVorbis_File *vf,int i);
@@ -120,7 +120,7 @@ extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
120extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link); 120extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link);
121 121
122extern long ov_read(OggVorbis_File *vf,char *buffer,int length, 122extern long ov_read(OggVorbis_File *vf,char *buffer,int length,
123 int *bitstream); 123 int *bitstream);
124extern long ov_read_fixed(OggVorbis_File *vf,ogg_int32_t ***pcm_channels, 124extern long ov_read_fixed(OggVorbis_File *vf,ogg_int32_t ***pcm_channels,
125 int length,int *bitstream); 125 int length,int *bitstream);
126 126
diff --git a/apps/codecs/libtremor/lsp_lookup.h b/apps/codecs/libtremor/lsp_lookup.h
index 42940bd39b..d996677ca1 100644
--- a/apps/codecs/libtremor/lsp_lookup.h
+++ b/apps/codecs/libtremor/lsp_lookup.h
@@ -51,23 +51,23 @@ static const ogg_int32_t FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ] ={
51#define INVSQ_LOOKUP_I_SHIFT 10 51#define INVSQ_LOOKUP_I_SHIFT 10
52#define INVSQ_LOOKUP_I_MASK 1023 52#define INVSQ_LOOKUP_I_MASK 1023
53static const long INVSQ_LOOKUP_I[64+1] ={ 53static const long INVSQ_LOOKUP_I[64+1] ={
54 92682, 91966, 91267, 90583, 54 92682, 91966, 91267, 90583,
55 89915, 89261, 88621, 87995, 55 89915, 89261, 88621, 87995,
56 87381, 86781, 86192, 85616, 56 87381, 86781, 86192, 85616,
57 85051, 84497, 83953, 83420, 57 85051, 84497, 83953, 83420,
58 82897, 82384, 81880, 81385, 58 82897, 82384, 81880, 81385,
59 80899, 80422, 79953, 79492, 59 80899, 80422, 79953, 79492,
60 79039, 78594, 78156, 77726, 60 79039, 78594, 78156, 77726,
61 77302, 76885, 76475, 76072, 61 77302, 76885, 76475, 76072,
62 75674, 75283, 74898, 74519, 62 75674, 75283, 74898, 74519,
63 74146, 73778, 73415, 73058, 63 74146, 73778, 73415, 73058,
64 72706, 72359, 72016, 71679, 64 72706, 72359, 72016, 71679,
65 71347, 71019, 70695, 70376, 65 71347, 71019, 70695, 70376,
66 70061, 69750, 69444, 69141, 66 70061, 69750, 69444, 69141,
67 68842, 68548, 68256, 67969, 67 68842, 68548, 68256, 67969,
68 67685, 67405, 67128, 66855, 68 67685, 67405, 67128, 66855,
69 66585, 66318, 66054, 65794, 69 66585, 66318, 66054, 65794,
70 65536, 70 65536,
71}; 71};
72 72
73static const long INVSQ_LOOKUP_IDel[64] ={ 73static const long INVSQ_LOOKUP_IDel[64] ={
@@ -93,44 +93,40 @@ static const long INVSQ_LOOKUP_IDel[64] ={
93#define COS_LOOKUP_I_MASK 511 93#define COS_LOOKUP_I_MASK 511
94#define COS_LOOKUP_I_SZ 128 94#define COS_LOOKUP_I_SZ 128
95static const ogg_int32_t COS_LOOKUP_I[COS_LOOKUP_I_SZ+1] ={ 95static const ogg_int32_t COS_LOOKUP_I[COS_LOOKUP_I_SZ+1] ={
96 16384, 16379, 16364, 16340, 96 16384, 16379, 16364, 16340,
97 16305, 16261, 16207, 16143, 97 16305, 16261, 16207, 16143,
98 16069, 15986, 15893, 15791, 98 16069, 15986, 15893, 15791,
99 15679, 15557, 15426, 15286, 99 15679, 15557, 15426, 15286,
100 15137, 14978, 14811, 14635, 100 15137, 14978, 14811, 14635,
101 14449, 14256, 14053, 13842, 101 14449, 14256, 14053, 13842,
102 13623, 13395, 13160, 12916, 102 13623, 13395, 13160, 12916,
103 12665, 12406, 12140, 11866, 103 12665, 12406, 12140, 11866,
104 11585, 11297, 11003, 10702, 104 11585, 11297, 11003, 10702,
105 10394, 10080, 9760, 9434, 105 10394, 10080, 9760, 9434,
106 9102, 8765, 8423, 8076, 106 9102, 8765, 8423, 8076,
107 7723, 7366, 7005, 6639, 107 7723, 7366, 7005, 6639,
108 6270, 5897, 5520, 5139, 108 6270, 5897, 5520, 5139,
109 4756, 4370, 3981, 3590, 109 4756, 4370, 3981, 3590,
110 3196, 2801, 2404, 2006, 110 3196, 2801, 2404, 2006,
111 1606, 1205, 804, 402, 111 1606, 1205, 804, 402,
112 0, -401, -803, -1204, 112 0, -401, -803, -1204,
113 -1605, -2005, -2403, -2800, 113 -1605, -2005, -2403, -2800,
114 -3195, -3589, -3980, -4369, 114 -3195, -3589, -3980, -4369,
115 -4755, -5138, -5519, -5896, 115 -4755, -5138, -5519, -5896,
116 -6269, -6638, -7004, -7365, 116 -6269, -6638, -7004, -7365,
117 -7722, -8075, -8422, -8764, 117 -7722, -8075, -8422, -8764,
118 -9101, -9433, -9759, -10079, 118 -9101, -9433, -9759, -10079,
119 -10393, -10701, -11002, -11296, 119 -10393, -10701, -11002, -11296,
120 -11584, -11865, -12139, -12405, 120 -11584, -11865, -12139, -12405,
121 -12664, -12915, -13159, -13394, 121 -12664, -12915, -13159, -13394,
122 -13622, -13841, -14052, -14255, 122 -13622, -13841, -14052, -14255,
123 -14448, -14634, -14810, -14977, 123 -14448, -14634, -14810, -14977,
124 -15136, -15285, -15425, -15556, 124 -15136, -15285, -15425, -15556,
125 -15678, -15790, -15892, -15985, 125 -15678, -15790, -15892, -15985,
126 -16068, -16142, -16206, -16260, 126 -16068, -16142, -16206, -16260,
127 -16304, -16339, -16363, -16378, 127 -16304, -16339, -16363, -16378,
128 -16383, 128 -16383,
129}; 129};
130 130
131#endif 131#endif
132 132
133
134
135
136
diff --git a/apps/codecs/libtremor/misc.h b/apps/codecs/libtremor/misc.h
index 6e22f20008..a64a95d137 100644
--- a/apps/codecs/libtremor/misc.h
+++ b/apps/codecs/libtremor/misc.h
@@ -119,33 +119,33 @@ static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
119 119
120/* replaced XPROD32 with a macro to avoid memory reference 120/* replaced XPROD32 with a macro to avoid memory reference
121 _x, _y are the results (must be l-values) */ 121 _x, _y are the results (must be l-values) */
122#define XPROD32(_a, _b, _t, _v, _x, _y) \ 122#define XPROD32(_a, _b, _t, _v, _x, _y) \
123 { (_x)=MULT32(_a,_t)+MULT32(_b,_v); \ 123 { (_x)=MULT32(_a,_t)+MULT32(_b,_v); \
124 (_y)=MULT32(_b,_t)-MULT32(_a,_v); } 124 (_y)=MULT32(_b,_t)-MULT32(_a,_v); }
125 125
126 126
127#ifdef __i386__ 127#ifdef __i386__
128 128
129#define XPROD31(_a, _b, _t, _v, _x, _y) \ 129#define XPROD31(_a, _b, _t, _v, _x, _y) \
130 { *(_x)=MULT31(_a,_t)+MULT31(_b,_v); \ 130 { *(_x)=MULT31(_a,_t)+MULT31(_b,_v); \
131 *(_y)=MULT31(_b,_t)-MULT31(_a,_v); } 131 *(_y)=MULT31(_b,_t)-MULT31(_a,_v); }
132#define XNPROD31(_a, _b, _t, _v, _x, _y) \ 132#define XNPROD31(_a, _b, _t, _v, _x, _y) \
133 { *(_x)=MULT31(_a,_t)-MULT31(_b,_v); \ 133 { *(_x)=MULT31(_a,_t)-MULT31(_b,_v); \
134 *(_y)=MULT31(_b,_t)+MULT31(_a,_v); } 134 *(_y)=MULT31(_b,_t)+MULT31(_a,_v); }
135 135
136#else 136#else
137 137
138static inline void XPROD31(ogg_int32_t a, ogg_int32_t b, 138static inline void XPROD31(ogg_int32_t a, ogg_int32_t b,
139 ogg_int32_t t, ogg_int32_t v, 139 ogg_int32_t t, ogg_int32_t v,
140 ogg_int32_t *x, ogg_int32_t *y) 140 ogg_int32_t *x, ogg_int32_t *y)
141{ 141{
142 *x = MULT31(a, t) + MULT31(b, v); 142 *x = MULT31(a, t) + MULT31(b, v);
143 *y = MULT31(b, t) - MULT31(a, v); 143 *y = MULT31(b, t) - MULT31(a, v);
144} 144}
145 145
146static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b, 146static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b,
147 ogg_int32_t t, ogg_int32_t v, 147 ogg_int32_t t, ogg_int32_t v,
148 ogg_int32_t *x, ogg_int32_t *y) 148 ogg_int32_t *x, ogg_int32_t *y)
149{ 149{
150 *x = MULT31(a, t) - MULT31(b, v); 150 *x = MULT31(a, t) - MULT31(b, v);
151 *y = MULT31(b, t) + MULT31(a, v); 151 *y = MULT31(b, t) + MULT31(a, v);
@@ -217,8 +217,8 @@ static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
217#endif 217#endif
218 218
219static inline ogg_int32_t VFLOAT_MULT(ogg_int32_t a,ogg_int32_t ap, 219static inline ogg_int32_t VFLOAT_MULT(ogg_int32_t a,ogg_int32_t ap,
220 ogg_int32_t b,ogg_int32_t bp, 220 ogg_int32_t b,ogg_int32_t bp,
221 ogg_int32_t *p){ 221 ogg_int32_t *p){
222 if(a && b){ 222 if(a && b){
223#ifndef _LOW_ACCURACY_ 223#ifndef _LOW_ACCURACY_
224 *p=ap+bp+32; 224 *p=ap+bp+32;
@@ -232,16 +232,16 @@ static inline ogg_int32_t VFLOAT_MULT(ogg_int32_t a,ogg_int32_t ap,
232} 232}
233 233
234static inline ogg_int32_t VFLOAT_MULTI(ogg_int32_t a,ogg_int32_t ap, 234static inline ogg_int32_t VFLOAT_MULTI(ogg_int32_t a,ogg_int32_t ap,
235 ogg_int32_t i, 235 ogg_int32_t i,
236 ogg_int32_t *p){ 236 ogg_int32_t *p){
237 237
238 int ip=_ilog(abs(i))-31; 238 int ip=_ilog(abs(i))-31;
239 return VFLOAT_MULT(a,ap,i<<-ip,ip,p); 239 return VFLOAT_MULT(a,ap,i<<-ip,ip,p);
240} 240}
241 241
242static inline ogg_int32_t VFLOAT_ADD(ogg_int32_t a,ogg_int32_t ap, 242static inline ogg_int32_t VFLOAT_ADD(ogg_int32_t a,ogg_int32_t ap,
243 ogg_int32_t b,ogg_int32_t bp, 243 ogg_int32_t b,ogg_int32_t bp,
244 ogg_int32_t *p){ 244 ogg_int32_t *p){
245 245
246 if(!a){ 246 if(!a){
247 *p=bp; 247 *p=bp;
diff --git a/apps/codecs/libtremor/sharedbook.c b/apps/codecs/libtremor/sharedbook.c
index 10fae80c84..c47476bdd7 100644
--- a/apps/codecs/libtremor/sharedbook.c
+++ b/apps/codecs/libtremor/sharedbook.c
@@ -80,45 +80,45 @@ static ogg_uint32_t *_make_words(long *l,long n,long sparsecount){
80 ogg_uint32_t entry=marker[length]; 80 ogg_uint32_t entry=marker[length];
81 81
82 /* when we claim a node for an entry, we also claim the nodes 82 /* when we claim a node for an entry, we also claim the nodes
83 below it (pruning off the imagined tree that may have dangled 83 below it (pruning off the imagined tree that may have dangled
84 from it) as well as blocking the use of any nodes directly 84 from it) as well as blocking the use of any nodes directly
85 above for leaves */ 85 above for leaves */
86 86
87 /* update ourself */ 87 /* update ourself */
88 if(length<32 && (entry>>length)){ 88 if(length<32 && (entry>>length)){
89 /* error condition; the lengths must specify an overpopulated tree */ 89 /* error condition; the lengths must specify an overpopulated tree */
90 _ogg_free(r); 90 _ogg_free(r);
91 return(NULL); 91 return(NULL);
92 } 92 }
93 r[count++]=entry; 93 r[count++]=entry;
94 94
95 /* Look to see if the next shorter marker points to the node 95 /* Look to see if the next shorter marker points to the node
96 above. if so, update it and repeat. */ 96 above. if so, update it and repeat. */
97 { 97 {
98 for(j=length;j>0;j--){ 98 for(j=length;j>0;j--){
99 99
100 if(marker[j]&1){ 100 if(marker[j]&1){
101 /* have to jump branches */ 101 /* have to jump branches */
102 if(j==1) 102 if(j==1)
103 marker[1]++; 103 marker[1]++;
104 else 104 else
105 marker[j]=marker[j-1]<<1; 105 marker[j]=marker[j-1]<<1;
106 break; /* invariant says next upper marker would already 106 break; /* invariant says next upper marker would already
107 have been moved if it was on the same path */ 107 have been moved if it was on the same path */
108 } 108 }
109 marker[j]++; 109 marker[j]++;
110 } 110 }
111 } 111 }
112 112
113 /* prune the tree; the implicit invariant says all the longer 113 /* prune the tree; the implicit invariant says all the longer
114 markers were dangling from our just-taken node. Dangle them 114 markers were dangling from our just-taken node. Dangle them
115 from our *new* node. */ 115 from our *new* node. */
116 for(j=length+1;j<33;j++) 116 for(j=length+1;j<33;j++)
117 if((marker[j]>>1) == entry){ 117 if((marker[j]>>1) == entry){
118 entry=marker[j]; 118 entry=marker[j];
119 marker[j]=marker[j-1]<<1; 119 marker[j]=marker[j-1]<<1;
120 }else 120 }else
121 break; 121 break;
122 }else 122 }else
123 if(sparsecount==0)count++; 123 if(sparsecount==0)count++;
124 } 124 }
@@ -134,7 +134,7 @@ static ogg_uint32_t *_make_words(long *l,long n,long sparsecount){
134 134
135 if(sparsecount){ 135 if(sparsecount){
136 if(l[i]) 136 if(l[i])
137 r[count++]=temp; 137 r[count++]=temp;
138 }else 138 }else
139 r[count++]=temp; 139 r[count++]=temp;
140 } 140 }
@@ -162,9 +162,9 @@ long _book_maptype1_quantvals(const static_codebook *b){
162 return(vals); 162 return(vals);
163 }else{ 163 }else{
164 if(acc>b->entries){ 164 if(acc>b->entries){
165 vals--; 165 vals--;
166 }else{ 166 }else{
167 vals++; 167 vals++;
168 } 168 }
169 } 169 }
170 } 170 }
@@ -197,85 +197,85 @@ static ogg_int32_t *_book_unquantize(const static_codebook *b,int n,
197 switch(b->maptype){ 197 switch(b->maptype){
198 case 1: 198 case 1:
199 /* most of the time, entries%dimensions == 0, but we need to be 199 /* most of the time, entries%dimensions == 0, but we need to be
200 well defined. We define that the possible vales at each 200 well defined. We define that the possible vales at each
201 scalar is values == entries/dim. If entries%dim != 0, we'll 201 scalar is values == entries/dim. If entries%dim != 0, we'll
202 have 'too few' values (values*dim<entries), which means that 202 have 'too few' values (values*dim<entries), which means that
203 we'll have 'left over' entries; left over entries use zeroed 203 we'll have 'left over' entries; left over entries use zeroed
204 values (and are wasted). So don't generate codebooks like 204 values (and are wasted). So don't generate codebooks like
205 that */ 205 that */
206 quantvals=_book_maptype1_quantvals(b); 206 quantvals=_book_maptype1_quantvals(b);
207 for(j=0;j<b->entries;j++){ 207 for(j=0;j<b->entries;j++){
208 if((sparsemap && b->lengthlist[j]) || !sparsemap){ 208 if((sparsemap && b->lengthlist[j]) || !sparsemap){
209 ogg_int32_t last=0; 209 ogg_int32_t last=0;
210 int lastpoint=0; 210 int lastpoint=0;
211 int indexdiv=1; 211 int indexdiv=1;
212 for(k=0;k<b->dim;k++){ 212 for(k=0;k<b->dim;k++){
213 int index= (j/indexdiv)%quantvals; 213 int index= (j/indexdiv)%quantvals;
214 int point=0; 214 int point=0;
215 int val=VFLOAT_MULTI(delta,delpoint, 215 int val=VFLOAT_MULTI(delta,delpoint,
216 abs(b->quantlist[index]),&point); 216 abs(b->quantlist[index]),&point);
217 217
218 val=VFLOAT_ADD(mindel,minpoint,val,point,&point); 218 val=VFLOAT_ADD(mindel,minpoint,val,point,&point);
219 val=VFLOAT_ADD(last,lastpoint,val,point,&point); 219 val=VFLOAT_ADD(last,lastpoint,val,point,&point);
220 220
221 if(b->q_sequencep){ 221 if(b->q_sequencep){
222 last=val; 222 last=val;
223 lastpoint=point; 223 lastpoint=point;
224 }
225
226 if(sparsemap){
227 r[sparsemap[count]*b->dim+k]=val;
228 rp[sparsemap[count]*b->dim+k]=point;
229 }else{
230 r[count*b->dim+k]=val;
231 rp[count*b->dim+k]=point;
232 }
233 if(*maxpoint<point)*maxpoint=point;
234 indexdiv*=quantvals;
235 }
236 count++;
224 } 237 }
225
226 if(sparsemap){
227 r[sparsemap[count]*b->dim+k]=val;
228 rp[sparsemap[count]*b->dim+k]=point;
229 }else{
230 r[count*b->dim+k]=val;
231 rp[count*b->dim+k]=point;
232 }
233 if(*maxpoint<point)*maxpoint=point;
234 indexdiv*=quantvals;
235 }
236 count++;
237 }
238 238
239 } 239 }
240 break; 240 break;
241 case 2: 241 case 2:
242 for(j=0;j<b->entries;j++){ 242 for(j=0;j<b->entries;j++){
243 if((sparsemap && b->lengthlist[j]) || !sparsemap){ 243 if((sparsemap && b->lengthlist[j]) || !sparsemap){
244 ogg_int32_t last=0; 244 ogg_int32_t last=0;
245 int lastpoint=0; 245 int lastpoint=0;
246 246
247 for(k=0;k<b->dim;k++){ 247 for(k=0;k<b->dim;k++){
248 int point=0; 248 int point=0;
249 int val=VFLOAT_MULTI(delta,delpoint, 249 int val=VFLOAT_MULTI(delta,delpoint,
250 abs(b->quantlist[j*b->dim+k]),&point); 250 abs(b->quantlist[j*b->dim+k]),&point);
251 251
252 val=VFLOAT_ADD(mindel,minpoint,val,point,&point); 252 val=VFLOAT_ADD(mindel,minpoint,val,point,&point);
253 val=VFLOAT_ADD(last,lastpoint,val,point,&point); 253 val=VFLOAT_ADD(last,lastpoint,val,point,&point);
254 254
255 if(b->q_sequencep){ 255 if(b->q_sequencep){
256 last=val; 256 last=val;
257 lastpoint=point; 257 lastpoint=point;
258 } 258 }
259 259
260 if(sparsemap){ 260 if(sparsemap){
261 r[sparsemap[count]*b->dim+k]=val; 261 r[sparsemap[count]*b->dim+k]=val;
262 rp[sparsemap[count]*b->dim+k]=point; 262 rp[sparsemap[count]*b->dim+k]=point;
263 }else{ 263 }else{
264 r[count*b->dim+k]=val; 264 r[count*b->dim+k]=val;
265 rp[count*b->dim+k]=point; 265 rp[count*b->dim+k]=point;
266 }
267 if(*maxpoint<point)*maxpoint=point;
268 }
269 count++;
266 } 270 }
267 if(*maxpoint<point)*maxpoint=point;
268 }
269 count++;
270 }
271 } 271 }
272 break; 272 break;
273 } 273 }
274 274
275 for(j=0;j<n*b->dim;j++) 275 for(j=0;j<n*b->dim;j++)
276 if(rp[j]<*maxpoint) 276 if(rp[j]<*maxpoint)
277 r[j]>>=*maxpoint-rp[j]; 277 r[j]>>=*maxpoint-rp[j];
278 278
279 _ogg_free(rp); 279 _ogg_free(rp);
280 return(r); 280 return(r);
281 } 281 }
@@ -383,12 +383,12 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
383 383
384 for(n=0,i=0;i<s->entries;i++) 384 for(n=0,i=0;i<s->entries;i++)
385 if(s->lengthlist[i]>0) 385 if(s->lengthlist[i]>0)
386 c->dec_index[sortindex[n++]]=i; 386 c->dec_index[sortindex[n++]]=i;
387 387
388 c->dec_codelengths=(char *)_ogg_malloc(n*sizeof(*c->dec_codelengths)); 388 c->dec_codelengths=(char *)_ogg_malloc(n*sizeof(*c->dec_codelengths));
389 for(n=0,i=0;i<s->entries;i++) 389 for(n=0,i=0;i<s->entries;i++)
390 if(s->lengthlist[i]>0) 390 if(s->lengthlist[i]>0)
391 c->dec_codelengths[sortindex[n++]]=s->lengthlist[i]; 391 c->dec_codelengths[sortindex[n++]]=s->lengthlist[i];
392 392
393 _ogg_free(sortindex); 393 _ogg_free(sortindex);
394 c->dec_firsttablen=_ilog(c->used_entries)-4; /* this is magic */ 394 c->dec_firsttablen=_ilog(c->used_entries)-4; /* this is magic */
@@ -401,11 +401,11 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
401 401
402 for(i=0;i<n;i++){ 402 for(i=0;i<n;i++){
403 if(c->dec_maxlength<c->dec_codelengths[i]) 403 if(c->dec_maxlength<c->dec_codelengths[i])
404 c->dec_maxlength=c->dec_codelengths[i]; 404 c->dec_maxlength=c->dec_codelengths[i];
405 if(c->dec_codelengths[i]<=c->dec_firsttablen){ 405 if(c->dec_codelengths[i]<=c->dec_firsttablen){
406 ogg_uint32_t orig=bitreverse(c->codelist[i]); 406 ogg_uint32_t orig=bitreverse(c->codelist[i]);
407 for(j=0;j<(1<<(c->dec_firsttablen-c->dec_codelengths[i]));j++) 407 for(j=0;j<(1<<(c->dec_firsttablen-c->dec_codelengths[i]));j++)
408 c->dec_firsttable[orig|(j<<c->dec_codelengths[i])]=i+1; 408 c->dec_firsttable[orig|(j<<c->dec_codelengths[i])]=i+1;
409 } 409 }
410 } 410 }
411 411
@@ -416,24 +416,24 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
416 long lo=0,hi=0; 416 long lo=0,hi=0;
417 417
418 for(i=0;i<tabn;i++){ 418 for(i=0;i<tabn;i++){
419 ogg_uint32_t word=i<<(32-c->dec_firsttablen); 419 ogg_uint32_t word=i<<(32-c->dec_firsttablen);
420 if(c->dec_firsttable[bitreverse(word)]==0){ 420 if(c->dec_firsttable[bitreverse(word)]==0){
421 while((lo+1)<n && c->codelist[lo+1]<=word)lo++; 421 while((lo+1)<n && c->codelist[lo+1]<=word)lo++;
422 while( hi<n && word>=(c->codelist[hi]&mask))hi++; 422 while( hi<n && word>=(c->codelist[hi]&mask))hi++;
423 423
424 /* we only actually have 15 bits per hint to play with here. 424 /* we only actually have 15 bits per hint to play with here.
425 In order to overflow gracefully (nothing breaks, efficiency 425 In order to overflow gracefully (nothing breaks, efficiency
426 just drops), encode as the difference from the extremes. */ 426 just drops), encode as the difference from the extremes. */
427 { 427 {
428 unsigned long loval=lo; 428 unsigned long loval=lo;
429 unsigned long hival=n-hi; 429 unsigned long hival=n-hi;
430 430
431 if(loval>0x7fff)loval=0x7fff; 431 if(loval>0x7fff)loval=0x7fff;
432 if(hival>0x7fff)hival=0x7fff; 432 if(hival>0x7fff)hival=0x7fff;
433 c->dec_firsttable[bitreverse(word)]= 433 c->dec_firsttable[bitreverse(word)]=
434 0x80000000UL | (loval<<15) | hival; 434 0x80000000UL | (loval<<15) | hival;
435 } 435 }
436 } 436 }
437 } 437 }
438 } 438 }
439 } 439 }
diff --git a/apps/codecs/libtremor/window.h b/apps/codecs/libtremor/window.h
index f11742e1dd..b242ec2354 100644
--- a/apps/codecs/libtremor/window.h
+++ b/apps/codecs/libtremor/window.h
@@ -20,8 +20,8 @@
20 20
21extern const void *_vorbis_window(int type,int left); 21extern const void *_vorbis_window(int type,int left);
22extern void _vorbis_apply_window(ogg_int32_t *d,const void *window[2], 22extern void _vorbis_apply_window(ogg_int32_t *d,const void *window[2],
23 long *blocksizes, 23 long *blocksizes,
24 int lW,int W,int nW); 24 int lW,int W,int nW);
25 25
26 26
27#endif 27#endif