Implement a Neon-enhanced MixRow
[openal-soft.git] / Alc / bformatdec.c
blob9ebaba27c127a2da09e20cbca2e6d8cdb5b18e47
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 #ifdef HAVE_NEON
163 if((CPUCapFlags&CPU_CAP_NEON))
164 return MixRow_Neon;
165 #endif
166 return MixRow_C;
169 static MatrixMixerFunc MixMatrixRow = MixRow_C;
172 static alonce_flag bformatdec_inited = AL_ONCE_FLAG_INIT;
174 static void init_bformatdec(void)
176 ALuint i, j;
178 MixMatrixRow = SelectMixer();
180 CalcXYZCoeffs(-0.577350269f, 0.577350269f, -0.577350269f, 0.0f, CubeEncoder[0]);
181 CalcXYZCoeffs( 0.577350269f, 0.577350269f, -0.577350269f, 0.0f, CubeEncoder[1]);
182 CalcXYZCoeffs(-0.577350269f, 0.577350269f, 0.577350269f, 0.0f, CubeEncoder[2]);
183 CalcXYZCoeffs( 0.577350269f, 0.577350269f, 0.577350269f, 0.0f, CubeEncoder[3]);
184 CalcXYZCoeffs(-0.577350269f, -0.577350269f, -0.577350269f, 0.0f, CubeEncoder[4]);
185 CalcXYZCoeffs( 0.577350269f, -0.577350269f, -0.577350269f, 0.0f, CubeEncoder[5]);
186 CalcXYZCoeffs(-0.577350269f, -0.577350269f, 0.577350269f, 0.0f, CubeEncoder[6]);
187 CalcXYZCoeffs( 0.577350269f, -0.577350269f, 0.577350269f, 0.0f, CubeEncoder[7]);
189 CalcXYZCoeffs(-0.707106781f, 0.0f, -0.707106781f, 0.0f, SquareEncoder[0]);
190 CalcXYZCoeffs( 0.707106781f, 0.0f, -0.707106781f, 0.0f, SquareEncoder[1]);
191 CalcXYZCoeffs(-0.707106781f, 0.0f, 0.707106781f, 0.0f, SquareEncoder[2]);
192 CalcXYZCoeffs( 0.707106781f, 0.0f, 0.707106781f, 0.0f, SquareEncoder[3]);
194 for(i = 0;i < 4;i++)
196 /* Remove the skipped height-related coefficients for 2D rendering. */
197 SquareEncoder[i][2] = SquareEncoder[i][3];
198 SquareEncoder[i][3] = SquareEncoder[i][4];
199 SquareEncoder[i][4] = SquareEncoder[i][8];
200 SquareEncoder[i][5] = SquareEncoder[i][9];
201 SquareEncoder[i][6] = SquareEncoder[i][15];
202 for(j = 7;j < MAX_AMBI_COEFFS;j++)
203 SquareEncoder[i][j] = 0.0f;
208 #define MAX_DELAY_LENGTH 128
210 /* NOTE: Low-frequency (LF) fields and BandSplitter filters are unused with
211 * single-band decoding
213 typedef struct BFormatDec {
214 ALboolean Enabled[MAX_OUTPUT_CHANNELS];
216 alignas(16) ALfloat MatrixHF[MAX_OUTPUT_CHANNELS][MAX_AMBI_COEFFS];
217 alignas(16) ALfloat MatrixLF[MAX_OUTPUT_CHANNELS][MAX_AMBI_COEFFS];
219 BandSplitter XOver[MAX_AMBI_COEFFS];
221 ALfloat (*Samples)[BUFFERSIZE];
222 /* These two alias into Samples */
223 ALfloat (*SamplesHF)[BUFFERSIZE];
224 ALfloat (*SamplesLF)[BUFFERSIZE];
226 alignas(16) ALfloat ChannelMix[BUFFERSIZE];
228 struct {
229 alignas(16) ALfloat Buffer[MAX_DELAY_LENGTH];
230 ALuint Length; /* Valid range is [0...MAX_DELAY_LENGTH). */
231 } Delay[MAX_OUTPUT_CHANNELS];
233 struct {
234 BandSplitter XOver[4];
236 const ALfloat (*restrict MatrixHF)[MAX_AMBI_COEFFS];
237 const ALfloat (*restrict MatrixLF)[MAX_AMBI_COEFFS];
238 const ALfloat (*restrict Encoder)[MAX_AMBI_COEFFS];
239 ALuint NumChannels;
240 } UpSampler;
242 ALuint NumChannels;
243 ALboolean DualBand;
244 ALboolean Periphonic;
245 } BFormatDec;
247 BFormatDec *bformatdec_alloc()
249 alcall_once(&bformatdec_inited, init_bformatdec);
250 return al_calloc(16, sizeof(BFormatDec));
253 void bformatdec_free(BFormatDec *dec)
255 if(dec)
257 al_free(dec->Samples);
258 dec->Samples = NULL;
259 dec->SamplesHF = NULL;
260 dec->SamplesLF = NULL;
262 memset(dec, 0, sizeof(*dec));
263 al_free(dec);
267 int bformatdec_getOrder(const struct BFormatDec *dec)
269 if(dec->Periphonic)
271 if(dec->NumChannels > 9) return 3;
272 if(dec->NumChannels > 4) return 2;
273 if(dec->NumChannels > 1) return 1;
275 else
277 if(dec->NumChannels > 5) return 3;
278 if(dec->NumChannels > 3) return 2;
279 if(dec->NumChannels > 1) return 1;
281 return 0;
284 void bformatdec_reset(BFormatDec *dec, const AmbDecConf *conf, ALuint chancount, ALuint srate, const ALuint chanmap[MAX_OUTPUT_CHANNELS], int flags)
286 static const ALuint map2DTo3D[7] = {
287 0, 1, 3, 4, 8, 9, 15
289 const ALfloat *coeff_scale = UnitScale;
290 ALfloat distgain[MAX_OUTPUT_CHANNELS];
291 ALfloat maxdist, ratio;
292 ALuint i;
294 al_free(dec->Samples);
295 dec->Samples = NULL;
296 dec->SamplesHF = NULL;
297 dec->SamplesLF = NULL;
299 dec->NumChannels = chancount;
300 dec->Samples = al_calloc(16, dec->NumChannels*2 * sizeof(dec->Samples[0]));
301 dec->SamplesHF = dec->Samples;
302 dec->SamplesLF = dec->SamplesHF + dec->NumChannels;
304 for(i = 0;i < MAX_OUTPUT_CHANNELS;i++)
305 dec->Enabled[i] = AL_FALSE;
306 for(i = 0;i < conf->NumSpeakers;i++)
307 dec->Enabled[chanmap[i]] = AL_TRUE;
309 if(conf->CoeffScale == ADS_SN3D)
310 coeff_scale = SN3D2N3DScale;
311 else if(conf->CoeffScale == ADS_FuMa)
312 coeff_scale = FuMa2N3DScale;
314 ratio = 400.0f / (ALfloat)srate;
315 for(i = 0;i < 4;i++)
316 bandsplit_init(&dec->UpSampler.XOver[i], ratio);
317 if((conf->ChanMask&AMBI_PERIPHONIC_MASK))
319 dec->UpSampler.MatrixHF = CubeMatrixHF;
320 dec->UpSampler.MatrixLF = CubeMatrixLF;
321 dec->UpSampler.Encoder = (const ALfloat(*)[MAX_AMBI_COEFFS])CubeEncoder;
322 dec->UpSampler.NumChannels = 8;
323 dec->Periphonic = AL_TRUE;
325 else
327 dec->UpSampler.MatrixHF = SquareMatrixHF;
328 dec->UpSampler.MatrixLF = SquareMatrixLF;
329 dec->UpSampler.Encoder = (const ALfloat(*)[MAX_AMBI_COEFFS])SquareEncoder;
330 dec->UpSampler.NumChannels = 4;
331 dec->Periphonic = AL_FALSE;
334 maxdist = 0.0f;
335 for(i = 0;i < conf->NumSpeakers;i++)
337 maxdist = maxf(maxdist, conf->Speakers[i].Distance);
338 distgain[i] = 1.0f;
341 memset(dec->Delay, 0, sizeof(dec->Delay));
342 if((flags&BFDF_DistanceComp) && maxdist > 0.0f)
344 for(i = 0;i < conf->NumSpeakers;i++)
346 ALuint chan = chanmap[i];
347 ALfloat delay;
349 /* Distance compensation only delays in steps of the sample rate.
350 * This is a bit less accurate since the delay time falls to the
351 * nearest sample time, but it's far simpler as it doesn't have to
352 * deal with phase offsets. This means at 48khz, for instance, the
353 * distance delay will be in steps of about 7 millimeters.
355 delay = floorf((maxdist-conf->Speakers[i].Distance) / SPEEDOFSOUNDMETRESPERSEC *
356 (ALfloat)srate + 0.5f);
357 if(delay >= (ALfloat)MAX_DELAY_LENGTH)
358 ERR("Delay for speaker \"%s\" exceeds buffer length (%f >= %u)\n",
359 al_string_get_cstr(conf->Speakers[i].Name), delay, MAX_DELAY_LENGTH);
361 dec->Delay[chan].Length = (ALuint)clampf(delay, 0.0f, (ALfloat)(MAX_DELAY_LENGTH-1));
362 distgain[i] = conf->Speakers[i].Distance / maxdist;
363 TRACE("Channel %u \"%s\" distance compensation: %u samples, %f gain\n", chan,
364 al_string_get_cstr(conf->Speakers[i].Name), dec->Delay[chan].Length, distgain[i]
369 if(conf->FreqBands == 1)
371 dec->DualBand = AL_FALSE;
372 ratio = 1.0f;
374 else
376 dec->DualBand = AL_TRUE;
378 ratio = conf->XOverFreq / (ALfloat)srate;
379 for(i = 0;i < MAX_AMBI_COEFFS;i++)
380 bandsplit_init(&dec->XOver[i], ratio);
382 ratio = powf(10.0f, conf->XOverRatio / 40.0f);
383 memset(dec->MatrixLF, 0, sizeof(dec->MatrixLF));
384 for(i = 0;i < conf->NumSpeakers;i++)
386 ALuint chan = chanmap[i];
387 ALuint j, k = 0;
388 ALfloat gain;
390 if(!dec->Periphonic)
392 for(j = 0;j < 7;j++)
394 ALuint l = map2DTo3D[j];
395 if(j == 0) gain = conf->LFOrderGain[0] / ratio;
396 else if(j == 1) gain = conf->LFOrderGain[1] / ratio;
397 else if(j == 3) gain = conf->LFOrderGain[2] / ratio;
398 else if(j == 5) gain = conf->LFOrderGain[3] / ratio;
399 if((conf->ChanMask&(1<<l)))
400 dec->MatrixLF[chan][j] = conf->LFMatrix[i][k++] / coeff_scale[l] *
401 gain * distgain[i];
404 else
406 for(j = 0;j < MAX_AMBI_COEFFS;j++)
408 if(j == 0) gain = conf->LFOrderGain[0] / ratio;
409 else if(j == 1) gain = conf->LFOrderGain[1] / ratio;
410 else if(j == 4) gain = conf->LFOrderGain[2] / ratio;
411 else if(j == 9) gain = conf->LFOrderGain[3] / ratio;
412 if((conf->ChanMask&(1<<j)))
413 dec->MatrixLF[chan][j] = conf->LFMatrix[i][k++] / coeff_scale[j] *
414 gain * distgain[i];
420 memset(dec->MatrixHF, 0, sizeof(dec->MatrixHF));
421 for(i = 0;i < conf->NumSpeakers;i++)
423 ALuint chan = chanmap[i];
424 ALuint j, k = 0;
425 ALfloat gain;
427 if(!dec->Periphonic)
429 for(j = 0;j < 7;j++)
431 ALuint l = map2DTo3D[j];
432 if(j == 0) gain = conf->HFOrderGain[0] * ratio;
433 else if(j == 1) gain = conf->HFOrderGain[1] * ratio;
434 else if(j == 3) gain = conf->HFOrderGain[2] * ratio;
435 else if(j == 5) gain = conf->HFOrderGain[3] * ratio;
436 if((conf->ChanMask&(1<<l)))
437 dec->MatrixHF[chan][j] = conf->HFMatrix[i][k++] / coeff_scale[l] *
438 gain * distgain[i];
441 else
443 for(j = 0;j < MAX_AMBI_COEFFS;j++)
445 if(j == 0) gain = conf->HFOrderGain[0] * ratio;
446 else if(j == 1) gain = conf->HFOrderGain[1] * ratio;
447 else if(j == 4) gain = conf->HFOrderGain[2] * ratio;
448 else if(j == 9) gain = conf->HFOrderGain[3] * ratio;
449 if((conf->ChanMask&(1<<j)))
450 dec->MatrixHF[chan][j] = conf->HFMatrix[i][k++] / coeff_scale[j] *
451 gain * distgain[i];
458 void bformatdec_process(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint OutChannels, ALfloat (*restrict InSamples)[BUFFERSIZE], ALuint SamplesToDo)
460 ALuint chan, i;
462 if(dec->DualBand)
464 for(i = 0;i < dec->NumChannels;i++)
465 bandsplit_process(&dec->XOver[i], dec->SamplesHF[i], dec->SamplesLF[i],
466 InSamples[i], SamplesToDo);
468 for(chan = 0;chan < OutChannels;chan++)
470 if(!dec->Enabled[chan])
471 continue;
473 memset(dec->ChannelMix, 0, SamplesToDo*sizeof(ALfloat));
474 MixMatrixRow(dec->ChannelMix, dec->MatrixHF[chan], dec->SamplesHF,
475 dec->NumChannels, SamplesToDo);
476 MixMatrixRow(dec->ChannelMix, dec->MatrixLF[chan], dec->SamplesLF,
477 dec->NumChannels, SamplesToDo);
479 if(dec->Delay[chan].Length > 0)
481 const ALuint base = dec->Delay[chan].Length;
482 if(SamplesToDo >= base)
484 for(i = 0;i < base;i++)
485 OutBuffer[chan][i] += dec->Delay[chan].Buffer[i];
486 for(;i < SamplesToDo;i++)
487 OutBuffer[chan][i] += dec->ChannelMix[i-base];
488 memcpy(dec->Delay[chan].Buffer, &dec->ChannelMix[SamplesToDo-base],
489 base*sizeof(ALfloat));
491 else
493 for(i = 0;i < SamplesToDo;i++)
494 OutBuffer[chan][i] += dec->Delay[chan].Buffer[i];
495 memmove(dec->Delay[chan].Buffer, dec->Delay[chan].Buffer+SamplesToDo,
496 base - SamplesToDo);
497 memcpy(dec->Delay[chan].Buffer+base-SamplesToDo, dec->ChannelMix,
498 SamplesToDo*sizeof(ALfloat));
501 else for(i = 0;i < SamplesToDo;i++)
502 OutBuffer[chan][i] += dec->ChannelMix[i];
505 else
507 for(chan = 0;chan < OutChannels;chan++)
509 if(!dec->Enabled[chan])
510 continue;
512 memset(dec->ChannelMix, 0, SamplesToDo*sizeof(ALfloat));
513 MixMatrixRow(dec->ChannelMix, dec->MatrixHF[chan], InSamples,
514 dec->NumChannels, SamplesToDo);
516 if(dec->Delay[chan].Length > 0)
518 const ALuint base = dec->Delay[chan].Length;
519 if(SamplesToDo >= base)
521 for(i = 0;i < base;i++)
522 OutBuffer[chan][i] += dec->Delay[chan].Buffer[i];
523 for(;i < SamplesToDo;i++)
524 OutBuffer[chan][i] += dec->ChannelMix[i-base];
525 memcpy(dec->Delay[chan].Buffer, &dec->ChannelMix[SamplesToDo-base],
526 base*sizeof(ALfloat));
528 else
530 for(i = 0;i < SamplesToDo;i++)
531 OutBuffer[chan][i] += dec->Delay[chan].Buffer[i];
532 memmove(dec->Delay[chan].Buffer, dec->Delay[chan].Buffer+SamplesToDo,
533 base - SamplesToDo);
534 memcpy(dec->Delay[chan].Buffer+base-SamplesToDo, dec->ChannelMix,
535 SamplesToDo*sizeof(ALfloat));
538 else for(i = 0;i < SamplesToDo;i++)
539 OutBuffer[chan][i] += dec->ChannelMix[i];
545 void bformatdec_upSample(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALfloat (*restrict InSamples)[BUFFERSIZE], ALuint InChannels, ALuint SamplesToDo)
547 ALuint i, j, k;
549 /* First, split the first-order components into low and high frequency
550 * bands. This assumes SamplesHF and SamplesLF have enough space for first-
551 * order content (to which, this up-sampler is only used with second-order
552 * or higher decoding, so it will).
554 for(i = 0;i < InChannels;i++)
555 bandsplit_process(&dec->UpSampler.XOver[i], dec->SamplesHF[i], dec->SamplesLF[i],
556 InSamples[i], SamplesToDo);
558 /* This up-sampler is very simplistic. It essentially decodes the first-
559 * order content to a square channel array (or cube if height is desired),
560 * then encodes those points onto the higher order soundfield.
562 for(k = 0;k < dec->UpSampler.NumChannels;k++)
564 memset(dec->ChannelMix, 0, SamplesToDo*sizeof(ALfloat));
565 MixMatrixRow(dec->ChannelMix, dec->UpSampler.MatrixHF[k], dec->SamplesHF,
566 InChannels, SamplesToDo);
567 MixMatrixRow(dec->ChannelMix, dec->UpSampler.MatrixLF[k], dec->SamplesLF,
568 InChannels, SamplesToDo);
570 for(j = 0;j < dec->NumChannels;j++)
572 ALfloat gain = dec->UpSampler.Encoder[k][j];
573 if(!(fabsf(gain) > GAIN_SILENCE_THRESHOLD))
574 continue;
575 for(i = 0;i < SamplesToDo;i++)
576 OutBuffer[j][i] += dec->ChannelMix[i] * gain;