1
0
Fork 0
forked from len0rd/rockbox

Fix broken whitespace after r24862

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25031 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Nils Wallménius 2010-03-05 09:48:07 +00:00
parent 3c87824970
commit b382d8334b
13 changed files with 395 additions and 403 deletions

View file

@ -35,11 +35,11 @@ static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) { static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
int lo,hi; int lo,hi;
asm volatile("smull %0, %1, %2, %3\n\t" asm volatile("smull %0, %1, %2, %3\n\t"
"movs %0, %0, lsr #15\n\t" "movs %0, %0, lsr #15\n\t"
"adc %1, %0, %1, lsl #17\n\t" "adc %1, %0, %1, lsl #17\n\t"
: "=&r"(lo),"=&r"(hi) : "=&r"(lo),"=&r"(hi)
: "%r"(x),"r"(y) : "%r"(x),"r"(y)
: "cc"); : "cc");
return(hi); return(hi);
} }
@ -47,42 +47,42 @@ static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
{ \ { \
long l; \ long l; \
asm( "smull %0, %1, %4, %6\n\t" \ asm( "smull %0, %1, %4, %6\n\t" \
"rsb %3, %4, #0\n\t" \ "rsb %3, %4, #0\n\t" \
"smlal %0, %1, %5, %7\n\t" \ "smlal %0, %1, %5, %7\n\t" \
"smull %0, %2, %5, %6\n\t" \ "smull %0, %2, %5, %6\n\t" \
"smlal %0, %2, %3, %7" \ "smlal %0, %2, %3, %7" \
: "=&r" (l), "=&r" (x), "=&r" (y), "=r" ((a)) \ : "=&r" (l), "=&r" (x), "=&r" (y), "=r" ((a)) \
: "3" ((a)), "r" ((b)), "r" ((t)), "r" ((v)) ); \ : "3" ((a)), "r" ((b)), "r" ((t)), "r" ((v)) ); \
} }
static inline void XPROD31(ogg_int32_t a, ogg_int32_t b, static inline void XPROD31(ogg_int32_t a, ogg_int32_t b,
ogg_int32_t t, ogg_int32_t v, ogg_int32_t t, ogg_int32_t v,
ogg_int32_t *x, ogg_int32_t *y) ogg_int32_t *x, ogg_int32_t *y)
{ {
int x1, y1, l; int x1, y1, l;
asm( "smull %0, %1, %4, %6\n\t" asm( "smull %0, %1, %4, %6\n\t"
"rsb %3, %4, #0\n\t" "rsb %3, %4, #0\n\t"
"smlal %0, %1, %5, %7\n\t" "smlal %0, %1, %5, %7\n\t"
"smull %0, %2, %5, %6\n\t" "smull %0, %2, %5, %6\n\t"
"smlal %0, %2, %3, %7" "smlal %0, %2, %3, %7"
: "=&r" (l), "=&r" (x1), "=&r" (y1), "=r" (a) : "=&r" (l), "=&r" (x1), "=&r" (y1), "=r" (a)
: "3" (a), "r" (b), "r" (t), "r" (v) ); : "3" (a), "r" (b), "r" (t), "r" (v) );
*x = x1 << 1; *x = x1 << 1;
*y = y1 << 1; *y = y1 << 1;
} }
static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b, static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b,
ogg_int32_t t, ogg_int32_t v, ogg_int32_t t, ogg_int32_t v,
ogg_int32_t *x, ogg_int32_t *y) ogg_int32_t *x, ogg_int32_t *y)
{ {
int x1, y1, l; int x1, y1, l;
asm( "smull %0, %1, %3, %5\n\t" asm( "smull %0, %1, %3, %5\n\t"
"rsb %2, %4, #0\n\t" "rsb %2, %4, #0\n\t"
"smlal %0, %1, %2, %6\n\t" "smlal %0, %1, %2, %6\n\t"
"smull %0, %2, %4, %5\n\t" "smull %0, %2, %4, %5\n\t"
"smlal %0, %2, %3, %6" "smlal %0, %2, %3, %6"
: "=&r" (l), "=&r" (x1), "=&r" (y1) : "=&r" (l), "=&r" (x1), "=&r" (y1)
: "r" (a), "r" (b), "r" (t), "r" (v) ); : "r" (a), "r" (b), "r" (t), "r" (v) );
*x = x1 << 1; *x = x1 << 1;
*y = y1 << 1; *y = y1 << 1;
} }
@ -217,13 +217,13 @@ static inline void vect_copy(ogg_int32_t *x, const ogg_int32_t *y, int n)
static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) { static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
int tmp; int tmp;
asm volatile("subs %1, %0, #32768\n\t" asm volatile("subs %1, %0, #32768\n\t"
"movpl %0, #0x7f00\n\t" "movpl %0, #0x7f00\n\t"
"orrpl %0, %0, #0xff\n" "orrpl %0, %0, #0xff\n"
"adds %1, %0, #32768\n\t" "adds %1, %0, #32768\n\t"
"movmi %0, #0x8000" "movmi %0, #0x8000"
: "+r"(x),"=r"(tmp) : "+r"(x),"=r"(tmp)
: :
: "cc"); : "cc");
return(x); return(x);
} }
@ -233,9 +233,9 @@ static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
#define _V_LSP_MATH_ASM #define _V_LSP_MATH_ASM
static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip, static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip,
ogg_int32_t *qexpp, ogg_int32_t *qexpp,
ogg_int32_t *ilsp,ogg_int32_t wi, ogg_int32_t *ilsp,ogg_int32_t wi,
ogg_int32_t m){ ogg_int32_t m){
ogg_uint32_t qi=*qip,pi=*pip; ogg_uint32_t qi=*qip,pi=*pip;
ogg_int32_t qexp=*qexpp; ogg_int32_t qexp=*qexpp;
@ -289,9 +289,9 @@ static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip,
//qi=(pi>>shift)*labs(ilsp[j]-wi); //qi=(pi>>shift)*labs(ilsp[j]-wi);
//pi=(qi>>shift)*labs(ilsp[j+1]-wi); //pi=(qi>>shift)*labs(ilsp[j+1]-wi);
//qexp+=shift; //qexp+=shift;
//} //}
/* normalize to max 16 sig figs */ /* normalize to max 16 sig figs */
"2:" "2:"
"mov r2,#0;" "mov r2,#0;"

View file

@ -34,12 +34,12 @@
typedef struct{ typedef struct{
vorbis_info_floor *(*unpack)(vorbis_info *,oggpack_buffer *); vorbis_info_floor *(*unpack)(vorbis_info *,oggpack_buffer *);
vorbis_look_floor *(*look) (vorbis_dsp_state *,vorbis_info_mode *, vorbis_look_floor *(*look) (vorbis_dsp_state *,vorbis_info_mode *,
vorbis_info_floor *); vorbis_info_floor *);
void (*free_info) (vorbis_info_floor *); void (*free_info) (vorbis_info_floor *);
void (*free_look) (vorbis_look_floor *); void (*free_look) (vorbis_look_floor *);
void *(*inverse1) (struct vorbis_block *,vorbis_look_floor *); void *(*inverse1) (struct vorbis_block *,vorbis_look_floor *);
int (*inverse2) (struct vorbis_block *,vorbis_look_floor *, int (*inverse2) (struct vorbis_block *,vorbis_look_floor *,
void *buffer,ogg_int32_t *); void *buffer,ogg_int32_t *);
} vorbis_func_floor; } vorbis_func_floor;
typedef struct{ typedef struct{
@ -77,11 +77,11 @@ typedef struct{
typedef struct{ typedef struct{
vorbis_info_residue *(*unpack)(vorbis_info *,oggpack_buffer *); vorbis_info_residue *(*unpack)(vorbis_info *,oggpack_buffer *);
vorbis_look_residue *(*look) (vorbis_dsp_state *,vorbis_info_mode *, vorbis_look_residue *(*look) (vorbis_dsp_state *,vorbis_info_mode *,
vorbis_info_residue *); vorbis_info_residue *);
void (*free_info) (vorbis_info_residue *); void (*free_info) (vorbis_info_residue *);
void (*free_look) (vorbis_look_residue *); void (*free_look) (vorbis_look_residue *);
int (*inverse) (struct vorbis_block *,vorbis_look_residue *, int (*inverse) (struct vorbis_block *,vorbis_look_residue *,
ogg_int32_t **,int *,int); ogg_int32_t **,int *,int);
} vorbis_func_residue; } vorbis_func_residue;
typedef struct vorbis_info_residue0{ typedef struct vorbis_info_residue0{
@ -101,7 +101,7 @@ typedef struct vorbis_info_residue0{
typedef struct{ typedef struct{
vorbis_info_mapping *(*unpack)(vorbis_info *,oggpack_buffer *); vorbis_info_mapping *(*unpack)(vorbis_info *,oggpack_buffer *);
vorbis_look_mapping *(*look) (vorbis_dsp_state *,vorbis_info_mode *, vorbis_look_mapping *(*look) (vorbis_dsp_state *,vorbis_info_mode *,
vorbis_info_mapping *); vorbis_info_mapping *);
void (*free_info) (vorbis_info_mapping *); void (*free_info) (vorbis_info_mapping *);
void (*free_look) (vorbis_look_mapping *); void (*free_look) (vorbis_look_mapping *);
int (*inverse) (struct vorbis_block *vb,vorbis_look_mapping *); int (*inverse) (struct vorbis_block *vb,vorbis_look_mapping *);

View file

@ -49,19 +49,19 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
/* yes, unused entries */ /* yes, unused entries */
for(i=0;i<s->entries;i++){ for(i=0;i<s->entries;i++){
if(oggpack_read(opb,1)){ if(oggpack_read(opb,1)){
long num=oggpack_read(opb,5); long num=oggpack_read(opb,5);
if(num==-1)goto _eofout; if(num==-1)goto _eofout;
s->lengthlist[i]=num+1; s->lengthlist[i]=num+1;
}else }else
s->lengthlist[i]=0; s->lengthlist[i]=0;
} }
}else{ }else{
/* all entries used; no tagging */ /* all entries used; no tagging */
for(i=0;i<s->entries;i++){ for(i=0;i<s->entries;i++){
long num=oggpack_read(opb,5); long num=oggpack_read(opb,5);
if(num==-1)goto _eofout; if(num==-1)goto _eofout;
s->lengthlist[i]=num+1; s->lengthlist[i]=num+1;
} }
} }
@ -73,11 +73,11 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries); s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries);
for(i=0;i<s->entries;){ for(i=0;i<s->entries;){
long num=oggpack_read(opb,_ilog(s->entries-i)); long num=oggpack_read(opb,_ilog(s->entries-i));
if(num==-1)goto _eofout; if(num==-1)goto _eofout;
for(j=0;j<num && i<s->entries;j++,i++) for(j=0;j<num && i<s->entries;j++,i++)
s->lengthlist[i]=length; s->lengthlist[i]=length;
length++; length++;
} }
} }
break; break;
@ -104,17 +104,17 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
int quantvals=0; int quantvals=0;
switch(s->maptype){ switch(s->maptype){
case 1: case 1:
quantvals=_book_maptype1_quantvals(s); quantvals=_book_maptype1_quantvals(s);
break; break;
case 2: case 2:
quantvals=s->entries*s->dim; quantvals=s->entries*s->dim;
break; break;
} }
/* quantized values */ /* quantized values */
s->quantlist=(long *)_ogg_malloc(sizeof(*s->quantlist)*quantvals); s->quantlist=(long *)_ogg_malloc(sizeof(*s->quantlist)*quantvals);
for(i=0;i<quantvals;i++) for(i=0;i<quantvals;i++)
s->quantlist[i]=oggpack_read(opb,s->q_quant); s->quantlist[i]=oggpack_read(opb,s->q_quant);
if(quantvals&&s->quantlist[quantvals-1]==-1)goto _eofout; if(quantvals&&s->quantlist[quantvals-1]==-1)goto _eofout;
} }
@ -216,7 +216,7 @@ static inline ogg_uint32_t bitreverse(register ogg_uint32_t x)
} }
STIN long decode_packed_entry_number(codebook *book, STIN long decode_packed_entry_number(codebook *book,
oggpack_buffer *b){ oggpack_buffer *b){
int read=book->dec_maxlength; int read=book->dec_maxlength;
long lo,hi; long lo,hi;
long lok = oggpack_look(b,book->dec_firsttablen); long lok = oggpack_look(b,book->dec_firsttablen);
@ -284,43 +284,39 @@ static long decode_packed_block(codebook *book, oggpack_buffer *b,
ptr = (ogg_uint32_t *)(adr&~3); ptr = (ogg_uint32_t *)(adr&~3);
bitend = ((adr&3)+b->headend)*8; bitend = ((adr&3)+b->headend)*8;
while (bufptr<bufend){ while (bufptr<bufend){
long entry, lo, hi; long entry, lo, hi;
if (UNLIKELY(cachesize<book->dec_maxlength)) { if (UNLIKELY(cachesize<book->dec_maxlength)) {
if (bit-cachesize+32>=bitend) if (bit-cachesize+32>=bitend)
break; break;
bit-=cachesize; bit-=cachesize;
cache=letoh32(ptr[bit>>5]) >> (bit&31); cache=letoh32(ptr[bit>>5]) >> (bit&31);
if (bit&31) if (bit&31)
cache|=letoh32(ptr[(bit>>5)+1]) << (32-(bit&31)); cache|=letoh32(ptr[(bit>>5)+1]) << (32-(bit&31));
cachesize=32; cachesize=32;
bit+=32; bit+=32;
} }
entry=book->dec_firsttable[cache&((1<<book->dec_firsttablen)-1)]; entry=book->dec_firsttable[cache&((1<<book->dec_firsttablen)-1)];
if(UNLIKELY(entry&0x80000000UL)){ if(UNLIKELY(entry&0x80000000UL)){
lo=(entry>>15)&0x7fff; lo=(entry>>15)&0x7fff;
hi=book->used_entries-(entry&0x7fff); hi=book->used_entries-(entry&0x7fff);
{ ogg_uint32_t testword=bitreverse((ogg_uint32_t)cache);
ogg_uint32_t testword=bitreverse((ogg_uint32_t)cache);
while(LIKELY(hi-lo>1)){
while(LIKELY(hi-lo>1)){ long p=(hi-lo)>>1;
long p=(hi-lo)>>1; if (book->codelist[lo+p]>testword)
if (book->codelist[lo+p]>testword) hi-=p;
hi-=p; else
else lo+=p;
lo+=p;
}
entry=lo;
} }
}else entry=lo;
entry--; }else
entry--;
*bufptr++=entry; *bufptr++=entry;
{ int l=book->dec_codelengths[entry];
int l=book->dec_codelengths[entry]; cachesize-=l;
cachesize-=l; cache>>=l;
cache>>=l;
}
} }
adr=(unsigned long)b->headptr; adr=(unsigned long)b->headptr;
@ -366,7 +362,7 @@ long vorbis_book_decode(codebook *book, oggpack_buffer *b){
/* returns 0 on OK or -1 on eof *************************************/ /* returns 0 on OK or -1 on eof *************************************/
long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a, long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a,
oggpack_buffer *b,int n,int point){ oggpack_buffer *b,int n,int point){
if(book->used_entries>0){ if(book->used_entries>0){
int step=n/book->dim; int step=n/book->dim;
long *entry = (long *)alloca(sizeof(*entry)*step); long *entry = (long *)alloca(sizeof(*entry)*step);
@ -376,29 +372,29 @@ long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a,
if(shift>=0){ if(shift>=0){
for (i = 0; i < step; i++) { for (i = 0; i < step; i++) {
entry[i]=decode_packed_entry_number(book,b); entry[i]=decode_packed_entry_number(book,b);
if(entry[i]==-1)return(-1); if(entry[i]==-1)return(-1);
t[i] = book->valuelist+entry[i]*book->dim; t[i] = book->valuelist+entry[i]*book->dim;
} }
for(i=0,o=0;i<book->dim;i++,o+=step) for(i=0,o=0;i<book->dim;i++,o+=step)
for (j=0;j<step;j++) for (j=0;j<step;j++)
a[o+j]+=t[j][i]>>shift; a[o+j]+=t[j][i]>>shift;
}else{ }else{
for (i = 0; i < step; i++) { for (i = 0; i < step; i++) {
entry[i]=decode_packed_entry_number(book,b); entry[i]=decode_packed_entry_number(book,b);
if(entry[i]==-1)return(-1); if(entry[i]==-1)return(-1);
t[i] = book->valuelist+entry[i]*book->dim; t[i] = book->valuelist+entry[i]*book->dim;
} }
for(i=0,o=0;i<book->dim;i++,o+=step) for(i=0,o=0;i<book->dim;i++,o+=step)
for (j=0;j<step;j++) for (j=0;j<step;j++)
a[o+j]+=t[j][i]<<-shift; a[o+j]+=t[j][i]<<-shift;
} }
} }
return(0); return(0);
} }
long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a, long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a,
oggpack_buffer *b,int n,int point){ oggpack_buffer *b,int n,int point){
if(book->used_entries>0){ if(book->used_entries>0){
int i,j,entry; int i,j,entry;
ogg_int32_t *t; ogg_int32_t *t;
@ -406,20 +402,20 @@ long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a,
if(shift>=0){ if(shift>=0){
for(i=0;i<n;){ for(i=0;i<n;){
entry = decode_packed_entry_number(book,b); entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1); if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim; t = book->valuelist+entry*book->dim;
for (j=0;j<book->dim;) for (j=0;j<book->dim;)
a[i++]+=t[j++]>>shift; a[i++]+=t[j++]>>shift;
} }
}else{ }else{
shift = -shift; shift = -shift;
for(i=0;i<n;){ for(i=0;i<n;){
entry = decode_packed_entry_number(book,b); entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1); if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim; t = book->valuelist+entry*book->dim;
for (j=0;j<book->dim;) for (j=0;j<book->dim;)
a[i++]+=t[j++]<<shift; a[i++]+=t[j++]<<shift;
} }
} }
} }
@ -427,7 +423,7 @@ long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a,
} }
long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a, long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a,
oggpack_buffer *b,int n,int point){ oggpack_buffer *b,int n,int point){
if(book->used_entries>0){ if(book->used_entries>0){
int i,j,entry; int i,j,entry;
ogg_int32_t *t; ogg_int32_t *t;
@ -436,22 +432,22 @@ long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a,
if(shift>=0){ if(shift>=0){
for(i=0;i<n;){ for(i=0;i<n;){
entry = decode_packed_entry_number(book,b); entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1); if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim; t = book->valuelist+entry*book->dim;
for (j=0;j<book->dim;){ for (j=0;j<book->dim;){
a[i++]=t[j++]>>shift; a[i++]=t[j++]>>shift;
} }
} }
}else{ }else{
shift = -shift; shift = -shift;
for(i=0;i<n;){ for(i=0;i<n;){
entry = decode_packed_entry_number(book,b); entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1); if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim; t = book->valuelist+entry*book->dim;
for (j=0;j<book->dim;){ for (j=0;j<book->dim;){
a[i++]=t[j++]<<shift; a[i++]=t[j++]<<shift;
} }
} }
} }
}else{ }else{
@ -459,7 +455,7 @@ long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a,
int i,j; int i,j;
for(i=0;i<n;){ for(i=0;i<n;){
for (j=0;j<book->dim;){ for (j=0;j<book->dim;){
a[i++]=0; a[i++]=0;
} }
} }
} }
@ -516,8 +512,8 @@ static long vorbis_book_decodevv_add_2ch_even(codebook *book,ogg_int32_t **a,
} }
long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a, long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,
long offset,int ch, long offset,int ch,
oggpack_buffer *b,int n,int point){ oggpack_buffer *b,int n,int point){
if(LIKELY(book->used_entries>0)){ if(LIKELY(book->used_entries>0)){
long i,j,k,chunk,read; long i,j,k,chunk,read;
int chptr=0; int chptr=0;
@ -535,14 +531,14 @@ long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,
chunk=((offset+n-i)*ch+book->dim-1)/book->dim; chunk=((offset+n-i)*ch+book->dim-1)/book->dim;
read = decode_packed_block(book,b,entries,chunk); read = decode_packed_block(book,b,entries,chunk);
for(k=0;k<read;k++){ for(k=0;k<read;k++){
const ogg_int32_t *t = book->valuelist+entries[k]*book->dim; const ogg_int32_t *t = book->valuelist+entries[k]*book->dim;
for (j=0;j<book->dim;j++){ for (j=0;j<book->dim;j++){
a[chptr++][i]+=t[j]>>shift; a[chptr++][i]+=t[j]>>shift;
if(chptr==ch){ if(chptr==ch){
chptr=0; chptr=0;
i++; i++;
} }
} }
} }
if (read<chunk)return-1; if (read<chunk)return-1;
} }
@ -554,14 +550,14 @@ long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,
chunk=((offset+n-i)*ch+book->dim-1)/book->dim; chunk=((offset+n-i)*ch+book->dim-1)/book->dim;
read = decode_packed_block(book,b,entries,chunk); read = decode_packed_block(book,b,entries,chunk);
for(k=0;k<read;k++){ for(k=0;k<read;k++){
const ogg_int32_t *t = book->valuelist+entries[k]*book->dim; const ogg_int32_t *t = book->valuelist+entries[k]*book->dim;
for (j=0;j<book->dim;j++){ for (j=0;j<book->dim;j++){
a[chptr++][i]+=t[j]<<shift; a[chptr++][i]+=t[j]<<shift;
if(chptr==ch){ if(chptr==ch){
chptr=0; chptr=0;
i++; i++;
} }
} }
} }
if (read<chunk)return-1; if (read<chunk)return-1;
} }

