updated on Thu Jan 12 08:01:00 UTC 2012
[aur-mirror.git] / openal-svn / al_filter.patch
blob80668d74eac24235d059d362d38132e342099e75
1 --- al_filter.c 2006-05-08 17:41:52.845524459 +0200
2 +++ new/al_filter.c 2006-05-08 17:39:45.001112085 +0200
3 @@ -109,7 +109,7 @@
5 * 2.0 is an arbitrary constant, and likely to be changed.
6 */
7 -#define TPITCH_MAX 256
8 +#define TPITCH_MAX 2048
11 * The default software time domain filters.
12 @@ -1333,7 +1333,7 @@
14 for(i = 0; i < nc; i++) {
15 ALint clen = len;
16 - int j;
17 + int j,sj;
20 * Kind of breaking convention here and actually using
21 @@ -1378,7 +1378,7 @@
22 offsets = tpitch_lookup.offsets[ l_index ];
23 fractionals = tpitch_lookup.fractionals[ l_index ];
25 - /* don't run past end */
26 + /* check for end */
27 if(((clen + 1) * pitch * sizeof(ALshort)) >=
28 (samp->size - src->srcParams.soundpos))
30 @@ -1394,13 +1394,27 @@
31 * be necessary, but seems to improve performance quite
32 * a bit.
34 - for(j = 0; j < clen; j++)
35 + sj=0;
36 + for(j=0; j < len; j++)
38 #if USE_LRINT
40 - int offset = offsets[j];
41 - int nextoffset = offsets[j+1];
42 - float frac = fractionals[j];
43 + if(j==clen) {
44 + /* We have reached the end of the sample.
45 + For looping samples: start over from the start,
46 + else fill with blanks and continue. */
47 + if( _alSourceIsLooping( src ) == AL_TRUE ) {
48 + obufptr = samp->orig_buffers[i];
49 + sj=0;
50 + } else {
51 + memset( &bufptr[j], 0, (len-j)*sizeof *bufptr );
52 + j==len;
53 + continue;
54 + }
55 + }
56 + int offset = offsets[sj];
57 + int nextoffset = offsets[sj+1];
58 + float frac = fractionals[sj];
59 float firstsample = obufptr[offset];
60 float nextsample = obufptr[nextoffset];
61 int finalsample;
62 @@ -1414,9 +1428,22 @@
64 #else
66 - int offset = offsets[j];
67 - int nextoffset = offsets[j+1];
68 - float frac = fractionals[j];
69 + if(j==clen) {
70 + /* We have reached the end of the sample.
71 + For looping samples: start over from the start,
72 + else fill with blanks and continue. */
73 + if( _alSourceIsLooping( src ) == AL_TRUE ) {
74 + obufptr = samp->orig_buffers[i];
75 + sj=0;
76 + } else {
77 + memset( &bufptr[j], 0, (len-j)*sizeof *bufptr );
78 + j==len;
79 + continue;
80 + }
81 + }
82 + int offset = offsets[sj];
83 + int nextoffset = offsets[sj+1];
84 + float frac = fractionals[sj];
85 int firstsample = obufptr[offset];
86 int nextsample = obufptr[nextoffset];
87 int finalsample;
88 @@ -1429,10 +1456,8 @@
89 bufptr[j] = MAX(finalsample, canon_min);
91 #endif
92 + sj++;
95 - /* zero off end */
96 - memset(&bufptr[j], 0, (len-j)*sizeof *bufptr);
100 @@ -1468,15 +1493,12 @@
101 if( _alSourceIsLooping( src ) == AL_TRUE ) {
103 * looping source
104 + * Note: in the resampling loop we already detected if
105 + * this was a looping sample. We still have to reset
106 + * soundpos to the correct value though...
108 - * FIXME:
109 - * This isn't right. soundpos should be set to
110 - * something different, and we may need to carry
111 - * over info so that the sound loops properly.
114 - /* FIXME: kind of kludgy */
115 - src->srcParams.soundpos = 0;
116 + src->srcParams.soundpos %= samp->size;
117 } else {
119 * let _alMixSources know it's time for this source
120 @@ -1547,7 +1569,7 @@
121 * Iterate over each buffers[0..nc-1]
123 for(i = 0; i < nc; i++) {
124 - ALuint j;
125 + ALuint j,sj;
127 if(pitch == 1.0f)
129 @@ -1575,7 +1597,7 @@
131 clen = len;
133 - /* don't run past end */
134 + /* check for end */
135 if(((clen + 1) * pitch * sizeof(ALshort)) >=
136 (samp->size - src->srcParams.soundpos))
138 @@ -1591,19 +1613,28 @@
139 * be necessary, but seems to improve performance quite
140 * a bit.
142 - for(j = 0; j < clen; j++)
143 + sj=0;
144 + for(j = 0; j < len; j++)
146 - /* make sure we don't go past end of last source */
147 -#ifdef DEBUG_FILTER
148 - assert(((j+1)*pitch)*2 <
149 - samp->size - src->srcParams.soundpos);
150 -#endif
152 - float foffset = j * pitch;
153 + if(j==clen) {
154 + /* We have reached the end of the sample.
155 + For looping samples: start over from the start,
156 + else fill with blanks and continue. */
157 + if( _alSourceIsLooping( src ) == AL_TRUE ) {
158 + obufptr = samp->orig_buffers[i];
159 + sj=0;
160 + } else {
161 + memset( &bufptr[j], 0, (len-j)*sizeof *bufptr );
162 + j==len;
163 + continue;
166 + float foffset = sj * pitch;
167 int offset = (int) foffset;
168 float frac = foffset - offset;
169 - int firstsample = obufptr[(int) (j * pitch)];
170 - int nextsample = obufptr[(int)((j+1) * pitch)];
171 + int firstsample = obufptr[(int) (sj * pitch)];
172 + int nextsample = obufptr[(int)((sj+1) * pitch)];
173 int finalsample;
175 /* do a little interpolation */
176 @@ -1613,12 +1644,7 @@
177 finalsample = MIN(finalsample, canon_max);
178 bufptr[j] = MAX(finalsample, canon_min);
182 - /* JIV FIXME: use memset */
183 - for( ; j < len; j++)
185 - bufptr[j] = 0;
186 + sj++;
190 @@ -1649,16 +1675,13 @@
192 if( _alSourceIsLooping( src ) == AL_TRUE ) {
194 - * looping source
195 + * looping source
196 + * Note: in the resampling loop we already detected if
197 + * this was a looping sample. We still have to reset
198 + * soundpos to the correct value though...
200 - * FIXME:
201 - * This isn't right. soundpos should be set to
202 - * something different, and we may need to carry
203 - * over info so that the sound loops properly.
206 - /* FIXME: kind of kludgy */
207 - src->srcParams.soundpos = 0;
208 + src->srcParams.soundpos %= samp->size;
209 } else {
211 * let _alMixSources know it's time for this source