From 34539bc973fc6ee525a4ba21f5653820e62004ae Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 28 Mar 2016 14:50:18 -0700 Subject: Skip unused output channels for the HQ decode --- Alc/bformatdec.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Alc/bformatdec.c b/Alc/bformatdec.c index ce489dc1..6dd5ce9a 100644 --- a/Alc/bformatdec.c +++ b/Alc/bformatdec.c @@ -167,6 +167,8 @@ static void init_encoder(void) * single-band decoding */ typedef struct BFormatDec { + ALboolean Enabled[MAX_OUTPUT_CHANNELS]; + alignas(16) ALfloat MatrixHF[MAX_OUTPUT_CHANNELS][MAX_AMBI_COEFFS]; alignas(16) ALfloat MatrixLF[MAX_OUTPUT_CHANNELS][MAX_AMBI_COEFFS]; @@ -253,6 +255,11 @@ void bformatdec_reset(BFormatDec *dec, const AmbDecConf *conf, ALuint chancount, dec->SamplesHF = dec->Samples; dec->SamplesLF = dec->SamplesHF + dec->NumChannels; + for(i = 0;i < MAX_OUTPUT_CHANNELS;i++) + dec->Enabled[i] = AL_FALSE; + for(i = 0;i < conf->NumSpeakers;i++) + dec->Enabled[chanmap[i]] = AL_TRUE; + if(conf->CoeffScale == ADS_SN3D) coeff_scale = SN3D2N3DScale; else if(conf->CoeffScale == ADS_FuMa) @@ -423,6 +430,9 @@ void bformatdec_process(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BU for(chan = 0;chan < OutChannels;chan++) { + if(!dec->Enabled[chan]) + continue; + memset(dec->ChannelMix, 0, SamplesToDo*sizeof(ALfloat)); apply_row(dec->ChannelMix, dec->MatrixHF[chan], dec->SamplesHF, dec->NumChannels, SamplesToDo); @@ -459,6 +469,9 @@ void bformatdec_process(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BU { for(chan = 0;chan < OutChannels;chan++) { + if(!dec->Enabled[chan]) + continue; + memset(dec->ChannelMix, 0, SamplesToDo*sizeof(ALfloat)); apply_row(dec->ChannelMix, dec->MatrixHF[chan], InSamples, dec->NumChannels, SamplesToDo); -- cgit v1.2.3