View file

@ -40,8 +40,8 @@ typedef struct static_codebook{
/* mapping ***************************************************************/ /* mapping ***************************************************************/
int maptype; /* 0=none int maptype; /* 0=none
1=implicitly populated values from map column 1=implicitly populated values from map column
2=listed arbitrary values */ 2=listed arbitrary values */
/* The below does a linear, single monotonic sequence mapping. */ /* The below does a linear, single monotonic sequence mapping. */
long q_min; /* packed 32 bit float; quant value 0 maps to minval */ long q_min; /* packed 32 bit float; quant value 0 maps to minval */
@ -50,8 +50,8 @@ typedef struct static_codebook{
int q_sequencep; /* bitflag */ int q_sequencep; /* bitflag */
long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map
map == 2: list of dim*entries quantized entry vals map == 2: list of dim*entries quantized entry vals
*/ */
} static_codebook; } static_codebook;
typedef struct codebook{ typedef struct codebook{
@ -87,14 +87,14 @@ extern int vorbis_staticbook_unpack(oggpack_buffer *b,static_codebook *c);
extern long vorbis_book_decode(codebook *book, oggpack_buffer *b); extern long vorbis_book_decode(codebook *book, oggpack_buffer *b);
extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a, extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a,
oggpack_buffer *b,int n,int point); oggpack_buffer *b,int n,int point);
extern long vorbis_book_decodev_set(codebook *book, ogg_int32_t *a, extern long vorbis_book_decodev_set(codebook *book, ogg_int32_t *a,
oggpack_buffer *b,int n,int point); oggpack_buffer *b,int n,int point);
extern long vorbis_book_decodev_add(codebook *book, ogg_int32_t *a, extern long vorbis_book_decodev_add(codebook *book, ogg_int32_t *a,
oggpack_buffer *b,int n,int point); oggpack_buffer *b,int n,int point);
extern long vorbis_book_decodevv_add(codebook *book, ogg_int32_t **a, extern long vorbis_book_decodevv_add(codebook *book, ogg_int32_t **a,
long off,int ch, long off,int ch,
oggpack_buffer *b,int n,int point); oggpack_buffer *b,int n,int point);
extern int _ilog(unsigned int v); extern int _ilog(unsigned int v);

