aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
Diffstat (limited to 'Alc')
-rw-r--r--Alc/bformatdec.c95
-rw-r--r--Alc/panning.c18
2 files changed, 94 insertions, 19 deletions
diff --git a/Alc/bformatdec.c b/Alc/bformatdec.c
index ab148d1b..3a07ac36 100644
--- a/Alc/bformatdec.c
+++ b/Alc/bformatdec.c
@@ -131,6 +131,8 @@ static alonce_flag encoder_inited = AL_ONCE_FLAG_INIT;
static void init_encoder(void)
{
+ ALuint i, j;
+
CalcXYZCoeffs(-0.577350269f, 0.577350269f, -0.577350269f, CubeEncoder[0]);
CalcXYZCoeffs( 0.577350269f, 0.577350269f, -0.577350269f, CubeEncoder[1]);
CalcXYZCoeffs(-0.577350269f, 0.577350269f, 0.577350269f, CubeEncoder[2]);
@@ -144,6 +146,18 @@ static void init_encoder(void)
CalcXYZCoeffs( 0.707106781f, 0.0f, -0.707106781f, SquareEncoder[1]);
CalcXYZCoeffs(-0.707106781f, 0.0f, 0.707106781f, SquareEncoder[2]);
CalcXYZCoeffs( 0.707106781f, 0.0f, 0.707106781f, SquareEncoder[3]);
+
+ for(i = 0;i < 4;i++)
+ {
+ /* Remove the skipped height-related coefficients for 2D rendering. */
+ SquareEncoder[i][2] = SquareEncoder[i][3];
+ SquareEncoder[i][3] = SquareEncoder[i][4];
+ SquareEncoder[i][4] = SquareEncoder[i][8];
+ SquareEncoder[i][5] = SquareEncoder[i][9];
+ SquareEncoder[i][6] = SquareEncoder[i][15];
+ for(j = 7;j < MAX_AMBI_COEFFS;j++)
+ SquareEncoder[i][j] = 0.0f;
+ }
}
@@ -169,6 +183,7 @@ typedef struct BFormatDec {
ALuint NumChannels;
ALboolean DualBand;
+ ALboolean Periphonic;
} BFormatDec;
BFormatDec *bformatdec_alloc()
@@ -193,14 +208,26 @@ void bformatdec_free(BFormatDec *dec)
int bformatdec_getOrder(const struct BFormatDec *dec)
{
- if(dec->NumChannels > 9) return 3;
- if(dec->NumChannels > 4) return 2;
- if(dec->NumChannels > 1) return 1;
+ if(dec->Periphonic)
+ {
+ if(dec->NumChannels > 9) return 3;
+ if(dec->NumChannels > 4) return 2;
+ if(dec->NumChannels > 1) return 1;
+ }
+ else
+ {
+ if(dec->NumChannels > 5) return 3;
+ if(dec->NumChannels > 3) return 2;
+ if(dec->NumChannels > 1) return 1;
+ }
return 0;
}
void bformatdec_reset(BFormatDec *dec, const AmbDecConf *conf, ALuint chancount, ALuint srate, const ALuint chanmap[MAX_OUTPUT_CHANNELS])
{
+ static const ALuint map2DTo3D[7] = {
+ 0, 1, 3, 4, 8, 9, 15
+ };
const ALfloat *coeff_scale = UnitScale;
ALfloat ratio;
ALuint i;
@@ -226,12 +253,14 @@ void bformatdec_reset(BFormatDec *dec, const AmbDecConf *conf, ALuint chancount,
dec->UpSampler.MatrixHF = CubeMatrixHF;
dec->UpSampler.Encoder = (const ALfloat(*)[MAX_AMBI_COEFFS])CubeEncoder;
dec->UpSampler.NumChannels = 8;
+ dec->Periphonic = AL_TRUE;
}
else
{
dec->UpSampler.MatrixHF = SquareMatrixHF;
dec->UpSampler.Encoder = (const ALfloat(*)[MAX_AMBI_COEFFS])SquareEncoder;
dec->UpSampler.NumChannels = 4;
+ dec->Periphonic = AL_FALSE;
}
if(conf->FreqBands == 1)
@@ -255,14 +284,30 @@ void bformatdec_reset(BFormatDec *dec, const AmbDecConf *conf, ALuint chancount,
ALuint j, k = 0;
ALfloat gain;
- for(j = 0;j < MAX_AMBI_COEFFS;j++)
+ if(!dec->Periphonic)
{
- if(j == 0) gain = conf->LFOrderGain[0] / ratio;
- else if(j == 1) gain = conf->LFOrderGain[1] / ratio;
- else if(j == 4) gain = conf->LFOrderGain[2] / ratio;
- else if(j == 9) gain = conf->LFOrderGain[3] / ratio;
- if((conf->ChanMask&(1<<j)))
- dec->MatrixLF[chan][j] = conf->LFMatrix[i][k++] / coeff_scale[j] * gain;
+ for(j = 0;j < 7;j++)
+ {
+ ALuint l = map2DTo3D[j];
+ if(j == 0) gain = conf->LFOrderGain[0] / ratio;
+ else if(j == 1) gain = conf->LFOrderGain[1] / ratio;
+ else if(j == 3) gain = conf->LFOrderGain[2] / ratio;
+ else if(j == 5) gain = conf->LFOrderGain[3] / ratio;
+ if((conf->ChanMask&(1<<l)))
+ dec->MatrixLF[chan][j] = conf->LFMatrix[i][k++] / coeff_scale[l] * gain;
+ }
+ }
+ else
+ {
+ for(j = 0;j < MAX_AMBI_COEFFS;j++)
+ {
+ if(j == 0) gain = conf->LFOrderGain[0] / ratio;
+ else if(j == 1) gain = conf->LFOrderGain[1] / ratio;
+ else if(j == 4) gain = conf->LFOrderGain[2] / ratio;
+ else if(j == 9) gain = conf->LFOrderGain[3] / ratio;
+ if((conf->ChanMask&(1<<j)))
+ dec->MatrixLF[chan][j] = conf->LFMatrix[i][k++] / coeff_scale[j] * gain;
+ }
}
}
}
@@ -274,14 +319,30 @@ void bformatdec_reset(BFormatDec *dec, const AmbDecConf *conf, ALuint chancount,
ALuint j, k = 0;
ALfloat gain;
- for(j = 0;j < MAX_AMBI_COEFFS;j++)
+ if(!dec->Periphonic)
+ {
+ for(j = 0;j < 7;j++)
+ {
+ ALuint l = map2DTo3D[j];
+ if(j == 0) gain = conf->HFOrderGain[0] * ratio;
+ else if(j == 1) gain = conf->HFOrderGain[1] * ratio;
+ else if(j == 3) gain = conf->HFOrderGain[2] * ratio;
+ else if(j == 5) gain = conf->HFOrderGain[3] * ratio;
+ if((conf->ChanMask&(1<<l)))
+ dec->MatrixHF[chan][j] = conf->HFMatrix[i][k++] / coeff_scale[l] * gain;
+ }
+ }
+ else
{
- if(j == 0) gain = conf->HFOrderGain[0] * ratio;
- else if(j == 1) gain = conf->HFOrderGain[1] * ratio;
- else if(j == 4) gain = conf->HFOrderGain[2] * ratio;
- else if(j == 9) gain = conf->HFOrderGain[3] * ratio;
- if((conf->ChanMask&(1<<j)))
- dec->MatrixHF[chan][j] = conf->HFMatrix[i][k++] / coeff_scale[j] * gain;
+ for(j = 0;j < MAX_AMBI_COEFFS;j++)
+ {
+ if(j == 0) gain = conf->HFOrderGain[0] * ratio;
+ else if(j == 1) gain = conf->HFOrderGain[1] * ratio;
+ else if(j == 4) gain = conf->HFOrderGain[2] * ratio;
+ else if(j == 9) gain = conf->HFOrderGain[3] * ratio;
+ if((conf->ChanMask&(1<<j)))
+ dec->MatrixHF[chan][j] = conf->HFMatrix[i][k++] / coeff_scale[j] * gain;
+ }
}
}
}
diff --git a/Alc/panning.c b/Alc/panning.c
index 6f6db3df..676896d8 100644
--- a/Alc/panning.c
+++ b/Alc/panning.c
@@ -596,6 +596,12 @@ ALvoid aluInitPanning(ALCdevice *device)
{ Aux6, { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f } },
{ Aux7, { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f } },
{ Aux8, { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } },
+ }, Ambi2D[5] = {
+ { Aux0, { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f } },
+ { Aux1, { 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f } },
+ { Aux2, { 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f } },
+ { Aux3, { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f } },
+ { Aux4, { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } },
};
ALuint speakermap[MAX_OUTPUT_CHANNELS];
const char *fname = "";
@@ -631,8 +637,16 @@ ALvoid aluInitPanning(ALCdevice *device)
if(!MakeSpeakerMap(device, &conf, speakermap))
goto ambi_fail;
- count = (conf.ChanMask > 0xf) ? COUNTOF(Ambi3D) : 4;
- chanmap = Ambi3D;
+ if((conf.ChanMask & ~0x831b))
+ {
+ count = (conf.ChanMask > 0xf) ? COUNTOF(Ambi3D) : 4;
+ chanmap = Ambi3D;
+ }
+ else
+ {
+ count = (conf.ChanMask > 0xf) ? COUNTOF(Ambi2D) : 3;
+ chanmap = Ambi2D;
+ }
ambiscale = 1.0f;
for(i = 0;i < count;i++)