devformat.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #ifndef CORE_DEVFORMAT_H
  2. #define CORE_DEVFORMAT_H
  3. #include <cstdint>
  4. #include <cstddef>
  5. #include <string_view>
  6. using uint = unsigned int;
  7. enum Channel : unsigned char {
  8. FrontLeft = 0,
  9. FrontRight,
  10. FrontCenter,
  11. LFE,
  12. BackLeft,
  13. BackRight,
  14. BackCenter,
  15. SideLeft,
  16. SideRight,
  17. TopCenter,
  18. TopFrontLeft,
  19. TopFrontCenter,
  20. TopFrontRight,
  21. TopBackLeft,
  22. TopBackCenter,
  23. TopBackRight,
  24. BottomFrontLeft,
  25. BottomFrontRight,
  26. BottomBackLeft,
  27. BottomBackRight,
  28. Aux0,
  29. Aux1,
  30. Aux2,
  31. Aux3,
  32. Aux4,
  33. Aux5,
  34. Aux6,
  35. Aux7,
  36. Aux8,
  37. Aux9,
  38. Aux10,
  39. Aux11,
  40. Aux12,
  41. Aux13,
  42. Aux14,
  43. Aux15,
  44. MaxChannels
  45. };
  46. /* Device formats */
  47. enum DevFmtType : unsigned char {
  48. DevFmtByte,
  49. DevFmtUByte,
  50. DevFmtShort,
  51. DevFmtUShort,
  52. DevFmtInt,
  53. DevFmtUInt,
  54. DevFmtFloat,
  55. DevFmtTypeDefault = DevFmtFloat
  56. };
  57. enum DevFmtChannels : unsigned char {
  58. DevFmtMono,
  59. DevFmtStereo,
  60. DevFmtQuad,
  61. DevFmtX51,
  62. DevFmtX61,
  63. DevFmtX71,
  64. DevFmtX714,
  65. DevFmtX7144,
  66. DevFmtX3D71,
  67. DevFmtAmbi3D,
  68. DevFmtChannelsDefault = DevFmtStereo
  69. };
  70. inline constexpr std::size_t MaxOutputChannels{16};
  71. /* DevFmtType traits, providing the type, etc given a DevFmtType. */
  72. template<DevFmtType T>
  73. struct DevFmtTypeTraits { };
  74. template<>
  75. struct DevFmtTypeTraits<DevFmtByte> { using Type = int8_t; };
  76. template<>
  77. struct DevFmtTypeTraits<DevFmtUByte> { using Type = uint8_t; };
  78. template<>
  79. struct DevFmtTypeTraits<DevFmtShort> { using Type = int16_t; };
  80. template<>
  81. struct DevFmtTypeTraits<DevFmtUShort> { using Type = uint16_t; };
  82. template<>
  83. struct DevFmtTypeTraits<DevFmtInt> { using Type = int32_t; };
  84. template<>
  85. struct DevFmtTypeTraits<DevFmtUInt> { using Type = uint32_t; };
  86. template<>
  87. struct DevFmtTypeTraits<DevFmtFloat> { using Type = float; };
  88. template<DevFmtType T>
  89. using DevFmtType_t = typename DevFmtTypeTraits<T>::Type;
  90. uint BytesFromDevFmt(DevFmtType type) noexcept;
  91. uint ChannelsFromDevFmt(DevFmtChannels chans, uint ambiorder) noexcept;
  92. inline uint FrameSizeFromDevFmt(DevFmtChannels chans, DevFmtType type, uint ambiorder) noexcept
  93. { return ChannelsFromDevFmt(chans, ambiorder) * BytesFromDevFmt(type); }
  94. auto DevFmtTypeString(DevFmtType type) noexcept -> std::string_view;
  95. auto DevFmtChannelsString(DevFmtChannels chans) noexcept -> std::string_view;
  96. enum class DevAmbiLayout : bool {
  97. FuMa,
  98. ACN,
  99. Default = ACN
  100. };
  101. enum class DevAmbiScaling : unsigned char {
  102. FuMa,
  103. SN3D,
  104. N3D,
  105. Default = SN3D
  106. };
  107. #endif /* CORE_DEVFORMAT_H */