diff options
Diffstat (limited to 'apps/codecs/libtremor')
-rw-r--r-- | apps/codecs/libtremor/asm_arm.h | 82 | ||||
-rw-r--r-- | apps/codecs/libtremor/backends.h | 10 | ||||
-rw-r--r-- | apps/codecs/libtremor/codebook.c | 204 | ||||
-rw-r--r-- | apps/codecs/libtremor/codebook.h | 18 | ||||
-rw-r--r-- | apps/codecs/libtremor/floor0.c | 36 | ||||
-rw-r--r-- | apps/codecs/libtremor/framing.c | 4 | ||||
-rw-r--r-- | apps/codecs/libtremor/info.c | 64 | ||||
-rw-r--r-- | apps/codecs/libtremor/ivorbiscodec.h | 4 | ||||
-rw-r--r-- | apps/codecs/libtremor/ivorbisfile.h | 6 | ||||
-rw-r--r-- | apps/codecs/libtremor/lsp_lookup.h | 100 | ||||
-rw-r--r-- | apps/codecs/libtremor/misc.h | 32 | ||||
-rw-r--r-- | apps/codecs/libtremor/sharedbook.c | 240 | ||||
-rw-r--r-- | apps/codecs/libtremor/window.h | 4 |
13 files changed, 402 insertions, 402 deletions
diff --git a/apps/codecs/libtremor/asm_arm.h b/apps/codecs/libtremor/asm_arm.h index 577dc91566..8da7ed75cc 100644 --- a/apps/codecs/libtremor/asm_arm.h +++ b/apps/codecs/libtremor/asm_arm.h | |||
@@ -34,55 +34,55 @@ static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) { | |||
34 | 34 | ||
35 | static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) { | 35 | static 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 | ||
46 | #define XPROD32(a, b, t, v, x, y) \ | 46 | #define XPROD32(a, b, t, v, x, 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 | ||
58 | static inline void XPROD31(ogg_int32_t a, ogg_int32_t b, | 58 | static 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 | ||
74 | static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b, | 74 | static 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 | } |
@@ -216,14 +216,14 @@ static inline void vect_copy(ogg_int32_t *x, const ogg_int32_t *y, int n) | |||
216 | 216 | ||
217 | static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) { | 217 | static 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 | ||
235 | static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip, | 235 | static 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; |
@@ -291,7 +291,7 @@ static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip, | |||
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 50c1c45cfd..677bc8fdc2 100644 --- a/apps/codecs/libtremor/backends.h +++ b/apps/codecs/libtremor/backends.h | |||
@@ -34,12 +34,12 @@ | |||
34 | typedef struct{ | 34 | typedef 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 | ||
45 | typedef struct{ | 45 | typedef struct{ |
@@ -77,11 +77,11 @@ typedef struct{ | |||
77 | typedef struct{ | 77 | typedef 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 | ||
87 | typedef struct vorbis_info_residue0{ | 87 | typedef struct vorbis_info_residue0{ |
@@ -101,7 +101,7 @@ typedef struct vorbis_info_residue0{ | |||
101 | typedef struct{ | 101 | typedef 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 c6027480a7..6ed6a08672 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 | ||
218 | STIN long decode_packed_entry_number(codebook *book, | 218 | STIN 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,25 +284,25 @@ 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 | { |
304 | ogg_uint32_t testword=bitreverse((ogg_uint32_t)cache); | 304 | ogg_uint32_t testword=bitreverse((ogg_uint32_t)cache); |
305 | 305 | ||
306 | while(LIKELY(hi-lo>1)){ | 306 | while(LIKELY(hi-lo>1)){ |
307 | long p=(hi-lo)>>1; | 307 | long p=(hi-lo)>>1; |
308 | if (book->codelist[lo+p]>testword) | 308 | if (book->codelist[lo+p]>testword) |
@@ -312,15 +312,15 @@ static long decode_packed_block(codebook *book, oggpack_buffer *b, | |||
312 | } | 312 | } |
313 | entry=lo; | 313 | entry=lo; |
314 | } | 314 | } |
315 | }else | 315 | }else |
316 | entry--; | 316 | entry--; |
317 | 317 | ||
318 | *bufptr++=entry; | 318 | *bufptr++=entry; |
319 | { | 319 | { |
320 | int l=book->dec_codelengths[entry]; | 320 | int l=book->dec_codelengths[entry]; |
321 | cachesize-=l; | 321 | cachesize-=l; |
322 | cache>>=l; | 322 | cache>>=l; |
323 | } | 323 | } |
324 | } | 324 | } |
325 | 325 | ||
326 | adr=(unsigned long)b->headptr; | 326 | adr=(unsigned long)b->headptr; |
@@ -366,7 +366,7 @@ long vorbis_book_decode(codebook *book, oggpack_buffer *b){ | |||
366 | 366 | ||
367 | /* returns 0 on OK or -1 on eof *************************************/ | 367 | /* returns 0 on OK or -1 on eof *************************************/ |
368 | long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a, | 368 | long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a, |
369 | oggpack_buffer *b,int n,int point){ | 369 | oggpack_buffer *b,int n,int point){ |
370 | if(book->used_entries>0){ | 370 | if(book->used_entries>0){ |
371 | int step=n/book->dim; | 371 | int step=n/book->dim; |
372 | long *entry = (long *)alloca(sizeof(*entry)*step); | 372 | long *entry = (long *)alloca(sizeof(*entry)*step); |
@@ -376,29 +376,29 @@ long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a, | |||
376 | 376 | ||
377 | if(shift>=0){ | 377 | if(shift>=0){ |
378 | for (i = 0; i < step; i++) { | 378 | for (i = 0; i < step; i++) { |
379 | entry[i]=decode_packed_entry_number(book,b); | 379 | entry[i]=decode_packed_entry_number(book,b); |
380 | if(entry[i]==-1)return(-1); | 380 | if(entry[i]==-1)return(-1); |
381 | t[i] = book->valuelist+entry[i]*book->dim; | 381 | t[i] = book->valuelist+entry[i]*book->dim; |
382 | } | 382 | } |
383 | for(i=0,o=0;i<book->dim;i++,o+=step) | 383 | for(i=0,o=0;i<book->dim;i++,o+=step) |
384 | for (j=0;j<step;j++) | 384 | for (j=0;j<step;j++) |
385 | a[o+j]+=t[j][i]>>shift; | 385 | a[o+j]+=t[j][i]>>shift; |
386 | }else{ | 386 | }else{ |
387 | for (i = 0; i < step; i++) { | 387 | for (i = 0; i < step; i++) { |
388 | entry[i]=decode_packed_entry_number(book,b); | 388 | entry[i]=decode_packed_entry_number(book,b); |
389 | if(entry[i]==-1)return(-1); | 389 | if(entry[i]==-1)return(-1); |
390 | t[i] = book->valuelist+entry[i]*book->dim; | 390 | t[i] = book->valuelist+entry[i]*book->dim; |
391 | } | 391 | } |
392 | for(i=0,o=0;i<book->dim;i++,o+=step) | 392 | for(i=0,o=0;i<book->dim;i++,o+=step) |
393 | for (j=0;j<step;j++) | 393 | for (j=0;j<step;j++) |
394 | a[o+j]+=t[j][i]<<-shift; | 394 | a[o+j]+=t[j][i]<<-shift; |
395 | } | 395 | } |
396 | } | 396 | } |
397 | return(0); | 397 | return(0); |
398 | } | 398 | } |
399 | 399 | ||
400 | long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a, | 400 | long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a, |
401 | oggpack_buffer *b,int n,int point){ | 401 | oggpack_buffer *b,int n,int point){ |
402 | if(book->used_entries>0){ | 402 | if(book->used_entries>0){ |
403 | int i,j,entry; | 403 | int i,j,entry; |
404 | ogg_int32_t *t; | 404 | ogg_int32_t *t; |
@@ -406,20 +406,20 @@ long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a, | |||
406 | 406 | ||
407 | if(shift>=0){ | 407 | if(shift>=0){ |
408 | for(i=0;i<n;){ | 408 | for(i=0;i<n;){ |
409 | entry = decode_packed_entry_number(book,b); | 409 | entry = decode_packed_entry_number(book,b); |
410 | if(entry==-1)return(-1); | 410 | if(entry==-1)return(-1); |
411 | t = book->valuelist+entry*book->dim; | 411 | t = book->valuelist+entry*book->dim; |
412 | for (j=0;j<book->dim;) | 412 | for (j=0;j<book->dim;) |
413 | a[i++]+=t[j++]>>shift; | 413 | a[i++]+=t[j++]>>shift; |
414 | } | 414 | } |
415 | }else{ | 415 | }else{ |
416 | shift = -shift; | 416 | shift = -shift; |
417 | for(i=0;i<n;){ | 417 | for(i=0;i<n;){ |
418 | entry = decode_packed_entry_number(book,b); | 418 | entry = decode_packed_entry_number(book,b); |
419 | if(entry==-1)return(-1); | 419 | if(entry==-1)return(-1); |
420 | t = book->valuelist+entry*book->dim; | 420 | t = book->valuelist+entry*book->dim; |
421 | for (j=0;j<book->dim;) | 421 | for (j=0;j<book->dim;) |
422 | a[i++]+=t[j++]<<shift; | 422 | a[i++]+=t[j++]<<shift; |
423 | } | 423 | } |
424 | } | 424 | } |
425 | } | 425 | } |
@@ -427,7 +427,7 @@ long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a, | |||
427 | } | 427 | } |
428 | 428 | ||
429 | long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a, | 429 | long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a, |
430 | oggpack_buffer *b,int n,int point){ | 430 | oggpack_buffer *b,int n,int point){ |
431 | if(book->used_entries>0){ | 431 | if(book->used_entries>0){ |
432 | int i,j,entry; | 432 | int i,j,entry; |
433 | ogg_int32_t *t; | 433 | ogg_int32_t *t; |
@@ -436,22 +436,22 @@ long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a, | |||
436 | if(shift>=0){ | 436 | if(shift>=0){ |
437 | 437 | ||
438 | for(i=0;i<n;){ | 438 | for(i=0;i<n;){ |
439 | entry = decode_packed_entry_number(book,b); | 439 | entry = decode_packed_entry_number(book,b); |
440 | if(entry==-1)return(-1); | 440 | if(entry==-1)return(-1); |
441 | t = book->valuelist+entry*book->dim; | 441 | t = book->valuelist+entry*book->dim; |
442 | for (j=0;j<book->dim;){ | 442 | for (j=0;j<book->dim;){ |
443 | a[i++]=t[j++]>>shift; | 443 | a[i++]=t[j++]>>shift; |
444 | } | 444 | } |
445 | } | 445 | } |
446 | }else{ | 446 | }else{ |
447 | shift = -shift; | 447 | shift = -shift; |
448 | for(i=0;i<n;){ | 448 | for(i=0;i<n;){ |
449 | entry = decode_packed_entry_number(book,b); | 449 | entry = decode_packed_entry_number(book,b); |
450 | if(entry==-1)return(-1); | 450 | if(entry==-1)return(-1); |
451 | t = book->valuelist+entry*book->dim; | 451 | t = book->valuelist+entry*book->dim; |
452 | for (j=0;j<book->dim;){ | 452 | for (j=0;j<book->dim;){ |
453 | a[i++]=t[j++]<<shift; | 453 | a[i++]=t[j++]<<shift; |
454 | } | 454 | } |
455 | } | 455 | } |
456 | } | 456 | } |
457 | }else{ | 457 | }else{ |
@@ -459,7 +459,7 @@ long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a, | |||
459 | int i,j; | 459 | int i,j; |
460 | for(i=0;i<n;){ | 460 | for(i=0;i<n;){ |
461 | for (j=0;j<book->dim;){ | 461 | for (j=0;j<book->dim;){ |
462 | a[i++]=0; | 462 | a[i++]=0; |
463 | } | 463 | } |
464 | } | 464 | } |
465 | } | 465 | } |
@@ -516,8 +516,8 @@ static long vorbis_book_decodevv_add_2ch_even(codebook *book,ogg_int32_t **a, | |||
516 | } | 516 | } |
517 | 517 | ||
518 | long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a, | 518 | long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a, |
519 | long offset,int ch, | 519 | long offset,int ch, |
520 | oggpack_buffer *b,int n,int point){ | 520 | oggpack_buffer *b,int n,int point){ |
521 | if(LIKELY(book->used_entries>0)){ | 521 | if(LIKELY(book->used_entries>0)){ |
522 | long i,j,k,chunk,read; | 522 | long i,j,k,chunk,read; |
523 | int chptr=0; | 523 | int chptr=0; |
@@ -535,14 +535,14 @@ long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a, | |||
535 | chunk=((offset+n-i)*ch+book->dim-1)/book->dim; | 535 | chunk=((offset+n-i)*ch+book->dim-1)/book->dim; |
536 | read = decode_packed_block(book,b,entries,chunk); | 536 | read = decode_packed_block(book,b,entries,chunk); |
537 | for(k=0;k<read;k++){ | 537 | for(k=0;k<read;k++){ |
538 | const ogg_int32_t *t = book->valuelist+entries[k]*book->dim; | 538 | const ogg_int32_t *t = book->valuelist+entries[k]*book->dim; |
539 | for (j=0;j<book->dim;j++){ | 539 | for (j=0;j<book->dim;j++){ |
540 | a[chptr++][i]+=t[j]>>shift; | 540 | a[chptr++][i]+=t[j]>>shift; |
541 | if(chptr==ch){ | 541 | if(chptr==ch){ |
542 | chptr=0; | 542 | chptr=0; |
543 | i++; | 543 | i++; |
544 | } | 544 | } |
545 | } | 545 | } |
546 | } | 546 | } |
547 | if (read<chunk)return-1; | 547 | if (read<chunk)return-1; |
548 | } | 548 | } |
@@ -554,14 +554,14 @@ long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a, | |||
554 | chunk=((offset+n-i)*ch+book->dim-1)/book->dim; | 554 | chunk=((offset+n-i)*ch+book->dim-1)/book->dim; |
555 | read = decode_packed_block(book,b,entries,chunk); | 555 | read = decode_packed_block(book,b,entries,chunk); |
556 | for(k=0;k<read;k++){ | 556 | for(k=0;k<read;k++){ |
557 | const ogg_int32_t *t = book->valuelist+entries[k]*book->dim; | 557 | const ogg_int32_t *t = book->valuelist+entries[k]*book->dim; |
558 | for (j=0;j<book->dim;j++){ | 558 | for (j=0;j<book->dim;j++){ |
559 | a[chptr++][i]+=t[j]<<shift; | 559 | a[chptr++][i]+=t[j]<<shift; |
560 | if(chptr==ch){ | 560 | if(chptr==ch){ |
561 | chptr=0; | 561 | chptr=0; |
562 | i++; | 562 | i++; |
563 | } | 563 | } |
564 | } | 564 | } |
565 | } | 565 | } |
566 | if (read<chunk)return-1; | 566 | if (read<chunk)return-1; |
567 | } | 567 | } |
diff --git a/apps/codecs/libtremor/codebook.h b/apps/codecs/libtremor/codebook.h index 14f65382dd..0fc6834daa 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 | ||
57 | typedef struct codebook{ | 57 | typedef struct codebook{ |
@@ -87,14 +87,14 @@ extern int vorbis_staticbook_unpack(oggpack_buffer *b,static_codebook *c); | |||
87 | 87 | ||
88 | extern long vorbis_book_decode(codebook *book, oggpack_buffer *b); | 88 | extern long vorbis_book_decode(codebook *book, oggpack_buffer *b); |
89 | extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a, | 89 | extern 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); |
91 | extern long vorbis_book_decodev_set(codebook *book, ogg_int32_t *a, | 91 | extern 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); |
93 | extern long vorbis_book_decodev_add(codebook *book, ogg_int32_t *a, | 93 | extern 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); |
95 | extern long vorbis_book_decodevv_add(codebook *book, ogg_int32_t **a, | 95 | extern 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 | ||
99 | extern int _ilog(unsigned int v); | 99 | extern int _ilog(unsigned int v); |
100 | 100 | ||
diff --git a/apps/codecs/libtremor/floor0.c b/apps/codecs/libtremor/floor0.c index cceb113a6b..9c890e6bad 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 | ||
415 | static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i, | 415 | static 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 ec1e4c34c2..0b08167da8 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 afa9497cf0..935fa03269 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 f17c57a86d..0f3c940216 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); | |||
157 | extern void vorbis_comment_init(vorbis_comment *vc); | 157 | extern void vorbis_comment_init(vorbis_comment *vc); |
158 | extern void vorbis_comment_add(vorbis_comment *vc, char *comment); | 158 | extern void vorbis_comment_add(vorbis_comment *vc, char *comment); |
159 | extern void vorbis_comment_add_tag(vorbis_comment *vc, | 159 | extern void vorbis_comment_add_tag(vorbis_comment *vc, |
160 | char *tag, char *contents); | 160 | char *tag, char *contents); |
161 | extern void vorbis_comment_clear(vorbis_comment *vc); | 161 | extern void vorbis_comment_clear(vorbis_comment *vc); |
162 | 162 | ||
163 | extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb); | 163 | extern 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 *******************************/ |
168 | extern int vorbis_synthesis_idheader(ogg_packet *op); | 168 | extern int vorbis_synthesis_idheader(ogg_packet *op); |
169 | extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc, | 169 | extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc, |
170 | ogg_packet *op); | 170 | ogg_packet *op); |
171 | 171 | ||
172 | extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi); | 172 | extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi); |
173 | extern int vorbis_synthesis_restart(vorbis_dsp_state *v); | 173 | extern int vorbis_synthesis_restart(vorbis_dsp_state *v); |
diff --git a/apps/codecs/libtremor/ivorbisfile.h b/apps/codecs/libtremor/ivorbisfile.h index 9ff446ab10..4aa82cf9a0 100644 --- a/apps/codecs/libtremor/ivorbisfile.h +++ b/apps/codecs/libtremor/ivorbisfile.h | |||
@@ -89,11 +89,11 @@ typedef struct OggVorbis_File { | |||
89 | extern int ov_clear(OggVorbis_File *vf); | 89 | extern 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); |
91 | extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf, | 91 | extern 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); |
95 | extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf, | 95 | extern 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); |
97 | extern int ov_test_open(OggVorbis_File *vf); | 97 | extern int ov_test_open(OggVorbis_File *vf); |
98 | 98 | ||
99 | extern long ov_bitrate(OggVorbis_File *vf,int i); | 99 | extern long ov_bitrate(OggVorbis_File *vf,int i); |
@@ -120,7 +120,7 @@ extern vorbis_info *ov_info(OggVorbis_File *vf,int link); | |||
120 | extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link); | 120 | extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link); |
121 | 121 | ||
122 | extern long ov_read(OggVorbis_File *vf,char *buffer,int length, | 122 | extern long ov_read(OggVorbis_File *vf,char *buffer,int length, |
123 | int *bitstream); | 123 | int *bitstream); |
124 | extern long ov_read_fixed(OggVorbis_File *vf,ogg_int32_t ***pcm_channels, | 124 | extern 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 cced7c9282..42940bd39b 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 |
53 | static const long INVSQ_LOOKUP_I[64+1] ={ | 53 | static 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 | ||
73 | static const long INVSQ_LOOKUP_IDel[64] ={ | 73 | static const long INVSQ_LOOKUP_IDel[64] ={ |
@@ -93,39 +93,39 @@ 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 |
95 | static const ogg_int32_t COS_LOOKUP_I[COS_LOOKUP_I_SZ+1] ={ | 95 | static 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 |
diff --git a/apps/codecs/libtremor/misc.h b/apps/codecs/libtremor/misc.h index 59ce6dbb74..6e22f20008 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 | ||
138 | static inline void XPROD31(ogg_int32_t a, ogg_int32_t b, | 138 | static 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 | ||
146 | static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b, | 146 | static 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 | ||
219 | static inline ogg_int32_t VFLOAT_MULT(ogg_int32_t a,ogg_int32_t ap, | 219 | static 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 | ||
234 | static inline ogg_int32_t VFLOAT_MULTI(ogg_int32_t a,ogg_int32_t ap, | 234 | static 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 | ||
242 | static inline ogg_int32_t VFLOAT_ADD(ogg_int32_t a,ogg_int32_t ap, | 242 | static 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 853d1f5d61..10fae80c84 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 | } | 224 | } |
225 | 225 | ||
226 | if(sparsemap){ | 226 | if(sparsemap){ |
227 | r[sparsemap[count]*b->dim+k]=val; | 227 | r[sparsemap[count]*b->dim+k]=val; |
228 | rp[sparsemap[count]*b->dim+k]=point; | 228 | rp[sparsemap[count]*b->dim+k]=point; |
229 | }else{ | 229 | }else{ |
230 | r[count*b->dim+k]=val; | 230 | r[count*b->dim+k]=val; |
231 | rp[count*b->dim+k]=point; | 231 | rp[count*b->dim+k]=point; |
232 | } | 232 | } |
233 | if(*maxpoint<point)*maxpoint=point; | 233 | if(*maxpoint<point)*maxpoint=point; |
234 | indexdiv*=quantvals; | 234 | indexdiv*=quantvals; |
235 | } | 235 | } |
236 | count++; | 236 | count++; |
237 | } | 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 | } | 266 | } |
267 | if(*maxpoint<point)*maxpoint=point; | 267 | if(*maxpoint<point)*maxpoint=point; |
268 | } | 268 | } |
269 | count++; | 269 | count++; |
270 | } | 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 27647fe62e..f11742e1dd 100644 --- a/apps/codecs/libtremor/window.h +++ b/apps/codecs/libtremor/window.h | |||
@@ -20,8 +20,8 @@ | |||
20 | 20 | ||
21 | extern const void *_vorbis_window(int type,int left); | 21 | extern const void *_vorbis_window(int type,int left); |
22 | extern void _vorbis_apply_window(ogg_int32_t *d,const void *window[2], | 22 | extern 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 |