From 0b700286bd33abca9526d30496745d7a52cbeb1a Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 26 Feb 2023 00:43:25 -0800 Subject: [PATCH] Add formats for UHJ with muLaw, and ADPCM for 2-channel UHJ ADPCM doesn't seem to be well defined for more than two channels, even though there doesn't seem to be any issue with simply increasing the channel step over interleaved data (ffmpeg refuses to create IMA4 or MSADPCM files with more than two channels, and its decoder behaves oddly different when channels > 2). So IMA4 and MSADPCM can only safely handle 2-channel UHJ. There's no problem with muLaw supporting 2-, 3-, or 4-channel UHJ though. --- al/buffer.cpp | 13 +++++++++---- alc/inprogext.h | 12 +++++++++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/al/buffer.cpp b/al/buffer.cpp index 2313a067..25f0b9e0 100644 --- a/al/buffer.cpp +++ b/al/buffer.cpp @@ -537,7 +537,7 @@ al::optional DecomposeUserFormat(ALenum format) UserFmtChannels channels; UserFmtType type; }; - static const std::array UserFmtList{{ + static const std::array UserFmtList{{ { AL_FORMAT_MONO8, UserFmtMono, UserFmtUByte }, { AL_FORMAT_MONO16, UserFmtMono, UserFmtShort }, { AL_FORMAT_MONO_FLOAT32, UserFmtMono, UserFmtFloat }, @@ -594,17 +594,22 @@ al::optional DecomposeUserFormat(ALenum format) { AL_FORMAT_BFORMAT3D_FLOAT32, UserFmtBFormat3D, UserFmtFloat }, { AL_FORMAT_BFORMAT3D_MULAW, UserFmtBFormat3D, UserFmtMulaw }, - { AL_FORMAT_UHJ2CHN8_SOFT, UserFmtUHJ2, UserFmtUByte }, - { AL_FORMAT_UHJ2CHN16_SOFT, UserFmtUHJ2, UserFmtShort }, - { AL_FORMAT_UHJ2CHN_FLOAT32_SOFT, UserFmtUHJ2, UserFmtFloat }, + { AL_FORMAT_UHJ2CHN8_SOFT, UserFmtUHJ2, UserFmtUByte }, + { AL_FORMAT_UHJ2CHN16_SOFT, UserFmtUHJ2, UserFmtShort }, + { AL_FORMAT_UHJ2CHN_FLOAT32_SOFT, UserFmtUHJ2, UserFmtFloat }, + { AL_FORMAT_UHJ2CHN_MULAW_SOFT, UserFmtUHJ2, UserFmtMulaw }, + { AL_FORMAT_UHJ2CHN_IMA4_SOFT, UserFmtUHJ2, UserFmtIMA4 }, + { AL_FORMAT_UHJ2CHN_MSADPCM_SOFT, UserFmtUHJ2, UserFmtMSADPCM }, { AL_FORMAT_UHJ3CHN8_SOFT, UserFmtUHJ3, UserFmtUByte }, { AL_FORMAT_UHJ3CHN16_SOFT, UserFmtUHJ3, UserFmtShort }, { AL_FORMAT_UHJ3CHN_FLOAT32_SOFT, UserFmtUHJ3, UserFmtFloat }, + { AL_FORMAT_UHJ3CHN_MULAW_SOFT, UserFmtUHJ3, UserFmtMulaw }, { AL_FORMAT_UHJ4CHN8_SOFT, UserFmtUHJ4, UserFmtUByte }, { AL_FORMAT_UHJ4CHN16_SOFT, UserFmtUHJ4, UserFmtShort }, { AL_FORMAT_UHJ4CHN_FLOAT32_SOFT, UserFmtUHJ4, UserFmtFloat }, + { AL_FORMAT_UHJ4CHN_MULAW_SOFT, UserFmtUHJ4, UserFmtMulaw }, }}; for(const auto &fmt : UserFmtList) diff --git a/alc/inprogext.h b/alc/inprogext.h index 5dfc22cb..284af05e 100644 --- a/alc/inprogext.h +++ b/alc/inprogext.h @@ -64,11 +64,21 @@ void AL_APIENTRY alSourcePlayAtTimevSOFT(ALsizei n, const ALuint *sources, ALint #endif #endif +#ifndef AL_SOFT_UHJ_ex +#define AL_SOFT_UHJ_ex +#define AL_FORMAT_UHJ2CHN_MULAW_SOFT 0x19B3 +#define AL_FORMAT_UHJ2CHN_IMA4_SOFT 0x19B4 +#define AL_FORMAT_UHJ2CHN_MSADPCM_SOFT 0x19B5 +#define AL_FORMAT_UHJ3CHN_MULAW_SOFT 0x19B6 +#define AL_FORMAT_UHJ4CHN_MULAW_SOFT 0x19B7 +#endif + + /* Non-standard export. Not part of any extension. */ AL_API const ALchar* AL_APIENTRY alsoft_get_version(void); -/* Functions from abandoned extenions. Only here for binary compatibility. */ +/* Functions from abandoned extensions. Only here for binary compatibility. */ AL_API void AL_APIENTRY alSourceQueueBufferLayersSOFT(ALuint src, ALsizei nb, const ALuint *buffers); -- 2.11.4.GIT