1 #ifndef CORE_BUFFER_STORAGE_H
2 #define CORE_BUFFER_STORAGE_H
11 using uint
= unsigned int;
13 /* Storable formats */
14 enum FmtType
: unsigned char {
22 enum FmtChannels
: unsigned char {
27 FmtX51
, /* (WFX order) */
28 FmtX61
, /* (WFX order) */
29 FmtX71
, /* (WFX order) */
32 FmtUHJ2
, /* 2-channel UHJ, aka "BHJ", stereo-compatible */
33 FmtUHJ3
, /* 3-channel UHJ, aka "THJ" */
34 FmtUHJ4
, /* 4-channel UHJ, aka "PHJ" */
35 FmtSuperStereo
, /* Stereo processed with Super Stereo. */
38 enum class AmbiLayout
: unsigned char {
42 enum class AmbiScaling
: unsigned char {
49 uint
BytesFromFmt(FmtType type
) noexcept
;
50 uint
ChannelsFromFmt(FmtChannels chans
, uint ambiorder
) noexcept
;
51 inline uint
FrameSizeFromFmt(FmtChannels chans
, FmtType type
, uint ambiorder
) noexcept
52 { return ChannelsFromFmt(chans
, ambiorder
) * BytesFromFmt(type
); }
54 constexpr bool IsBFormat(FmtChannels chans
) noexcept
55 { return chans
== FmtBFormat2D
|| chans
== FmtBFormat3D
; }
57 /* Super Stereo is considered part of the UHJ family here, since it goes
58 * through similar processing as UHJ, both result in a B-Format signal, and
59 * needs the same consideration as BHJ (three channel result with only two
62 constexpr bool IsUHJ(FmtChannels chans
) noexcept
63 { return chans
== FmtUHJ2
|| chans
== FmtUHJ3
|| chans
== FmtUHJ4
|| chans
== FmtSuperStereo
; }
65 /** Ambisonic formats are either B-Format or UHJ formats. */
66 constexpr bool IsAmbisonic(FmtChannels chans
) noexcept
67 { return IsBFormat(chans
) || IsUHJ(chans
); }
69 constexpr bool Is2DAmbisonic(FmtChannels chans
) noexcept
71 return chans
== FmtBFormat2D
|| chans
== FmtUHJ2
|| chans
== FmtUHJ3
72 || chans
== FmtSuperStereo
;
76 using CallbackType
= int(*)(void*, void*, int);
78 struct BufferStorage
{
79 CallbackType mCallback
{nullptr};
80 void *mUserData
{nullptr};
83 FmtChannels mChannels
{FmtMono
};
84 FmtType mType
{FmtShort
};
87 AmbiLayout mAmbiLayout
{AmbiLayout::FuMa
};
88 AmbiScaling mAmbiScaling
{AmbiScaling::FuMa
};
91 inline uint
bytesFromFmt() const noexcept
{ return BytesFromFmt(mType
); }
92 inline uint
channelsFromFmt() const noexcept
93 { return ChannelsFromFmt(mChannels
, mAmbiOrder
); }
94 inline uint
frameSizeFromFmt() const noexcept
{ return channelsFromFmt() * bytesFromFmt(); }
96 inline bool isBFormat() const noexcept
{ return IsBFormat(mChannels
); }
99 #endif /* CORE_BUFFER_STORAGE_H */