View file

@ -74,7 +74,7 @@ static inline ogg_int32_t vorbis_coslook_i(long a){
int i=a>>COS_LOOKUP_I_SHIFT; int i=a>>COS_LOOKUP_I_SHIFT;
int d=a&COS_LOOKUP_I_MASK; int d=a&COS_LOOKUP_I_MASK;
return COS_LOOKUP_I[i]- ((d*(COS_LOOKUP_I[i]-COS_LOOKUP_I[i+1]))>> return COS_LOOKUP_I[i]- ((d*(COS_LOOKUP_I[i]-COS_LOOKUP_I[i+1]))>>
COS_LOOKUP_I_SHIFT); COS_LOOKUP_I_SHIFT);
} }
/* interpolated lookup based cos function */ /* 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,
qi=((qi*qi)>>16); qi=((qi*qi)>>16);
if(m&1){ if(m&1){
qexp= qexp*2-28*((m+1)>>1)+m; qexp= qexp*2-28*((m+1)>>1)+m;
pi*=(1<<14)-((wi*wi)>>14); pi*=(1<<14)-((wi*wi)>>14);
qi+=pi>>14; qi+=pi>>14;
}else{ }else{
@ -205,15 +205,15 @@ static void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
for(j=3;j<m;j+=2){ for(j=3;j<m;j+=2){
if(!(shift=MLOOP_1[(pi|qi)>>25])) if(!(shift=MLOOP_1[(pi|qi)>>25]))
if(!(shift=MLOOP_2[(pi|qi)>>19])) if(!(shift=MLOOP_2[(pi|qi)>>19]))
shift=MLOOP_3[(pi|qi)>>16]; shift=MLOOP_3[(pi|qi)>>16];
qi=(qi>>shift)*labs(ilsp[j-1]-wi); qi=(qi>>shift)*labs(ilsp[j-1]-wi);
pi=(pi>>shift)*labs(ilsp[j]-wi); pi=(pi>>shift)*labs(ilsp[j]-wi);
qexp+=shift; qexp+=shift;
} }
if(!(shift=MLOOP_1[(pi|qi)>>25])) if(!(shift=MLOOP_1[(pi|qi)>>25]))
if(!(shift=MLOOP_2[(pi|qi)>>19])) if(!(shift=MLOOP_2[(pi|qi)>>19]))
shift=MLOOP_3[(pi|qi)>>16]; shift=MLOOP_3[(pi|qi)>>16];
/* pi,qi normalized collectively, both tracked using qexp */ /* pi,qi normalized collectively, both tracked using qexp */
@ -225,8 +225,8 @@ static void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
qexp+=shift; qexp+=shift;
if(!(shift=MLOOP_1[(pi|qi)>>25])) if(!(shift=MLOOP_1[(pi|qi)>>25]))
if(!(shift=MLOOP_2[(pi|qi)>>19])) if(!(shift=MLOOP_2[(pi|qi)>>19]))
shift=MLOOP_3[(pi|qi)>>16]; shift=MLOOP_3[(pi|qi)>>16];
pi>>=shift; pi>>=shift;
qi>>=shift; qi>>=shift;
@ -243,7 +243,7 @@ static void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
/* even order filter; still symmetric */ /* even order filter; still symmetric */
/* p*=p(1-w), q*=q(1+w), let normalization drift because it isn't /* p*=p(1-w), q*=q(1+w), let normalization drift because it isn't
worth tracking step by step */ worth tracking step by step */
pi>>=shift; pi>>=shift;
qi>>=shift; qi>>=shift;
@ -268,15 +268,15 @@ static void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
qi>>=1; qexp++; qi>>=1; qexp++;
}else }else
while(qi && !(qi&0x8000)){ /* checks for 0.0xxxxxxxxxxxxxxx or less*/ while(qi && !(qi&0x8000)){ /* checks for 0.0xxxxxxxxxxxxxxx or less*/
qi<<=1; qexp--; qi<<=1; qexp--;
} }
#endif #endif
amp=vorbis_fromdBlook_i(ampi* /* n.4 */ amp=vorbis_fromdBlook_i(ampi* /* n.4 */
vorbis_invsqlook_i(qi,qexp)- vorbis_invsqlook_i(qi,qexp)-
/* m.8, m+n<=8 */ /* m.8, m+n<=8 */
ampoffseti); /* 8.12[0] */ ampoffseti); /* 8.12[0] */
#ifdef _LOW_ACCURACY_ #ifdef _LOW_ACCURACY_
amp>>=9; amp>>=9;
@ -366,7 +366,7 @@ static vorbis_look_floor *floor0_look (vorbis_dsp_state *vd,vorbis_info_mode *mi
for(j=0;j<look->n;j++){ for(j=0;j<look->n;j++){
int val=(look->ln* int val=(look->ln*
((toBARK(info->rate/2*j/look->n)<<11)/toBARK(info->rate/2)))>>11; ((toBARK(info->rate/2*j/look->n)<<11)/toBARK(info->rate/2)))>>11;
if(val>=look->ln)val=look->ln-1; /* guard against the approximation */ if(val>=look->ln)val=look->ln-1; /* guard against the approximation */
look->linearmap[j]=val; look->linearmap[j]=val;
@ -398,10 +398,10 @@ static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){
ogg_int32_t *lsp=(ogg_int32_t *)_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+1)); ogg_int32_t *lsp=(ogg_int32_t *)_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+1));
for(j=0;j<look->m;j+=b->dim) for(j=0;j<look->m;j+=b->dim)
if(vorbis_book_decodev_set(b,lsp+j,&vb->opb,b->dim,-24)==-1)goto eop; if(vorbis_book_decodev_set(b,lsp+j,&vb->opb,b->dim,-24)==-1)goto eop;
for(j=0;j<look->m;){ for(j=0;j<look->m;){
for(k=0;k<b->dim;k++,j++)lsp[j]+=last; for(k=0;k<b->dim;k++,j++)lsp[j]+=last;
last=lsp[j-1]; last=lsp[j-1];
} }
lsp[look->m]=amp; lsp[look->m]=amp;
@ -413,7 +413,7 @@ static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){
} }
static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i, static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i,
void *memo,ogg_int32_t *out){ void *memo,ogg_int32_t *out){
vorbis_look_floor0 *look=(vorbis_look_floor0 *)i; vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
vorbis_info_floor0 *info=look->vi; vorbis_info_floor0 *info=look->vi;
(void)vb; (void)vb;
@ -424,7 +424,7 @@ static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i,
/* take the coefficients back to a spectral envelope curve */ /* take the coefficients back to a spectral envelope curve */
vorbis_lsp_to_curve(out,look->linearmap,look->n,look->ln, vorbis_lsp_to_curve(out,look->linearmap,look->n,look->ln,
lsp,look->m,amp,info->ampdB,look->lsp_look); lsp,look->m,amp,info->ampdB,look->lsp_look);
return(1); return(1);
} }
memset(out,0,sizeof(*out)*look->n); memset(out,0,sizeof(*out)*look->n);

