1 #ifndef CORE_BUFFER_STORAGE_H
2 #define CORE_BUFFER_STORAGE_H
10 #include "storage_formats.h"
13 using uint
= unsigned int;
15 constexpr bool IsBFormat(FmtChannels chans
) noexcept
16 { return chans
== FmtBFormat2D
|| chans
== FmtBFormat3D
; }
18 /* Super Stereo is considered part of the UHJ family here, since it goes
19 * through similar processing as UHJ, both result in a B-Format signal, and
20 * needs the same consideration as BHJ (three channel result with only two
23 constexpr bool IsUHJ(FmtChannels chans
) noexcept
24 { return chans
== FmtUHJ2
|| chans
== FmtUHJ3
|| chans
== FmtUHJ4
|| chans
== FmtSuperStereo
; }
26 /** Ambisonic formats are either B-Format or UHJ formats. */
27 constexpr bool IsAmbisonic(FmtChannels chans
) noexcept
28 { return IsBFormat(chans
) || IsUHJ(chans
); }
30 constexpr bool Is2DAmbisonic(FmtChannels chans
) noexcept
32 return chans
== FmtBFormat2D
|| chans
== FmtUHJ2
|| chans
== FmtUHJ3
33 || chans
== FmtSuperStereo
;
37 using CallbackType
= int(*)(void*, void*, int);
39 struct BufferStorage
{
40 CallbackType mCallback
{nullptr};
41 void *mUserData
{nullptr};
43 al::span
<std::byte
> mData
;
46 FmtChannels mChannels
{FmtMono
};
47 FmtType mType
{FmtShort
};
51 AmbiLayout mAmbiLayout
{AmbiLayout::FuMa
};
52 AmbiScaling mAmbiScaling
{AmbiScaling::FuMa
};
55 [[nodiscard
]] auto bytesFromFmt() const noexcept
-> uint
{ return BytesFromFmt(mType
); }
56 [[nodiscard
]] auto channelsFromFmt() const noexcept
-> uint
57 { return ChannelsFromFmt(mChannels
, mAmbiOrder
); }
58 [[nodiscard
]] auto frameSizeFromFmt() const noexcept
-> uint
59 { return channelsFromFmt() * bytesFromFmt(); }
61 [[nodiscard
]] auto blockSizeFromFmt() const noexcept
-> uint
63 if(mType
== FmtIMA4
) return ((mBlockAlign
-1)/2 + 4) * channelsFromFmt();
64 if(mType
== FmtMSADPCM
) return ((mBlockAlign
-2)/2 + 7) * channelsFromFmt();
65 return frameSizeFromFmt();
68 [[nodiscard
]] auto isBFormat() const noexcept
-> bool { return IsBFormat(mChannels
); }
71 #endif /* CORE_BUFFER_STORAGE_H */