Don't use periphonic FOA when the HOA decoder is not periphonic
This commit is contained in:
@@ -2118,16 +2118,21 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
|
||||
aluInitRenderer(device, hrtf_id, hrtf_appreq, hrtf_userreq);
|
||||
|
||||
/* Allocate extra channels for any post-filter output. */
|
||||
size = device->Dry.NumChannels * sizeof(device->Dry.Buffer[0]);
|
||||
if((device->AmbiDecoder && bformatdec_getOrder(device->AmbiDecoder) >= 2))
|
||||
size += (ChannelsFromDevFmt(device->FmtChans)+4) * sizeof(device->Dry.Buffer[0]);
|
||||
else if(device->Hrtf.Handle || device->Uhj_Encoder || device->AmbiDecoder)
|
||||
size = device->Dry.NumChannels;
|
||||
if(device->AmbiDecoder && bformatdec_getOrder(device->AmbiDecoder) >= 2)
|
||||
{
|
||||
size += ChannelsFromDevFmt(device->FmtChans) * sizeof(device->Dry.Buffer[0]);
|
||||
if(device->AmbiUp) size += 4 * sizeof(device->Dry.Buffer[0]);
|
||||
size += ChannelsFromDevFmt(device->FmtChans);
|
||||
size += bformatdec_isPeriphonic(device->AmbiDecoder) ? 4 : 3;
|
||||
}
|
||||
else if(device->AmbiUp)
|
||||
size += 4 * sizeof(device->Dry.Buffer[0]);
|
||||
else
|
||||
{
|
||||
if(device->Hrtf.Handle || device->Uhj_Encoder || device->AmbiDecoder)
|
||||
size += ChannelsFromDevFmt(device->FmtChans);
|
||||
if(device->AmbiUp)
|
||||
size += 4;
|
||||
}
|
||||
size *= sizeof(device->Dry.Buffer[0]);
|
||||
|
||||
TRACE("Allocating "SZFMT" channels, "SZFMT" bytes\n", size/sizeof(device->Dry.Buffer[0]), size);
|
||||
device->Dry.Buffer = al_calloc(16, size);
|
||||
if(!device->Dry.Buffer)
|
||||
@@ -2136,9 +2141,26 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
|
||||
return ALC_INVALID_DEVICE;
|
||||
}
|
||||
|
||||
if((device->AmbiDecoder && bformatdec_getOrder(device->AmbiDecoder) >= 2) || device->AmbiUp)
|
||||
{
|
||||
/* Higher-order rendering requires upsampling first-order content, so
|
||||
* make sure to mix it separately.
|
||||
*/
|
||||
device->FOAOut.Buffer = device->Dry.Buffer + device->Dry.NumChannels;
|
||||
if((device->AmbiDecoder && bformatdec_isPeriphonic(device->AmbiDecoder)) || device->AmbiUp)
|
||||
device->FOAOut.NumChannels = 4;
|
||||
else
|
||||
device->FOAOut.NumChannels = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
device->FOAOut.Buffer = device->Dry.Buffer;
|
||||
device->FOAOut.NumChannels = device->Dry.NumChannels;
|
||||
}
|
||||
|
||||
if(device->Hrtf.Handle || device->Uhj_Encoder || device->AmbiDecoder)
|
||||
{
|
||||
device->RealOut.Buffer = device->Dry.Buffer + device->Dry.NumChannels;
|
||||
device->RealOut.Buffer = device->FOAOut.Buffer + device->FOAOut.NumChannels;
|
||||
device->RealOut.NumChannels = ChannelsFromDevFmt(device->FmtChans);
|
||||
}
|
||||
else
|
||||
@@ -2146,20 +2168,6 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
|
||||
device->RealOut.Buffer = device->Dry.Buffer;
|
||||
device->RealOut.NumChannels = device->Dry.NumChannels;
|
||||
}
|
||||
|
||||
if((device->AmbiDecoder && bformatdec_getOrder(device->AmbiDecoder) >= 2) || device->AmbiUp)
|
||||
{
|
||||
/* Higher-order rendering requires upsampling first-order content, so
|
||||
* make sure to mix it separately.
|
||||
*/
|
||||
device->FOAOut.Buffer = device->RealOut.Buffer + device->RealOut.NumChannels;
|
||||
device->FOAOut.NumChannels = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
device->FOAOut.Buffer = device->Dry.Buffer;
|
||||
device->FOAOut.NumChannels = device->Dry.NumChannels;
|
||||
}
|
||||
TRACE("Channel config, Dry: %d, FOA: %d, Real: %d\n", device->Dry.NumChannels,
|
||||
device->FOAOut.NumChannels, device->RealOut.NumChannels);
|
||||
|
||||
|
||||
@@ -81,7 +81,6 @@ extern inline ALuint64 clampu64(ALuint64 val, ALuint64 min, ALuint64 max);
|
||||
|
||||
extern inline ALfloat lerp(ALfloat val1, ALfloat val2, ALfloat mu);
|
||||
extern inline ALfloat resample_fir4(ALfloat val0, ALfloat val1, ALfloat val2, ALfloat val3, ALuint frac);
|
||||
extern inline ALfloat resample_fir8(ALfloat val0, ALfloat val1, ALfloat val2, ALfloat val3, ALfloat val4, ALfloat val5, ALfloat val6, ALfloat val7, ALuint frac);
|
||||
|
||||
extern inline void aluVectorSet(aluVector *restrict vector, ALfloat x, ALfloat y, ALfloat z, ALfloat w);
|
||||
|
||||
@@ -1415,12 +1414,12 @@ void aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
|
||||
SamplesToDo = mini(size, BUFFERSIZE);
|
||||
for(c = 0;c < device->Dry.NumChannels;c++)
|
||||
memset(device->Dry.Buffer[c], 0, SamplesToDo*sizeof(ALfloat));
|
||||
if(device->Dry.Buffer != device->RealOut.Buffer)
|
||||
for(c = 0;c < device->RealOut.NumChannels;c++)
|
||||
memset(device->RealOut.Buffer[c], 0, SamplesToDo*sizeof(ALfloat));
|
||||
if(device->Dry.Buffer != device->FOAOut.Buffer)
|
||||
for(c = 0;c < device->FOAOut.NumChannels;c++)
|
||||
memset(device->FOAOut.Buffer[c], 0, SamplesToDo*sizeof(ALfloat));
|
||||
if(device->Dry.Buffer != device->RealOut.Buffer)
|
||||
for(c = 0;c < device->RealOut.NumChannels;c++)
|
||||
memset(device->RealOut.Buffer[c], 0, SamplesToDo*sizeof(ALfloat));
|
||||
|
||||
IncrementRef(&device->MixCount);
|
||||
|
||||
|
||||
+9
-13
@@ -184,10 +184,7 @@ typedef struct BFormatDec {
|
||||
} Delay[MAX_OUTPUT_CHANNELS];
|
||||
|
||||
struct {
|
||||
ALsizei Index;
|
||||
|
||||
BandSplitter XOver;
|
||||
|
||||
ALfloat Gains[FB_Max];
|
||||
} UpSampler[4];
|
||||
|
||||
@@ -233,6 +230,11 @@ int bformatdec_getOrder(const struct BFormatDec *dec)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bformatdec_isPeriphonic(const struct BFormatDec *dec)
|
||||
{
|
||||
return dec->Periphonic;
|
||||
}
|
||||
|
||||
void bformatdec_reset(BFormatDec *dec, const AmbDecConf *conf, ALsizei chancount, ALuint srate, const ALsizei chanmap[MAX_OUTPUT_CHANNELS], int flags)
|
||||
{
|
||||
static const ALsizei map2DTo3D[MAX_AMBI2D_COEFFS] = {
|
||||
@@ -271,13 +273,11 @@ void bformatdec_reset(BFormatDec *dec, const AmbDecConf *conf, ALsizei chancount
|
||||
{
|
||||
dec->Periphonic = AL_TRUE;
|
||||
|
||||
dec->UpSampler[0].Index = 0;
|
||||
dec->UpSampler[0].Gains[FB_HighFreq] = (dec->NumChannels > 9) ? W_SCALE3D_THIRD :
|
||||
(dec->NumChannels > 4) ? W_SCALE3D_SECOND : 1.0f;
|
||||
dec->UpSampler[0].Gains[FB_LowFreq] = 1.0f;
|
||||
for(i = 1;i < 4;i++)
|
||||
{
|
||||
dec->UpSampler[i].Index = i;
|
||||
dec->UpSampler[i].Gains[FB_HighFreq] = (dec->NumChannels > 9) ? XYZ_SCALE3D_THIRD :
|
||||
(dec->NumChannels > 4) ? XYZ_SCALE3D_SECOND : 1.0f;
|
||||
dec->UpSampler[i].Gains[FB_LowFreq] = 1.0f;
|
||||
@@ -287,17 +287,17 @@ void bformatdec_reset(BFormatDec *dec, const AmbDecConf *conf, ALsizei chancount
|
||||
{
|
||||
dec->Periphonic = AL_FALSE;
|
||||
|
||||
dec->UpSampler[0].Index = 0;
|
||||
dec->UpSampler[0].Gains[FB_HighFreq] = (dec->NumChannels > 5) ? W_SCALE2D_THIRD :
|
||||
(dec->NumChannels > 3) ? W_SCALE2D_SECOND : 1.0f;
|
||||
dec->UpSampler[0].Gains[FB_LowFreq] = 1.0f;
|
||||
for(i = 1;i < 4;i++)
|
||||
for(i = 1;i < 3;i++)
|
||||
{
|
||||
dec->UpSampler[i].Index = (i>2) ? i-1 : ((i==2) ? INVALID_UPSAMPLE_INDEX : i);
|
||||
dec->UpSampler[i].Gains[FB_HighFreq] = (dec->NumChannels > 5) ? XYZ_SCALE2D_THIRD :
|
||||
(dec->NumChannels > 3) ? XYZ_SCALE2D_SECOND : 1.0f;
|
||||
dec->UpSampler[i].Gains[FB_LowFreq] = 1.0f;
|
||||
}
|
||||
dec->UpSampler[3].Gains[FB_HighFreq] = 0.0f;
|
||||
dec->UpSampler[3].Gains[FB_LowFreq] = 0.0f;
|
||||
}
|
||||
|
||||
maxdist = 0.0f;
|
||||
@@ -553,10 +553,6 @@ void bformatdec_upSample(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[B
|
||||
*/
|
||||
for(i = 0;i < InChannels;i++)
|
||||
{
|
||||
ALsizei dst_chan = dec->UpSampler[i].Index;
|
||||
if(dst_chan == INVALID_UPSAMPLE_INDEX)
|
||||
continue;
|
||||
|
||||
/* First, split the first-order components into low and high frequency
|
||||
* bands.
|
||||
*/
|
||||
@@ -566,7 +562,7 @@ void bformatdec_upSample(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[B
|
||||
);
|
||||
|
||||
/* Now write each band to the output. */
|
||||
MixMatrixRow(OutBuffer[dst_chan], dec->UpSampler[i].Gains,
|
||||
MixMatrixRow(OutBuffer[i], dec->UpSampler[i].Gains,
|
||||
SAFE_CONST(ALfloatBUFFERSIZE*,dec->Samples), FB_Max, 0,
|
||||
SamplesToDo
|
||||
);
|
||||
|
||||
@@ -32,6 +32,7 @@ enum BFormatDecFlags {
|
||||
struct BFormatDec *bformatdec_alloc();
|
||||
void bformatdec_free(struct BFormatDec *dec);
|
||||
int bformatdec_getOrder(const struct BFormatDec *dec);
|
||||
int bformatdec_isPeriphonic(const struct BFormatDec *dec);
|
||||
void bformatdec_reset(struct BFormatDec *dec, const struct AmbDecConf *conf, ALsizei chancount, ALuint srate, const ALsizei chanmap[MAX_OUTPUT_CHANNELS], int flags);
|
||||
|
||||
/* Decodes the ambisonic input to the given output channels. */
|
||||
|
||||
+13
-3
@@ -742,10 +742,20 @@ static void InitHQPanning(ALCdevice *device, const AmbDecConf *conf, const ALsiz
|
||||
else
|
||||
{
|
||||
memset(&device->FOAOut.Ambi, 0, sizeof(device->FOAOut.Ambi));
|
||||
for(i = 0;i < 4;i++)
|
||||
if((conf->ChanMask&AMBI_PERIPHONIC_MASK))
|
||||
for(i = 0;i < 4;i++)
|
||||
{
|
||||
device->FOAOut.Ambi.Map[i].Scale = 1.0f;
|
||||
device->FOAOut.Ambi.Map[i].Index = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
device->FOAOut.Ambi.Map[i].Scale = 1.0f;
|
||||
device->FOAOut.Ambi.Map[i].Index = i;
|
||||
static const int map[3] = { 0, 1, 3 };
|
||||
for(i = 0;i < 3;i++)
|
||||
{
|
||||
device->FOAOut.Ambi.Map[i].Scale = 1.0f;
|
||||
device->FOAOut.Ambi.Map[i].Index = map[i];
|
||||
}
|
||||
}
|
||||
device->FOAOut.CoeffCount = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user