View file

@ -1003,11 +1003,11 @@ STATICIRAM_NOT_MDCT int _packetout(ogg_stream_state *os,ogg_packet *op,int adv){
/* split the body contents off */ /* split the body contents off */
if(op){ if(op){
op->packet=ogg_buffer_split(&os->body_tail,&os->body_head, op->packet=ogg_buffer_split(&os->body_tail,&os->body_head,
os->body_fill&FINMASK); os->body_fill&FINMASK);
op->bytes=os->body_fill&FINMASK; op->bytes=os->body_fill&FINMASK;
}else{ }else{
os->body_tail=ogg_buffer_pretruncate(os->body_tail, os->body_tail=ogg_buffer_pretruncate(os->body_tail,
os->body_fill&FINMASK); os->body_fill&FINMASK);
if(os->body_tail==0)os->body_head=0; if(os->body_tail==0)os->body_head=0;
} }

View file

@ -47,7 +47,7 @@ void vorbis_comment_clear(vorbis_comment *vc){
for(i=0;i<vc->comments;i++) for(i=0;i<vc->comments;i++)
if(vc->user_comments[i])_ogg_free(vc->user_comments[i]); if(vc->user_comments[i])_ogg_free(vc->user_comments[i]);
if(vc->user_comments)_ogg_free(vc->user_comments); if(vc->user_comments)_ogg_free(vc->user_comments);
if(vc->comment_lengths)_ogg_free(vc->comment_lengths); if(vc->comment_lengths)_ogg_free(vc->comment_lengths);
if(vc->vendor)_ogg_free(vc->vendor); if(vc->vendor)_ogg_free(vc->vendor);
memset(vc,0,sizeof(*vc)); memset(vc,0,sizeof(*vc));
} }
@ -77,26 +77,26 @@ void vorbis_info_clear(vorbis_info *vi){
for(i=0;i<ci->maps;i++) /* unpack does the range checking */ for(i=0;i<ci->maps;i++) /* unpack does the range checking */
if(ci->map_param[i]) if(ci->map_param[i])
_mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]); _mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]);
for(i=0;i<ci->floors;i++) /* unpack does the range checking */ for(i=0;i<ci->floors;i++) /* unpack does the range checking */
if(ci->floor_param[i]) if(ci->floor_param[i])
_floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]); _floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]);
for(i=0;i<ci->residues;i++) /* unpack does the range checking */ for(i=0;i<ci->residues;i++) /* unpack does the range checking */
if(ci->residue_param[i]) if(ci->residue_param[i])
_residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]); _residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]);
for(i=0;i<ci->books;i++){ for(i=0;i<ci->books;i++){
if(ci->book_param[i]){ if(ci->book_param[i]){
/* knows if the book was not alloced */ /* knows if the book was not alloced */
vorbis_staticbook_destroy(ci->book_param[i]); vorbis_staticbook_destroy(ci->book_param[i]);
} }
if(ci->fullbooks) if(ci->fullbooks)
vorbis_book_clear(ci->fullbooks+i); vorbis_book_clear(ci->fullbooks+i);
} }
if(ci->fullbooks) if(ci->fullbooks)
_ogg_free(ci->fullbooks); _ogg_free(ci->fullbooks);
_ogg_free(ci); _ogg_free(ci);
} }
@ -278,42 +278,42 @@ int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,ogg_packet *op)
memset(buffer,0,6); memset(buffer,0,6);
_v_readstring(&opb,buffer,6); _v_readstring(&opb,buffer,6);
if(memcmp(buffer,"vorbis",6)){ if(memcmp(buffer,"vorbis",6)){
/* not a vorbis header */ /* not a vorbis header */
return(OV_ENOTVORBIS); return(OV_ENOTVORBIS);
} }
switch(packtype){ switch(packtype){
case 0x01: /* least significant *bit* is read first */ case 0x01: /* least significant *bit* is read first */
if(!op->b_o_s){ if(!op->b_o_s){
/* Not the initial packet */ /* Not the initial packet */
return(OV_EBADHEADER); return(OV_EBADHEADER);
} }
if(vi->rate!=0){ if(vi->rate!=0){
/* previously initialized info header */ /* previously initialized info header */
return(OV_EBADHEADER); return(OV_EBADHEADER);
} }
return(_vorbis_unpack_info(vi,&opb)); return(_vorbis_unpack_info(vi,&opb));
case 0x03: /* least significant *bit* is read first */ case 0x03: /* least significant *bit* is read first */
if(vi->rate==0){ if(vi->rate==0){
/* um... we didn't get the initial header */ /* um... we didn't get the initial header */
return(OV_EBADHEADER); return(OV_EBADHEADER);
} }
return(_vorbis_unpack_comment(vc,&opb)); return(_vorbis_unpack_comment(vc,&opb));
case 0x05: /* least significant *bit* is read first */ case 0x05: /* least significant *bit* is read first */
if(vi->rate==0 || vc->vendor==NULL){ if(vi->rate==0 || vc->vendor==NULL){
/* um... we didn;t get the initial header or comments yet */ /* um... we didn;t get the initial header or comments yet */
return(OV_EBADHEADER); return(OV_EBADHEADER);
} }
return(_vorbis_unpack_books(vi,&opb)); return(_vorbis_unpack_books(vi,&opb));
default: default:
/* Not a valid vorbis header type */ /* Not a valid vorbis header type */
return(OV_EBADHEADER); return(OV_EBADHEADER);
break; break;
} }
} }
} }

