aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2021-03-31 10:03:31 -0700
committerChris Robinson <[email protected]>2021-03-31 10:03:31 -0700
commitb5e36007f136f817e6d14685377e781e224daf17 (patch)
tree2b16156169cba4f4139ff16391e619f49fedce80 /alc
parent35a0f2665f834c107e39ec2dcfc3d9ae0a0b33ce (diff)
Handle 3-channel UHJ audio buffers
Diffstat (limited to 'alc')
-rw-r--r--alc/alu.cpp8
-rw-r--r--alc/buffer_storage.cpp1
-rw-r--r--alc/buffer_storage.h1
-rw-r--r--alc/effects/convolution.cpp3
-rw-r--r--alc/inprogext.h3
-rw-r--r--alc/voice.cpp6
6 files changed, 15 insertions, 7 deletions
diff --git a/alc/alu.cpp b/alc/alu.cpp
index 86cbefa5..7e6d6ca6 100644
--- a/alc/alu.cpp
+++ b/alc/alu.cpp
@@ -790,13 +790,14 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con
case FmtBFormat2D:
case FmtBFormat3D:
case FmtUHJ2:
+ case FmtUHJ3:
DirectChannels = DirectMode::Off;
break;
}
voice->mFlags &= ~(VoiceHasHrtf | VoiceHasNfc);
if(voice->mFmtChannels == FmtBFormat2D || voice->mFmtChannels == FmtBFormat3D
- || voice->mFmtChannels == FmtUHJ2)
+ || voice->mFmtChannels == FmtUHJ2 || voice->mFmtChannels == FmtUHJ3)
{
/* Special handling for B-Format sources. */
@@ -900,7 +901,8 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con
* whether input is 2D or 3D.
*/
const uint8_t *index_map{
- (voice->mFmtChannels == FmtBFormat2D || voice->mFmtChannels == FmtUHJ2) ?
+ (voice->mFmtChannels == FmtBFormat2D || voice->mFmtChannels == FmtUHJ2
+ || voice->mFmtChannels == FmtUHJ3) ?
GetAmbi2DLayout(voice->mAmbiLayout).data() :
GetAmbiLayout(voice->mAmbiLayout).data()};
@@ -1558,7 +1560,7 @@ void CalcSourceParams(Voice *voice, ALCcontext *context, bool force)
if((voice->mProps.DirectChannels != DirectMode::Off && voice->mFmtChannels != FmtMono
&& voice->mFmtChannels != FmtBFormat2D && voice->mFmtChannels != FmtBFormat3D
- && voice->mFmtChannels != FmtUHJ2)
+ && voice->mFmtChannels != FmtUHJ2 && voice->mFmtChannels != FmtUHJ3)
|| voice->mProps.mSpatializeMode==SpatializeMode::Off
|| (voice->mProps.mSpatializeMode==SpatializeMode::Auto && voice->mFmtChannels != FmtMono))
CalcNonAttnSourceParams(voice, &voice->mProps, context);
diff --git a/alc/buffer_storage.cpp b/alc/buffer_storage.cpp
index 58752341..1e35220a 100644
--- a/alc/buffer_storage.cpp
+++ b/alc/buffer_storage.cpp
@@ -34,6 +34,7 @@ uint ChannelsFromFmt(FmtChannels chans, uint ambiorder) noexcept
case FmtBFormat2D: return (ambiorder*2) + 1;
case FmtBFormat3D: return (ambiorder+1) * (ambiorder+1);
case FmtUHJ2: return 2;
+ case FmtUHJ3: return 3;
}
return 0;
}
diff --git a/alc/buffer_storage.h b/alc/buffer_storage.h
index 2f8da5e2..135b9b83 100644
--- a/alc/buffer_storage.h
+++ b/alc/buffer_storage.h
@@ -28,6 +28,7 @@ enum FmtChannels : unsigned char {
FmtBFormat2D,
FmtBFormat3D,
FmtUHJ2, /* 2-channel UHJ, aka "BHJ", stereo-compatible */
+ FmtUHJ3, /* 3-channel UHJ, aka "THJ", first-two channels are stereo-compatible */
};
enum class AmbiLayout : unsigned char {
diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp
index d03d661f..1ee59604 100644
--- a/alc/effects/convolution.cpp
+++ b/alc/effects/convolution.cpp
@@ -382,7 +382,7 @@ void ConvolutionState::update(const ALCcontext *context, const EffectSlot *slot,
* Not that UHJ should really ever be used for convolution, but it's a
* valid format regardless.
*/
- if(mChannels == FmtUHJ2 && target.RealOut
+ if((mChannels == FmtUHJ2 || mChannels == FmtUHJ3) && target.RealOut
&& target.RealOut->ChannelIndex[FrontLeft] != INVALID_CHANNEL_INDEX
&& target.RealOut->ChannelIndex[FrontRight] != INVALID_CHANNEL_INDEX)
{
@@ -435,6 +435,7 @@ void ConvolutionState::update(const ALCcontext *context, const EffectSlot *slot,
case FmtBFormat2D:
case FmtBFormat3D:
case FmtUHJ2:
+ case FmtUHJ3:
break;
}
diff --git a/alc/inprogext.h b/alc/inprogext.h
index a3319ff7..4f9c6715 100644
--- a/alc/inprogext.h
+++ b/alc/inprogext.h
@@ -81,6 +81,9 @@ ALCboolean ALC_APIENTRY alcReopenDeviceSOFT(ALCdevice *device, const ALCchar *de
#define AL_FORMAT_UHJ2CHN8 0x19A2
#define AL_FORMAT_UHJ2CHN16 0x19A3
#define AL_FORMAT_UHJ2CHN_FLOAT32 0x19A4
+#define AL_FORMAT_UHJ3CHN8 0x19A5
+#define AL_FORMAT_UHJ3CHN16 0x19A6
+#define AL_FORMAT_UHJ3CHN_FLOAT32 0x19A7
#endif
#ifdef __cplusplus
diff --git a/alc/voice.cpp b/alc/voice.cpp
index c3e3dca2..577d5f72 100644
--- a/alc/voice.cpp
+++ b/alc/voice.cpp
@@ -529,7 +529,7 @@ void Voice::mix(const State vstate, ALCcontext *Context, const uint SamplesToDo)
Counter = std::min(Counter, 64u);
const uint PostPadding{MaxResamplerEdge +
- ((mFmtChannels==FmtUHJ2) ? uint{UhjDecoder::sFilterDelay} : 0u)};
+ ((mFmtChannels==FmtUHJ2 || mFmtChannels==FmtUHJ3) ? uint{UhjDecoder::sFilterDelay} : 0u)};
uint buffers_done{0u};
uint OutPos{0u};
do {
@@ -823,9 +823,9 @@ void Voice::mix(const State vstate, ALCcontext *Context, const uint SamplesToDo)
void Voice::prepare(ALCdevice *device)
{
- if(mFmtChannels == FmtUHJ2 && !mDecoder)
+ if((mFmtChannels == FmtUHJ2 || mFmtChannels == FmtUHJ3) && !mDecoder)
mDecoder = std::make_unique<UhjDecoder>();
- else if(mFmtChannels != FmtUHJ2)
+ else if(mFmtChannels != FmtUHJ2 && mFmtChannels != FmtUHJ3)
mDecoder = nullptr;
/* Clear the stepping value explicitly so the mixer knows not to mix this