Use a macro to specify the ambisonic periphonic channel mask
[openal-soft.git] / Alc / bformatdec.c
blob7da506920d4e2d5fd0112d8944b13dc4424a6220
2 #include "config.h"
4 #include "bformatdec.h"
5 #include "ambdec.h"
6 #include "mixer_defs.h"
7 #include "alu.h"
9 #include "threads.h"
10 #include "almalloc.h"
13 typedef struct BandSplitter {
14 ALfloat coeff;
15 ALfloat lp_z1;
16 ALfloat lp_z2;
17 ALfloat hp_z1;
18 } BandSplitter;
20 static void bandsplit_init(BandSplitter *splitter, ALfloat freq_mult)
22 ALfloat w = freq_mult * F_TAU;
23 ALfloat cw = cosf(w);
24 if(cw > FLT_EPSILON)
25 splitter->coeff = (sinf(w) - 1.0f) / cw;
26 else
27 splitter->coeff = cw * -0.5f;
29 splitter->lp_z1 = 0.0f;
30 splitter->lp_z2 = 0.0f;
31 splitter->hp_z1 = 0.0f;
34 static void bandsplit_process(BandSplitter *splitter, ALfloat *restrict hpout, ALfloat *restrict lpout,
35 const ALfloat *input, ALuint count)
37 ALfloat coeff, d, x;
38 ALfloat z1, z2;
39 ALuint i;
41 coeff = splitter->coeff*0.5f + 0.5f;
42 z1 = splitter->lp_z1;
43 z2 = splitter->lp_z2;
44 for(i = 0;i < count;i++)
46 x = input[i];
48 d = (x - z1) * coeff;
49 x = z1 + d;
50 z1 = x + d;
52 d = (x - z2) * coeff;
53 x = z2 + d;
54 z2 = x + d;
56 lpout[i] = x;
58 splitter->lp_z1 = z1;
59 splitter->lp_z2 = z2;
61 coeff = splitter->coeff;
62 z1 = splitter->hp_z1;
63 for(i = 0;i < count;i++)
65 x = input[i];
67 d = x - coeff*z1;
68 x = z1 + coeff*d;
69 z1 = d;
71 hpout[i] = x - lpout[i];
73 splitter->hp_z1 = z1;
77 static const ALfloat UnitScale[MAX_AMBI_COEFFS] = {
78 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
79 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f
81 static const ALfloat SN3D2N3DScale[MAX_AMBI_COEFFS] = {
82 1.000000000f, /* ACN 0 (W), sqrt(1) */
83 1.732050808f, /* ACN 1 (Y), sqrt(3) */
84 1.732050808f, /* ACN 2 (Z), sqrt(3) */
85 1.732050808f, /* ACN 3 (X), sqrt(3) */
86 2.236067978f, /* ACN 4 (V), sqrt(5) */
87 2.236067978f, /* ACN 5 (T), sqrt(5) */
88 2.236067978f, /* ACN 6 (R), sqrt(5) */
89 2.236067978f, /* ACN 7 (S), sqrt(5) */
90 2.236067978f, /* ACN 8 (U), sqrt(5) */
91 2.645751311f, /* ACN 9 (Q), sqrt(7) */
92 2.645751311f, /* ACN 10 (O), sqrt(7) */
93 2.645751311f, /* ACN 11 (M), sqrt(7) */
94 2.645751311f, /* ACN 12 (K), sqrt(7) */
95 2.645751311f, /* ACN 13 (L), sqrt(7) */
96 2.645751311f, /* ACN 14 (N), sqrt(7) */
97 2.645751311f, /* ACN 15 (P), sqrt(7) */
99 static const ALfloat FuMa2N3DScale[MAX_AMBI_COEFFS] = {
100 1.414213562f, /* ACN 0 (W), sqrt(2) */
101 1.732050808f, /* ACN 1 (Y), sqrt(3) */
102 1.732050808f, /* ACN 2 (Z), sqrt(3) */
103 1.732050808f, /* ACN 3 (X), sqrt(3) */
104 1.936491673f, /* ACN 4 (V), sqrt(15)/2 */
105 1.936491673f, /* ACN 5 (T), sqrt(15)/2 */
106 2.236067978f, /* ACN 6 (R), sqrt(5) */
107 1.936491673f, /* ACN 7 (S), sqrt(15)/2 */
108 1.936491673f, /* ACN 8 (U), sqrt(15)/2 */
109 2.091650066f, /* ACN 9 (Q), sqrt(35/8) */
110 1.972026594f, /* ACN 10 (O), sqrt(35)/3 */
111 2.231093404f, /* ACN 11 (M), sqrt(224/45) */
112 2.645751311f, /* ACN 12 (K), sqrt(7) */
113 2.231093404f, /* ACN 13 (L), sqrt(224/45) */
114 1.972026594f, /* ACN 14 (N), sqrt(35)/3 */
115 2.091650066f, /* ACN 15 (P), sqrt(35/8) */
119 static const ALfloat SquareMatrixHF[4][MAX_AMBI_COEFFS] = {
120 { 0.353553f, 0.204094f, 0.0f, 0.204094f },
121 { 0.353553f, -0.204094f, 0.0f, 0.204094f },
122 { 0.353553f, 0.204094f, 0.0f, -0.204094f },
123 { 0.353553f, -0.204094f, 0.0f, -0.204094f },
125 static const ALfloat SquareMatrixLF[4][MAX_AMBI_COEFFS] = {
126 { 0.25f, 0.204094f, 0.0f, 0.204094f },
127 { 0.25f, -0.204094f, 0.0f, 0.204094f },
128 { 0.25f, 0.204094f, 0.0f, -0.204094f },
129 { 0.25f, -0.204094f, 0.0f, -0.204094f },
131 static ALfloat SquareEncoder[4][MAX_AMBI_COEFFS];
133 static const ALfloat CubeMatrixHF[8][MAX_AMBI_COEFFS] = {
134 { 0.25f, 0.14425f, 0.14425f, 0.14425f },
135 { 0.25f, -0.14425f, 0.14425f, 0.14425f },
136 { 0.25f, 0.14425f, 0.14425f, -0.14425f },
137 { 0.25f, -0.14425f, 0.14425f, -0.14425f },
138 { 0.25f, 0.14425f, -0.14425f, 0.14425f },
139 { 0.25f, -0.14425f, -0.14425f, 0.14425f },
140 { 0.25f, 0.14425f, -0.14425f, -0.14425f },
141 { 0.25f, -0.14425f, -0.14425f, -0.14425f },
143 static const ALfloat CubeMatrixLF[8][MAX_AMBI_COEFFS] = {
144 { 0.125f, 0.125f, 0.125f, 0.125f },
145 { 0.125f, -0.125f, 0.125f, 0.125f },
146 { 0.125f, 0.125f, 0.125f, -0.125f },
147 { 0.125f, -0.125f, 0.125f, -0.125f },
148 { 0.125f, 0.125f, -0.125f, 0.125f },
149 { 0.125f, -0.125f, -0.125f, 0.125f },
150 { 0.125f, 0.125f, -0.125f, -0.125f },
151 { 0.125f, -0.125f, -0.125f, -0.125f },
153 static ALfloat CubeEncoder[8][MAX_AMBI_COEFFS];
156 static inline MatrixMixerFunc SelectMixer(void)
158 #ifdef HAVE_SSE
159 if((CPUCapFlags&CPU_CAP_SSE))
160 return MixRow_SSE;
161 #endif
162 return MixRow_C;
165 static MatrixMixerFunc MixMatrixRow = MixRow_C;
168 static alonce_flag bformatdec_inited = AL_ONCE_FLAG_INIT;
170 static void init_bformatdec(void)
172 ALuint i, j;
174 MixMatrixRow = SelectMixer();
176 CalcXYZCoeffs(-0.577350269f, 0.577350269f, -0.577350269f, 0.0f, CubeEncoder[0]);
177 CalcXYZCoeffs( 0.577350269f, 0.577350269f, -0.577350269f, 0.0f, CubeEncoder[1]);
178 CalcXYZCoeffs(-0.577350269f, 0.577350269f, 0.577350269f, 0.0f, CubeEncoder[2]);
179 CalcXYZCoeffs( 0.577350269f, 0.577350269f, 0.577350269f, 0.0f, CubeEncoder[3]);
180 CalcXYZCoeffs(-0.577350269f, -0.577350269f, -0.577350269f, 0.0f, CubeEncoder[4]);
181 CalcXYZCoeffs( 0.577350269f, -0.577350269f, -0.577350269f, 0.0f, CubeEncoder[5]);
182 CalcXYZCoeffs(-0.577350269f, -0.577350269f, 0.577350269f, 0.0f, CubeEncoder[6]);
183 CalcXYZCoeffs( 0.577350269f, -0.577350269f, 0.577350269f, 0.0f, CubeEncoder[7]);
185 CalcXYZCoeffs(-0.707106781f, 0.0f, -0.707106781f, 0.0f, SquareEncoder[0]);
186 CalcXYZCoeffs( 0.707106781f, 0.0f, -0.707106781f, 0.0f, SquareEncoder[1]);
187 CalcXYZCoeffs(-0.707106781f, 0.0f, 0.707106781f, 0.0f, SquareEncoder[2]);
188 CalcXYZCoeffs( 0.707106781f, 0.0f, 0.707106781f, 0.0f, SquareEncoder[3]);
190 for(i = 0;i < 4;i++)
192 /* Remove the skipped height-related coefficients for 2D rendering. */
193 SquareEncoder[i][2] = SquareEncoder[i][3];
194 SquareEncoder[i][3] = SquareEncoder[i][4];
195 SquareEncoder[i][4] = SquareEncoder[i][8];
196 SquareEncoder[i][5] = SquareEncoder[i][9];
197 SquareEncoder[i][6] = SquareEncoder[i][15];
198 for(j = 7;j < MAX_AMBI_COEFFS;j++)
199 SquareEncoder[i][j] = 0.0f;
204 #define MAX_DELAY_LENGTH 128
206 /* NOTE: Low-frequency (LF) fields and BandSplitter filters are unused with
207 * single-band decoding
209 typedef struct BFormatDec {
210 ALboolean Enabled[MAX_OUTPUT_CHANNELS];
212 alignas(16) ALfloat MatrixHF[MAX_OUTPUT_CHANNELS][MAX_AMBI_COEFFS];
213 alignas(16) ALfloat MatrixLF[MAX_OUTPUT_CHANNELS][MAX_AMBI_COEFFS];
215 BandSplitter XOver[MAX_AMBI_COEFFS];
217 ALfloat (*Samples)[BUFFERSIZE];
218 /* These two alias into Samples */
219 ALfloat (*SamplesHF)[BUFFERSIZE];
220 ALfloat (*SamplesLF)[BUFFERSIZE];
222 alignas(16) ALfloat ChannelMix[BUFFERSIZE];
224 struct {
225 alignas(16) ALfloat Buffer[MAX_DELAY_LENGTH];
226 ALuint Length; /* Valid range is [0...MAX_DELAY_LENGTH). */
227 } Delay[MAX_OUTPUT_CHANNELS];
229 struct {
230 BandSplitter XOver[4];
232 const ALfloat (*restrict MatrixHF)[MAX_AMBI_COEFFS];
233 const ALfloat (*restrict MatrixLF)[MAX_AMBI_COEFFS];
234 const ALfloat (*restrict Encoder)[MAX_AMBI_COEFFS];
235 ALuint NumChannels;
236 } UpSampler;
238 ALuint NumChannels;
239 ALboolean DualBand;
240 ALboolean Periphonic;
241 } BFormatDec;
243 BFormatDec *bformatdec_alloc()
245 alcall_once(&bformatdec_inited, init_bformatdec);
246 return al_calloc(16, sizeof(BFormatDec));
249 void bformatdec_free(BFormatDec *dec)
251 if(dec)
253 al_free(dec->Samples);
254 dec->Samples = NULL;
255 dec->SamplesHF = NULL;
256 dec->SamplesLF = NULL;
258 memset(dec, 0, sizeof(*dec));
259 al_free(dec);
263 int bformatdec_getOrder(const struct BFormatDec *dec)
265 if(dec->Periphonic)
267 if(dec->NumChannels > 9) return 3;
268 if(dec->NumChannels > 4) return 2;
269 if(dec->NumChannels > 1) return 1;
271 else
273 if(dec->NumChannels > 5) return 3;
274 if(dec->NumChannels > 3) return 2;
275 if(dec->NumChannels > 1) return 1;
277 return 0;
280 void bformatdec_reset(BFormatDec *dec, const AmbDecConf *conf, ALuint chancount, ALuint srate, const ALuint chanmap[MAX_OUTPUT_CHANNELS], int flags)
282 static const ALuint map2DTo3D[7] = {
283 0, 1, 3, 4, 8, 9, 15
285 const ALfloat *coeff_scale = UnitScale;
286 ALfloat distgain[MAX_OUTPUT_CHANNELS];
287 ALfloat maxdist, ratio;
288 ALuint i;
290 al_free(dec->Samples);
291 dec->Samples = NULL;
292 dec->SamplesHF = NULL;
293 dec->SamplesLF = NULL;
295 dec->NumChannels = chancount;
296 dec->Samples = al_calloc(16, dec->NumChannels*2 * sizeof(dec->Samples[0]));
297 dec->SamplesHF = dec->Samples;
298 dec->SamplesLF = dec->SamplesHF + dec->NumChannels;
300 for(i = 0;i < MAX_OUTPUT_CHANNELS;i++)
301 dec->Enabled[i] = AL_FALSE;
302 for(i = 0;i < conf->NumSpeakers;i++)
303 dec->Enabled[chanmap[i]] = AL_TRUE;
305 if(conf->CoeffScale == ADS_SN3D)
306 coeff_scale = SN3D2N3DScale;
307 else if(conf->CoeffScale == ADS_FuMa)
308 coeff_scale = FuMa2N3DScale;
310 ratio = 400.0f / (ALfloat)srate;
311 for(i = 0;i < 4;i++)
312 bandsplit_init(&dec->UpSampler.XOver[i], ratio);
313 if((conf->ChanMask&AMBI_PERIPHONIC_MASK))
315 dec->UpSampler.MatrixHF = CubeMatrixHF;
316 dec->UpSampler.MatrixLF = CubeMatrixLF;
317 dec->UpSampler.Encoder = (const ALfloat(*)[MAX_AMBI_COEFFS])CubeEncoder;
318 dec->UpSampler.NumChannels = 8;
319 dec->Periphonic = AL_TRUE;
321 else
323 dec->UpSampler.MatrixHF = SquareMatrixHF;
324 dec->UpSampler.MatrixLF = SquareMatrixLF;
325 dec->UpSampler.Encoder = (const ALfloat(*)[MAX_AMBI_COEFFS])SquareEncoder;
326 dec->UpSampler.NumChannels = 4;
327 dec->Periphonic = AL_FALSE;
330 maxdist = 0.0f;
331 for(i = 0;i < conf->NumSpeakers;i++)
333 maxdist = maxf(maxdist, conf->Speakers[i].Distance);
334 distgain[i] = 1.0f;
337 memset(dec->Delay, 0, sizeof(dec->Delay));
338 if((flags&BFDF_DistanceComp) && maxdist > 0.0f)
340 for(i = 0;i < conf->NumSpeakers;i++)
342 ALuint chan = chanmap[i];
343 ALfloat delay;
345 /* Distance compensation only delays in steps of the sample rate.
346 * This is a bit less accurate since the delay time falls to the
347 * nearest sample time, but it's far simpler as it doesn't have to
348 * deal with phase offsets. This means at 48khz, for instance, the
349 * distance delay will be in steps of about 7 millimeters.
351 delay = floorf((maxdist-conf->Speakers[i].Distance) / SPEEDOFSOUNDMETRESPERSEC *
352 (ALfloat)srate + 0.5f);
353 if(delay >= (ALfloat)MAX_DELAY_LENGTH)
354 ERR("Delay for speaker \"%s\" exceeds buffer length (%f >= %u)\n",
355 al_string_get_cstr(conf->Speakers[i].Name), delay, MAX_DELAY_LENGTH);
357 dec->Delay[chan].Length = (ALuint)clampf(delay, 0.0f, (ALfloat)(MAX_DELAY_LENGTH-1));
358 distgain[i] = conf->Speakers[i].Distance / maxdist;
359 TRACE("Channel %u \"%s\" distance compensation: %u samples, %f gain\n", chan,
360 al_string_get_cstr(conf->Speakers[i].Name), dec->Delay[chan].Length, distgain[i]
365 if(conf->FreqBands == 1)
367 dec->DualBand = AL_FALSE;
368 ratio = 1.0f;
370 else
372 dec->DualBand = AL_TRUE;
374 ratio = conf->XOverFreq / (ALfloat)srate;
375 for(i = 0;i < MAX_AMBI_COEFFS;i++)
376 bandsplit_init(&dec->XOver[i], ratio);
378 ratio = powf(10.0f, conf->XOverRatio / 40.0f);
379 memset(dec->MatrixLF, 0, sizeof(dec->MatrixLF));
380 for(i = 0;i < conf->NumSpeakers;i++)
382 ALuint chan = chanmap[i];
383 ALuint j, k = 0;
384 ALfloat gain;
386 if(!dec->Periphonic)
388 for(j = 0;j < 7;j++)
390 ALuint l = map2DTo3D[j];
391 if(j == 0) gain = conf->LFOrderGain[0] / ratio;
392 else if(j == 1) gain = conf->LFOrderGain[1] / ratio;
393 else if(j == 3) gain = conf->LFOrderGain[2] / ratio;
394 else if(j == 5) gain = conf->LFOrderGain[3] / ratio;
395 if((conf->ChanMask&(1<<l)))
396 dec->MatrixLF[chan][j] = conf->LFMatrix[i][k++] / coeff_scale[l] *
397 gain * distgain[i];
400 else
402 for(j = 0;j < MAX_AMBI_COEFFS;j++)
404 if(j == 0) gain = conf->LFOrderGain[0] / ratio;
405 else if(j == 1) gain = conf->LFOrderGain[1] / ratio;
406 else if(j == 4) gain = conf->LFOrderGain[2] / ratio;
407 else if(j == 9) gain = conf->LFOrderGain[3] / ratio;
408 if((conf->ChanMask&(1<<j)))
409 dec->MatrixLF[chan][j] = conf->LFMatrix[i][k++] / coeff_scale[j] *
410 gain * distgain[i];
416 memset(dec->MatrixHF, 0, sizeof(dec->MatrixHF));
417 for(i = 0;i < conf->NumSpeakers;i++)
419 ALuint chan = chanmap[i];
420 ALuint j, k = 0;
421 ALfloat gain;
423 if(!dec->Periphonic)
425 for(j = 0;j < 7;j++)
427 ALuint l = map2DTo3D[j];
428 if(j == 0) gain = conf->HFOrderGain[0] * ratio;
429 else if(j == 1) gain = conf->HFOrderGain[1] * ratio;
430 else if(j == 3) gain = conf->HFOrderGain[2] * ratio;
431 else if(j == 5) gain = conf->HFOrderGain[3] * ratio;
432 if((conf->ChanMask&(1<<l)))
433 dec->MatrixHF[chan][j] = conf->HFMatrix[i][k++] / coeff_scale[l] *
434 gain * distgain[i];
437 else
439 for(j = 0;j < MAX_AMBI_COEFFS;j++)
441 if(j == 0) gain = conf->HFOrderGain[0] * ratio;
442 else if(j == 1) gain = conf->HFOrderGain[1] * ratio;
443 else if(j == 4) gain = conf->HFOrderGain[2] * ratio;
444 else if(j == 9) gain = conf->HFOrderGain[3] * ratio;
445 if((conf->ChanMask&(1<<j)))
446 dec->MatrixHF[chan][j] = conf->HFMatrix[i][k++] / coeff_scale[j] *
447 gain * distgain[i];
454 void bformatdec_process(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint OutChannels, ALfloat (*restrict InSamples)[BUFFERSIZE], ALuint SamplesToDo)
456 ALuint chan, i;
458 if(dec->DualBand)
460 for(i = 0;i < dec->NumChannels;i++)
461 bandsplit_process(&dec->XOver[i], dec->SamplesHF[i], dec->SamplesLF[i],
462 InSamples[i], SamplesToDo);
464 for(chan = 0;chan < OutChannels;chan++)
466 if(!dec->Enabled[chan])
467 continue;
469 memset(dec->ChannelMix, 0, SamplesToDo*sizeof(ALfloat));
470 MixMatrixRow(dec->ChannelMix, dec->MatrixHF[chan], dec->SamplesHF,
471 dec->NumChannels, SamplesToDo);
472 MixMatrixRow(dec->ChannelMix, dec->MatrixLF[chan], dec->SamplesLF,
473 dec->NumChannels, SamplesToDo);
475 if(dec->Delay[chan].Length > 0)
477 const ALuint base = dec->Delay[chan].Length;
478 if(SamplesToDo >= base)
480 for(i = 0;i < base;i++)
481 OutBuffer[chan][i] += dec->Delay[chan].Buffer[i];
482 for(;i < SamplesToDo;i++)
483 OutBuffer[chan][i] += dec->ChannelMix[i-base];
484 memcpy(dec->Delay[chan].Buffer, &dec->ChannelMix[SamplesToDo-base],
485 base*sizeof(ALfloat));
487 else
489 for(i = 0;i < SamplesToDo;i++)
490 OutBuffer[chan][i] += dec->Delay[chan].Buffer[i];
491 memmove(dec->Delay[chan].Buffer, dec->Delay[chan].Buffer+SamplesToDo,
492 base - SamplesToDo);
493 memcpy(dec->Delay[chan].Buffer+base-SamplesToDo, dec->ChannelMix,
494 SamplesToDo*sizeof(ALfloat));
497 else for(i = 0;i < SamplesToDo;i++)
498 OutBuffer[chan][i] += dec->ChannelMix[i];
501 else
503 for(chan = 0;chan < OutChannels;chan++)
505 if(!dec->Enabled[chan])
506 continue;
508 memset(dec->ChannelMix, 0, SamplesToDo*sizeof(ALfloat));
509 MixMatrixRow(dec->ChannelMix, dec->MatrixHF[chan], InSamples,
510 dec->NumChannels, SamplesToDo);
512 if(dec->Delay[chan].Length > 0)
514 const ALuint base = dec->Delay[chan].Length;
515 if(SamplesToDo >= base)
517 for(i = 0;i < base;i++)
518 OutBuffer[chan][i] += dec->Delay[chan].Buffer[i];
519 for(;i < SamplesToDo;i++)
520 OutBuffer[chan][i] += dec->ChannelMix[i-base];
521 memcpy(dec->Delay[chan].Buffer, &dec->ChannelMix[SamplesToDo-base],
522 base*sizeof(ALfloat));
524 else
526 for(i = 0;i < SamplesToDo;i++)
527 OutBuffer[chan][i] += dec->Delay[chan].Buffer[i];
528 memmove(dec->Delay[chan].Buffer, dec->Delay[chan].Buffer+SamplesToDo,
529 base - SamplesToDo);
530 memcpy(dec->Delay[chan].Buffer+base-SamplesToDo, dec->ChannelMix,
531 SamplesToDo*sizeof(ALfloat));
534 else for(i = 0;i < SamplesToDo;i++)
535 OutBuffer[chan][i] += dec->ChannelMix[i];
541 void bformatdec_upSample(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALfloat (*restrict InSamples)[BUFFERSIZE], ALuint InChannels, ALuint SamplesToDo)
543 ALuint i, j, k;
545 /* First, split the first-order components into low and high frequency
546 * bands. This assumes SamplesHF and SamplesLF have enough space for first-
547 * order content (to which, this up-sampler is only used with second-order
548 * or higher decoding, so it will).
550 for(i = 0;i < InChannels;i++)
551 bandsplit_process(&dec->UpSampler.XOver[i], dec->SamplesHF[i], dec->SamplesLF[i],
552 InSamples[i], SamplesToDo);
554 /* This up-sampler is very simplistic. It essentially decodes the first-
555 * order content to a square channel array (or cube if height is desired),
556 * then encodes those points onto the higher order soundfield.
558 for(k = 0;k < dec->UpSampler.NumChannels;k++)
560 memset(dec->ChannelMix, 0, SamplesToDo*sizeof(ALfloat));
561 MixMatrixRow(dec->ChannelMix, dec->UpSampler.MatrixHF[k], dec->SamplesHF,
562 InChannels, SamplesToDo);
563 MixMatrixRow(dec->ChannelMix, dec->UpSampler.MatrixLF[k], dec->SamplesLF,
564 InChannels, SamplesToDo);
566 for(j = 0;j < dec->NumChannels;j++)
568 ALfloat gain = dec->UpSampler.Encoder[k][j];
569 if(!(fabsf(gain) > GAIN_SILENCE_THRESHOLD))
570 continue;
571 for(i = 0;i < SamplesToDo;i++)
572 OutBuffer[j][i] += dec->ChannelMix[i] * gain;