View file

@ -157,7 +157,7 @@ extern int vorbis_info_blocksize(vorbis_info *vi,int zo);
extern void vorbis_comment_init(vorbis_comment *vc); extern void vorbis_comment_init(vorbis_comment *vc);
extern void vorbis_comment_add(vorbis_comment *vc, char *comment); extern void vorbis_comment_add(vorbis_comment *vc, char *comment);
extern void vorbis_comment_add_tag(vorbis_comment *vc, extern void vorbis_comment_add_tag(vorbis_comment *vc,
char *tag, char *contents); char *tag, char *contents);
extern void vorbis_comment_clear(vorbis_comment *vc); extern void vorbis_comment_clear(vorbis_comment *vc);
extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb); 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);
/* Vorbis PRIMITIVES: synthesis layer *******************************/ /* Vorbis PRIMITIVES: synthesis layer *******************************/
extern int vorbis_synthesis_idheader(ogg_packet *op); extern int vorbis_synthesis_idheader(ogg_packet *op);
extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc, extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,
ogg_packet *op); ogg_packet *op);
extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi); extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi);
extern int vorbis_synthesis_restart(vorbis_dsp_state *v); extern int vorbis_synthesis_restart(vorbis_dsp_state *v);

View file

@ -89,11 +89,11 @@ typedef struct OggVorbis_File {
extern int ov_clear(OggVorbis_File *vf); extern int ov_clear(OggVorbis_File *vf);
//extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); //extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf, extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf,
char *initial, long ibytes, ov_callbacks callbacks); char *initial, long ibytes, ov_callbacks callbacks);
//extern int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); //extern int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf, extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf,
char *initial, long ibytes, ov_callbacks callbacks); char *initial, long ibytes, ov_callbacks callbacks);
extern int ov_test_open(OggVorbis_File *vf); extern int ov_test_open(OggVorbis_File *vf);
extern long ov_bitrate(OggVorbis_File *vf,int i); extern long ov_bitrate(OggVorbis_File *vf,int i);
@ -120,7 +120,7 @@ extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link); extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link);
extern long ov_read(OggVorbis_File *vf,char *buffer,int length, extern long ov_read(OggVorbis_File *vf,char *buffer,int length,
int *bitstream); int *bitstream);
extern long ov_read_fixed(OggVorbis_File *vf,ogg_int32_t ***pcm_channels, extern long ov_read_fixed(OggVorbis_File *vf,ogg_int32_t ***pcm_channels,
int length,int *bitstream); int length,int *bitstream);

