author | inu |
Fri, 18 Jan 2013 11:30:09 +0100 | |
changeset 8398 | d63a0f9d2ccb |
parent 7849 | a12155461b34 |
permissions | -rw-r--r-- |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
1 |
/******************************************************************** |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
2 |
* * |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
3 |
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
4 |
* * |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
5 |
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
6 |
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
7 |
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
8 |
* * |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
9 |
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
10 |
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
11 |
* * |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
12 |
******************************************************************** |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
13 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
14 |
function: basic codebook pack/unpack/code/decode operations |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
15 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
16 |
********************************************************************/ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
17 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
18 |
#include <stdlib.h> |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
19 |
#include <string.h> |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
20 |
#include <math.h> |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
21 |
#include "ogg.h" |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
22 |
#include "ivorbiscodec.h" |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
23 |
#include "codebook.h" |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
24 |
#include "misc.h" |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
25 |
|
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
26 |
/* unpacks a codebook from the packet buffer into the codebook struct, |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
27 |
readies the codebook auxiliary structures for decode *************/ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
28 |
int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
29 |
long i,j; |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
30 |
memset(s,0,sizeof(*s)); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
31 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
32 |
/* make sure alignment is correct */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
33 |
if(oggpack_read(opb,24)!=0x564342)goto _eofout; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
34 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
35 |
/* first the basic parameters */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
36 |
s->dim=oggpack_read(opb,16); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
37 |
s->entries=oggpack_read(opb,24); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
38 |
if(s->entries==-1)goto _eofout; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
39 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
40 |
/* codeword ordering.... length ordered or unordered? */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
41 |
switch((int)oggpack_read(opb,1)){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
42 |
case 0: |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
43 |
/* unordered */ |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
44 |
s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries); |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
45 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
46 |
/* allocated but unused entries? */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
47 |
if(oggpack_read(opb,1)){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
48 |
/* yes, unused entries */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
49 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
50 |
for(i=0;i<s->entries;i++){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
51 |
if(oggpack_read(opb,1)){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
52 |
long num=oggpack_read(opb,5); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
53 |
if(num==-1)goto _eofout; |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
54 |
s->lengthlist[i]=num+1; |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
55 |
}else |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
56 |
s->lengthlist[i]=0; |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
57 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
58 |
}else{ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
59 |
/* all entries used; no tagging */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
60 |
for(i=0;i<s->entries;i++){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
61 |
long num=oggpack_read(opb,5); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
62 |
if(num==-1)goto _eofout; |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
63 |
s->lengthlist[i]=num+1; |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
64 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
65 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
66 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
67 |
break; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
68 |
case 1: |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
69 |
/* ordered */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
70 |
{ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
71 |
long length=oggpack_read(opb,5)+1; |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
72 |
s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries); |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
73 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
74 |
for(i=0;i<s->entries;){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
75 |
long num=oggpack_read(opb,_ilog(s->entries-i)); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
76 |
if(num==-1)goto _eofout; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
77 |
for(j=0;j<num && i<s->entries;j++,i++) |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
78 |
s->lengthlist[i]=length; |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
79 |
length++; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
80 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
81 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
82 |
break; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
83 |
default: |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
84 |
/* EOF */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
85 |
return(-1); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
86 |
} |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
87 |
|
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
88 |
/* Do we have a mapping to unpack? */ |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
89 |
switch((s->maptype=oggpack_read(opb,4))){ |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
90 |
case 0: |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
91 |
/* no mapping */ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
92 |
break; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
93 |
case 1: case 2: |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
94 |
/* implicitly populated value mapping */ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
95 |
/* explicitly populated value mapping */ |
7697
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
6045
diff
changeset
|
96 |
|
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
97 |
s->q_min=oggpack_read(opb,32); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
98 |
s->q_delta=oggpack_read(opb,32); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
99 |
s->q_quant=oggpack_read(opb,4)+1; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
100 |
s->q_sequencep=oggpack_read(opb,1); |
7697
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
6045
diff
changeset
|
101 |
|
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
102 |
{ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
103 |
int quantvals=0; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
104 |
switch(s->maptype){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
105 |
case 1: |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
106 |
quantvals=_book_maptype1_quantvals(s); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
107 |
break; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
108 |
case 2: |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
109 |
quantvals=s->entries*s->dim; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
110 |
break; |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
111 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
112 |
|
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
113 |
/* quantized values */ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
114 |
s->quantlist=(long *)_ogg_malloc(sizeof(*s->quantlist)*quantvals); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
115 |
for(i=0;i<quantvals;i++) |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
116 |
s->quantlist[i]=oggpack_read(opb,s->q_quant); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
117 |
|
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
118 |
if(quantvals&&s->quantlist[quantvals-1]==-1)goto _eofout; |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
119 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
120 |
break; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
121 |
default: |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
122 |
goto _errout; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
123 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
124 |
|
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
125 |
/* all set */ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
126 |
return(0); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
127 |
|
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
128 |
_errout: |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
129 |
_eofout: |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
130 |
vorbis_staticbook_clear(s); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
131 |
return(-1); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
132 |
} |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
133 |
|
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
134 |
/* the 'eliminate the decode tree' optimization actually requires the |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
135 |
codewords to be MSb first, not LSb. This is an annoying inelegancy |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
136 |
(and one of the first places where carefully thought out design |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
137 |
turned out to be wrong; Vorbis II and future Ogg codecs should go |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
138 |
to an MSb bitpacker), but not actually the huge hit it appears to |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
139 |
be. The first-stage decode table catches most words so that |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
140 |
bitreverse is not in the main execution path. */ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
141 |
|
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
142 |
static ogg_uint32_t bitreverse(ogg_uint32_t x){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
143 |
x= ((x>>16)&0x0000ffff) | ((x<<16)&0xffff0000); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
144 |
x= ((x>> 8)&0x00ff00ff) | ((x<< 8)&0xff00ff00); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
145 |
x= ((x>> 4)&0x0f0f0f0f) | ((x<< 4)&0xf0f0f0f0); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
146 |
x= ((x>> 2)&0x33333333) | ((x<< 2)&0xcccccccc); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
147 |
return((x>> 1)&0x55555555) | ((x<< 1)&0xaaaaaaaa); |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
148 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
149 |
|
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
150 |
STIN long decode_packed_entry_number(codebook *book, |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
151 |
oggpack_buffer *b){ |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
152 |
int read=book->dec_maxlength; |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
153 |
long lo,hi; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
154 |
long lok = oggpack_look(b,book->dec_firsttablen); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
155 |
|
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
156 |
if (lok >= 0) { |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
157 |
long entry = book->dec_firsttable[lok]; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
158 |
if(entry&0x80000000UL){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
159 |
lo=(entry>>15)&0x7fff; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
160 |
hi=book->used_entries-(entry&0x7fff); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
161 |
}else{ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
162 |
oggpack_adv(b, book->dec_codelengths[entry-1]); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
163 |
return(entry-1); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
164 |
} |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
165 |
}else{ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
166 |
lo=0; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
167 |
hi=book->used_entries; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
168 |
} |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
169 |
|
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
170 |
lok = oggpack_look(b, read); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
171 |
|
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
172 |
while(lok<0 && read>1) |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
173 |
lok = oggpack_look(b, --read); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
174 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
175 |
if(lok<0){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
176 |
oggpack_adv(b,1); /* force eop */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
177 |
return -1; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
178 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
179 |
|
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
180 |
/* bisect search for the codeword in the ordered list */ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
181 |
{ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
182 |
ogg_uint32_t testword=bitreverse((ogg_uint32_t)lok); |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
183 |
|
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
184 |
while(hi-lo>1){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
185 |
long p=(hi-lo)>>1; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
186 |
long test=book->codelist[lo+p]>testword; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
187 |
lo+=p&(test-1); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
188 |
hi-=p&(-test); |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
189 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
190 |
|
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
191 |
if(book->dec_codelengths[lo]<=read){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
192 |
oggpack_adv(b, book->dec_codelengths[lo]); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
193 |
return(lo); |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
194 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
195 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
196 |
|
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
197 |
oggpack_adv(b, read+1); |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
198 |
return(-1); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
199 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
200 |
|
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
201 |
/* Decode side is specced and easier, because we don't need to find |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
202 |
matches using different criteria; we simply read and map. There are |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
203 |
two things we need to do 'depending': |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
204 |
|
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
205 |
We may need to support interleave. We don't really, but it's |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
206 |
convenient to do it here rather than rebuild the vector later. |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
207 |
|
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
208 |
Cascades may be additive or multiplicitive; this is not inherent in |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
209 |
the codebook, but set in the code using the codebook. Like |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
210 |
interleaving, it's easiest to do it here. |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
211 |
addmul==0 -> declarative (set the value) |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
212 |
addmul==1 -> additive |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
213 |
addmul==2 -> multiplicitive */ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
214 |
|
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
215 |
/* returns the [original, not compacted] entry number or -1 on eof *********/ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
216 |
long vorbis_book_decode(codebook *book, oggpack_buffer *b){ |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
217 |
if(book->used_entries>0){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
218 |
long packed_entry=decode_packed_entry_number(book,b); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
219 |
if(packed_entry>=0) |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
220 |
return(book->dec_index[packed_entry]); |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
221 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
222 |
|
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
223 |
/* if there's no dec_index, the codebook unpacking isn't collapsed */ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
224 |
return(-1); |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
225 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
226 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
227 |
/* returns 0 on OK or -1 on eof *************************************/ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
228 |
long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a, |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
229 |
oggpack_buffer *b,int n,int point){ |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
230 |
if(book->used_entries>0){ |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
231 |
int step=n/book->dim; |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
232 |
long *entry = (long *)alloca(sizeof(*entry)*step); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
233 |
ogg_int32_t **t = (ogg_int32_t **)alloca(sizeof(*t)*step); |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
234 |
int i,j,o; |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
235 |
int shift=point-book->binarypoint; |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
236 |
|
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
237 |
if(shift>=0){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
238 |
for (i = 0; i < step; i++) { |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
239 |
entry[i]=decode_packed_entry_number(book,b); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
240 |
if(entry[i]==-1)return(-1); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
241 |
t[i] = book->valuelist+entry[i]*book->dim; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
242 |
} |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
243 |
for(i=0,o=0;i<book->dim;i++,o+=step) |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
244 |
for (j=0;j<step;j++) |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
245 |
a[o+j]+=t[j][i]>>shift; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
246 |
}else{ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
247 |
for (i = 0; i < step; i++) { |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
248 |
entry[i]=decode_packed_entry_number(book,b); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
249 |
if(entry[i]==-1)return(-1); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
250 |
t[i] = book->valuelist+entry[i]*book->dim; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
251 |
} |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
252 |
for(i=0,o=0;i<book->dim;i++,o+=step) |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
253 |
for (j=0;j<step;j++) |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
254 |
a[o+j]+=t[j][i]<<-shift; |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
255 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
256 |
} |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
257 |
return(0); |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
258 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
259 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
260 |
long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a, |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
261 |
oggpack_buffer *b,int n,int point){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
262 |
if(book->used_entries>0){ |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
263 |
int i,j,entry; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
264 |
ogg_int32_t *t; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
265 |
int shift=point-book->binarypoint; |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
266 |
|
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
267 |
if(shift>=0){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
268 |
for(i=0;i<n;){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
269 |
entry = decode_packed_entry_number(book,b); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
270 |
if(entry==-1)return(-1); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
271 |
t = book->valuelist+entry*book->dim; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
272 |
for (j=0;j<book->dim;) |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
273 |
a[i++]+=t[j++]>>shift; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
274 |
} |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
275 |
}else{ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
276 |
for(i=0;i<n;){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
277 |
entry = decode_packed_entry_number(book,b); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
278 |
if(entry==-1)return(-1); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
279 |
t = book->valuelist+entry*book->dim; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
280 |
for (j=0;j<book->dim;) |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
281 |
a[i++]+=t[j++]<<-shift; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
282 |
} |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
283 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
284 |
} |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
285 |
return(0); |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
286 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
287 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
288 |
long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a, |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
289 |
oggpack_buffer *b,int n,int point){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
290 |
if(book->used_entries>0){ |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
291 |
int i,j,entry; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
292 |
ogg_int32_t *t; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
293 |
int shift=point-book->binarypoint; |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
294 |
|
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
295 |
if(shift>=0){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
296 |
|
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
297 |
for(i=0;i<n;){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
298 |
entry = decode_packed_entry_number(book,b); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
299 |
if(entry==-1)return(-1); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
300 |
t = book->valuelist+entry*book->dim; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
301 |
for (j=0;j<book->dim;){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
302 |
a[i++]=t[j++]>>shift; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
303 |
} |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
304 |
} |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
305 |
}else{ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
306 |
|
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
307 |
for(i=0;i<n;){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
308 |
entry = decode_packed_entry_number(book,b); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
309 |
if(entry==-1)return(-1); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
310 |
t = book->valuelist+entry*book->dim; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
311 |
for (j=0;j<book->dim;){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
312 |
a[i++]=t[j++]<<-shift; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
313 |
} |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
314 |
} |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
315 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
316 |
}else{ |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
317 |
|
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
318 |
int i,j; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
319 |
for(i=0;i<n;){ |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
320 |
for (j=0;j<book->dim;){ |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
321 |
a[i++]=0; |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
322 |
} |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
323 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
324 |
} |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
325 |
return(0); |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
326 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
327 |
|
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
328 |
long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,\ |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
329 |
long offset,int ch, |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
330 |
oggpack_buffer *b,int n,int point){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
331 |
if(book->used_entries>0){ |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
332 |
long i,j,entry; |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
333 |
int chptr=0; |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
334 |
int shift=point-book->binarypoint; |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
335 |
|
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
336 |
if(shift>=0){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
337 |
|
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
338 |
for(i=offset;i<offset+n;){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
339 |
entry = decode_packed_entry_number(book,b); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
340 |
if(entry==-1)return(-1); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
341 |
{ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
342 |
const ogg_int32_t *t = book->valuelist+entry*book->dim; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
343 |
for (j=0;j<book->dim;j++){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
344 |
a[chptr++][i]+=t[j]>>shift; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
345 |
if(chptr==ch){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
346 |
chptr=0; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
347 |
i++; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
348 |
} |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
349 |
} |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
350 |
} |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
351 |
} |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
352 |
}else{ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
353 |
|
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
354 |
for(i=offset;i<offset+n;){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
355 |
entry = decode_packed_entry_number(book,b); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
356 |
if(entry==-1)return(-1); |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
357 |
{ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
358 |
const ogg_int32_t *t = book->valuelist+entry*book->dim; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
359 |
for (j=0;j<book->dim;j++){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
360 |
a[chptr++][i]+=t[j]<<-shift; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
361 |
if(chptr==ch){ |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
362 |
chptr=0; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
363 |
i++; |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
364 |
} |
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
365 |
} |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
366 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
367 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
368 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
369 |
} |
7849
a12155461b34
revert r767d3c4153a1 this tremor implementation is buggy
koda
parents:
7697
diff
changeset
|
370 |
return(0); |
5170
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
371 |
} |