View file

@ -51,23 +51,23 @@ static const ogg_int32_t FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ] ={
#define INVSQ_LOOKUP_I_SHIFT 10 #define INVSQ_LOOKUP_I_SHIFT 10
#define INVSQ_LOOKUP_I_MASK 1023 #define INVSQ_LOOKUP_I_MASK 1023
static const long INVSQ_LOOKUP_I[64+1] ={ static const long INVSQ_LOOKUP_I[64+1] ={
92682, 91966, 91267, 90583, 92682, 91966, 91267, 90583,
89915, 89261, 88621, 87995, 89915, 89261, 88621, 87995,
87381, 86781, 86192, 85616, 87381, 86781, 86192, 85616,
85051, 84497, 83953, 83420, 85051, 84497, 83953, 83420,
82897, 82384, 81880, 81385, 82897, 82384, 81880, 81385,
80899, 80422, 79953, 79492, 80899, 80422, 79953, 79492,
79039, 78594, 78156, 77726, 79039, 78594, 78156, 77726,
77302, 76885, 76475, 76072, 77302, 76885, 76475, 76072,
75674, 75283, 74898, 74519, 75674, 75283, 74898, 74519,
74146, 73778, 73415, 73058, 74146, 73778, 73415, 73058,
72706, 72359, 72016, 71679, 72706, 72359, 72016, 71679,
71347, 71019, 70695, 70376, 71347, 71019, 70695, 70376,
70061, 69750, 69444, 69141, 70061, 69750, 69444, 69141,
68842, 68548, 68256, 67969, 68842, 68548, 68256, 67969,
67685, 67405, 67128, 66855, 67685, 67405, 67128, 66855,
66585, 66318, 66054, 65794, 66585, 66318, 66054, 65794,
65536, 65536,
}; };
static const long INVSQ_LOOKUP_IDel[64] ={ static const long INVSQ_LOOKUP_IDel[64] ={
@ -93,44 +93,40 @@ static const long INVSQ_LOOKUP_IDel[64] ={
#define COS_LOOKUP_I_MASK 511 #define COS_LOOKUP_I_MASK 511
#define COS_LOOKUP_I_SZ 128 #define COS_LOOKUP_I_SZ 128
static const ogg_int32_t COS_LOOKUP_I[COS_LOOKUP_I_SZ+1] ={ static const ogg_int32_t COS_LOOKUP_I[COS_LOOKUP_I_SZ+1] ={
16384, 16379, 16364, 16340, 16384, 16379, 16364, 16340,
16305, 16261, 16207, 16143, 16305, 16261, 16207, 16143,
16069, 15986, 15893, 15791, 16069, 15986, 15893, 15791,
15679, 15557, 15426, 15286, 15679, 15557, 15426, 15286,
15137, 14978, 14811, 14635, 15137, 14978, 14811, 14635,
14449, 14256, 14053, 13842, 14449, 14256, 14053, 13842,
13623, 13395, 13160, 12916, 13623, 13395, 13160, 12916,
12665, 12406, 12140, 11866, 12665, 12406, 12140, 11866,
11585, 11297, 11003, 10702, 11585, 11297, 11003, 10702,
10394, 10080, 9760, 9434, 10394, 10080, 9760, 9434,
9102, 8765, 8423, 8076, 9102, 8765, 8423, 8076,
7723, 7366, 7005, 6639, 7723, 7366, 7005, 6639,
6270, 5897, 5520, 5139, 6270, 5897, 5520, 5139,
4756, 4370, 3981, 3590, 4756, 4370, 3981, 3590,
3196, 2801, 2404, 2006, 3196, 2801, 2404, 2006,
1606, 1205, 804, 402, 1606, 1205, 804, 402,
0, -401, -803, -1204, 0, -401, -803, -1204,
-1605, -2005, -2403, -2800, -1605, -2005, -2403, -2800,
-3195, -3589, -3980, -4369, -3195, -3589, -3980, -4369,
-4755, -5138, -5519, -5896, -4755, -5138, -5519, -5896,
-6269, -6638, -7004, -7365, -6269, -6638, -7004, -7365,
-7722, -8075, -8422, -8764, -7722, -8075, -8422, -8764,
-9101, -9433, -9759, -10079, -9101, -9433, -9759, -10079,
-10393, -10701, -11002, -11296, -10393, -10701, -11002, -11296,
-11584, -11865, -12139, -12405, -11584, -11865, -12139, -12405,
-12664, -12915, -13159, -13394, -12664, -12915, -13159, -13394,
-13622, -13841, -14052, -14255, -13622, -13841, -14052, -14255,
-14448, -14634, -14810, -14977, -14448, -14634, -14810, -14977,
-15136, -15285, -15425, -15556, -15136, -15285, -15425, -15556,
-15678, -15790, -15892, -15985, -15678, -15790, -15892, -15985,
-16068, -16142, -16206, -16260, -16068, -16142, -16206, -16260,
-16304, -16339, -16363, -16378, -16304, -16339, -16363, -16378,
-16383, -16383,
}; };
#endif #endif

View file

@ -119,33 +119,33 @@ static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
/* replaced XPROD32 with a macro to avoid memory reference /* replaced XPROD32 with a macro to avoid memory reference
_x, _y are the results (must be l-values) */ _x, _y are the results (must be l-values) */
#define XPROD32(_a, _b, _t, _v, _x, _y) \ #define XPROD32(_a, _b, _t, _v, _x, _y) \
{ (_x)=MULT32(_a,_t)+MULT32(_b,_v); \ { (_x)=MULT32(_a,_t)+MULT32(_b,_v); \
(_y)=MULT32(_b,_t)-MULT32(_a,_v); } (_y)=MULT32(_b,_t)-MULT32(_a,_v); }
#ifdef __i386__ #ifdef __i386__
#define XPROD31(_a, _b, _t, _v, _x, _y) \ #define XPROD31(_a, _b, _t, _v, _x, _y) \
{ *(_x)=MULT31(_a,_t)+MULT31(_b,_v); \ { *(_x)=MULT31(_a,_t)+MULT31(_b,_v); \
*(_y)=MULT31(_b,_t)-MULT31(_a,_v); } *(_y)=MULT31(_b,_t)-MULT31(_a,_v); }
#define XNPROD31(_a, _b, _t, _v, _x, _y) \ #define XNPROD31(_a, _b, _t, _v, _x, _y) \
{ *(_x)=MULT31(_a,_t)-MULT31(_b,_v); \ { *(_x)=MULT31(_a,_t)-MULT31(_b,_v); \
*(_y)=MULT31(_b,_t)+MULT31(_a,_v); } *(_y)=MULT31(_b,_t)+MULT31(_a,_v); }
#else #else
static inline void XPROD31(ogg_int32_t a, ogg_int32_t b, static inline void XPROD31(ogg_int32_t a, ogg_int32_t b,
ogg_int32_t t, ogg_int32_t v, ogg_int32_t t, ogg_int32_t v,
ogg_int32_t *x, ogg_int32_t *y) ogg_int32_t *x, ogg_int32_t *y)
{ {
*x = MULT31(a, t) + MULT31(b, v); *x = MULT31(a, t) + MULT31(b, v);
*y = MULT31(b, t) - MULT31(a, v); *y = MULT31(b, t) - MULT31(a, v);
} }
static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b, static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b,
ogg_int32_t t, ogg_int32_t v, ogg_int32_t t, ogg_int32_t v,
ogg_int32_t *x, ogg_int32_t *y) ogg_int32_t *x, ogg_int32_t *y)
{ {
*x = MULT31(a, t) - MULT31(b, v); *x = MULT31(a, t) - MULT31(b, v);
*y = MULT31(b, t) + MULT31(a, v); *y = MULT31(b, t) + MULT31(a, v);
@ -217,8 +217,8 @@ static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
#endif #endif
static inline ogg_int32_t VFLOAT_MULT(ogg_int32_t a,ogg_int32_t ap, static inline ogg_int32_t VFLOAT_MULT(ogg_int32_t a,ogg_int32_t ap,
ogg_int32_t b,ogg_int32_t bp, ogg_int32_t b,ogg_int32_t bp,
ogg_int32_t *p){ ogg_int32_t *p){
if(a && b){ if(a && b){
#ifndef _LOW_ACCURACY_ #ifndef _LOW_ACCURACY_
*p=ap+bp+32; *p=ap+bp+32;
@ -232,16 +232,16 @@ static inline ogg_int32_t VFLOAT_MULT(ogg_int32_t a,ogg_int32_t ap,
} }
static inline ogg_int32_t VFLOAT_MULTI(ogg_int32_t a,ogg_int32_t ap, static inline ogg_int32_t VFLOAT_MULTI(ogg_int32_t a,ogg_int32_t ap,
ogg_int32_t i, ogg_int32_t i,
ogg_int32_t *p){ ogg_int32_t *p){
int ip=_ilog(abs(i))-31; int ip=_ilog(abs(i))-31;
return VFLOAT_MULT(a,ap,i<<-ip,ip,p); return VFLOAT_MULT(a,ap,i<<-ip,ip,p);
} }
static inline ogg_int32_t VFLOAT_ADD(ogg_int32_t a,ogg_int32_t ap, static inline ogg_int32_t VFLOAT_ADD(ogg_int32_t a,ogg_int32_t ap,
ogg_int32_t b,ogg_int32_t bp, ogg_int32_t b,ogg_int32_t bp,
ogg_int32_t *p){ ogg_int32_t *p){
if(!a){ if(!a){
*p=bp; *p=bp;

View file

@ -80,45 +80,45 @@ static ogg_uint32_t *_make_words(long *l,long n,long sparsecount){
ogg_uint32_t entry=marker[length]; ogg_uint32_t entry=marker[length];
/* when we claim a node for an entry, we also claim the nodes /* when we claim a node for an entry, we also claim the nodes
below it (pruning off the imagined tree that may have dangled below it (pruning off the imagined tree that may have dangled
from it) as well as blocking the use of any nodes directly from it) as well as blocking the use of any nodes directly
above for leaves */ above for leaves */
/* update ourself */ /* update ourself */
if(length<32 && (entry>>length)){ if(length<32 && (entry>>length)){
/* error condition; the lengths must specify an overpopulated tree */ /* error condition; the lengths must specify an overpopulated tree */
_ogg_free(r); _ogg_free(r);
return(NULL); return(NULL);
} }
r[count++]=entry; r[count++]=entry;
/* Look to see if the next shorter marker points to the node /* Look to see if the next shorter marker points to the node
above. if so, update it and repeat. */ above. if so, update it and repeat. */
{ {
for(j=length;j>0;j--){ for(j=length;j>0;j--){
if(marker[j]&1){ if(marker[j]&1){
/* have to jump branches */ /* have to jump branches */
if(j==1) if(j==1)
marker[1]++; marker[1]++;
else else
marker[j]=marker[j-1]<<1; marker[j]=marker[j-1]<<1;
break; /* invariant says next upper marker would already break; /* invariant says next upper marker would already
have been moved if it was on the same path */ have been moved if it was on the same path */
} }
marker[j]++; marker[j]++;
} }
} }
/* prune the tree; the implicit invariant says all the longer /* prune the tree; the implicit invariant says all the longer
markers were dangling from our just-taken node. Dangle them markers were dangling from our just-taken node. Dangle them
from our *new* node. */ from our *new* node. */
for(j=length+1;j<33;j++) for(j=length+1;j<33;j++)
if((marker[j]>>1) == entry){ if((marker[j]>>1) == entry){
entry=marker[j]; entry=marker[j];
marker[j]=marker[j-1]<<1; marker[j]=marker[j-1]<<1;
}else }else
break; break;
}else }else
if(sparsecount==0)count++; if(sparsecount==0)count++;
} }
@ -134,7 +134,7 @@ static ogg_uint32_t *_make_words(long *l,long n,long sparsecount){
if(sparsecount){ if(sparsecount){
if(l[i]) if(l[i])
r[count++]=temp; r[count++]=temp;
}else }else
r[count++]=temp; r[count++]=temp;
} }
@ -162,9 +162,9 @@ long _book_maptype1_quantvals(const static_codebook *b){
return(vals); return(vals);
}else{ }else{
if(acc>b->entries){ if(acc>b->entries){
vals--; vals--;
}else{ }else{
vals++; vals++;
} }
} }
} }
@ -197,85 +197,85 @@ static ogg_int32_t *_book_unquantize(const static_codebook *b,int n,
switch(b->maptype){ switch(b->maptype){
case 1: case 1:
/* most of the time, entries%dimensions == 0, but we need to be /* most of the time, entries%dimensions == 0, but we need to be
well defined. We define that the possible vales at each well defined. We define that the possible vales at each
scalar is values == entries/dim. If entries%dim != 0, we'll scalar is values == entries/dim. If entries%dim != 0, we'll
have 'too few' values (values*dim<entries), which means that have 'too few' values (values*dim<entries), which means that
we'll have 'left over' entries; left over entries use zeroed we'll have 'left over' entries; left over entries use zeroed
values (and are wasted). So don't generate codebooks like values (and are wasted). So don't generate codebooks like
that */ that */
quantvals=_book_maptype1_quantvals(b); quantvals=_book_maptype1_quantvals(b);
for(j=0;j<b->entries;j++){ for(j=0;j<b->entries;j++){
if((sparsemap && b->lengthlist[j]) || !sparsemap){ if((sparsemap && b->lengthlist[j]) || !sparsemap){
ogg_int32_t last=0; ogg_int32_t last=0;
int lastpoint=0; int lastpoint=0;
int indexdiv=1; int indexdiv=1;
for(k=0;k<b->dim;k++){ for(k=0;k<b->dim;k++){
int index= (j/indexdiv)%quantvals; int index= (j/indexdiv)%quantvals;
int point=0; int point=0;
int val=VFLOAT_MULTI(delta,delpoint, int val=VFLOAT_MULTI(delta,delpoint,
abs(b->quantlist[index]),&point); abs(b->quantlist[index]),&point);
val=VFLOAT_ADD(mindel,minpoint,val,point,&point); val=VFLOAT_ADD(mindel,minpoint,val,point,&point);
val=VFLOAT_ADD(last,lastpoint,val,point,&point); val=VFLOAT_ADD(last,lastpoint,val,point,&point);
if(b->q_sequencep){ if(b->q_sequencep){
last=val; last=val;
lastpoint=point; lastpoint=point;
}
if(sparsemap){
r[sparsemap[count]*b->dim+k]=val;
rp[sparsemap[count]*b->dim+k]=point;
}else{
r[count*b->dim+k]=val;
rp[count*b->dim+k]=point;
}
if(*maxpoint<point)*maxpoint=point;
indexdiv*=quantvals;
}
count++;
} }
if(sparsemap){
r[sparsemap[count]*b->dim+k]=val;
rp[sparsemap[count]*b->dim+k]=point;
}else{
r[count*b->dim+k]=val;
rp[count*b->dim+k]=point;
}
if(*maxpoint<point)*maxpoint=point;
indexdiv*=quantvals;
}
count++;
}
} }
break; break;
case 2: case 2:
for(j=0;j<b->entries;j++){ for(j=0;j<b->entries;j++){
if((sparsemap && b->lengthlist[j]) || !sparsemap){ if((sparsemap && b->lengthlist[j]) || !sparsemap){
ogg_int32_t last=0; ogg_int32_t last=0;
int lastpoint=0; int lastpoint=0;
for(k=0;k<b->dim;k++){ for(k=0;k<b->dim;k++){
int point=0; int point=0;
int val=VFLOAT_MULTI(delta,delpoint, int val=VFLOAT_MULTI(delta,delpoint,
abs(b->quantlist[j*b->dim+k]),&point); abs(b->quantlist[j*b->dim+k]),&point);
val=VFLOAT_ADD(mindel,minpoint,val,point,&point); val=VFLOAT_ADD(mindel,minpoint,val,point,&point);
val=VFLOAT_ADD(last,lastpoint,val,point,&point); val=VFLOAT_ADD(last,lastpoint,val,point,&point);
if(b->q_sequencep){ if(b->q_sequencep){
last=val; last=val;
lastpoint=point; lastpoint=point;
}
if(sparsemap){
r[sparsemap[count]*b->dim+k]=val;
rp[sparsemap[count]*b->dim+k]=point;
}else{
r[count*b->dim+k]=val;
rp[count*b->dim+k]=point;
}
if(*maxpoint<point)*maxpoint=point;
}
count++;
} }
if(sparsemap){
r[sparsemap[count]*b->dim+k]=val;
rp[sparsemap[count]*b->dim+k]=point;
}else{
r[count*b->dim+k]=val;
rp[count*b->dim+k]=point;
}
if(*maxpoint<point)*maxpoint=point;
}
count++;
}
} }
break; break;
} }
for(j=0;j<n*b->dim;j++) for(j=0;j<n*b->dim;j++)
if(rp[j]<*maxpoint) if(rp[j]<*maxpoint)
r[j]>>=*maxpoint-rp[j]; r[j]>>=*maxpoint-rp[j];
_ogg_free(rp); _ogg_free(rp);
return(r); return(r);
} }
@ -383,12 +383,12 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
for(n=0,i=0;i<s->entries;i++) for(n=0,i=0;i<s->entries;i++)
if(s->lengthlist[i]>0) if(s->lengthlist[i]>0)
c->dec_index[sortindex[n++]]=i; c->dec_index[sortindex[n++]]=i;
c->dec_codelengths=(char *)_ogg_malloc(n*sizeof(*c->dec_codelengths)); c->dec_codelengths=(char *)_ogg_malloc(n*sizeof(*c->dec_codelengths));
for(n=0,i=0;i<s->entries;i++) for(n=0,i=0;i<s->entries;i++)
if(s->lengthlist[i]>0) if(s->lengthlist[i]>0)
c->dec_codelengths[sortindex[n++]]=s->lengthlist[i]; c->dec_codelengths[sortindex[n++]]=s->lengthlist[i];
_ogg_free(sortindex); _ogg_free(sortindex);
c->dec_firsttablen=_ilog(c->used_entries)-4; /* this is magic */ 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){
for(i=0;i<n;i++){ for(i=0;i<n;i++){
if(c->dec_maxlength<c->dec_codelengths[i]) if(c->dec_maxlength<c->dec_codelengths[i])
c->dec_maxlength=c->dec_codelengths[i]; c->dec_maxlength=c->dec_codelengths[i];
if(c->dec_codelengths[i]<=c->dec_firsttablen){ if(c->dec_codelengths[i]<=c->dec_firsttablen){
ogg_uint32_t orig=bitreverse(c->codelist[i]); ogg_uint32_t orig=bitreverse(c->codelist[i]);
for(j=0;j<(1<<(c->dec_firsttablen-c->dec_codelengths[i]));j++) for(j=0;j<(1<<(c->dec_firsttablen-c->dec_codelengths[i]));j++)
c->dec_firsttable[orig|(j<<c->dec_codelengths[i])]=i+1; c->dec_firsttable[orig|(j<<c->dec_codelengths[i])]=i+1;
} }
} }
@ -416,24 +416,24 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
long lo=0,hi=0; long lo=0,hi=0;
for(i=0;i<tabn;i++){ for(i=0;i<tabn;i++){
ogg_uint32_t word=i<<(32-c->dec_firsttablen); ogg_uint32_t word=i<<(32-c->dec_firsttablen);
if(c->dec_firsttable[bitreverse(word)]==0){ if(c->dec_firsttable[bitreverse(word)]==0){
while((lo+1)<n && c->codelist[lo+1]<=word)lo++; while((lo+1)<n && c->codelist[lo+1]<=word)lo++;
while( hi<n && word>=(c->codelist[hi]&mask))hi++; while( hi<n && word>=(c->codelist[hi]&mask))hi++;
/* we only actually have 15 bits per hint to play with here. /* we only actually have 15 bits per hint to play with here.
In order to overflow gracefully (nothing breaks, efficiency In order to overflow gracefully (nothing breaks, efficiency
just drops), encode as the difference from the extremes. */ just drops), encode as the difference from the extremes. */
{ {
unsigned long loval=lo; unsigned long loval=lo;
unsigned long hival=n-hi; unsigned long hival=n-hi;
if(loval>0x7fff)loval=0x7fff; if(loval>0x7fff)loval=0x7fff;
if(hival>0x7fff)hival=0x7fff; if(hival>0x7fff)hival=0x7fff;
c->dec_firsttable[bitreverse(word)]= c->dec_firsttable[bitreverse(word)]=
0x80000000UL | (loval<<15) | hival; 0x80000000UL | (loval<<15) | hival;
} }
} }
} }
} }
} }

View file

@ -20,8 +20,8 @@
extern const void *_vorbis_window(int type,int left); extern const void *_vorbis_window(int type,int left);
extern void _vorbis_apply_window(ogg_int32_t *d,const void *window[2], extern void _vorbis_apply_window(ogg_int32_t *d,const void *window[2],
long *blocksizes, long *blocksizes,
int lW,int W,int nW); int lW,int W,int nW);
#endif #endif