aboutsummaryrefslogtreecommitdiffstats
path: root/core/ambidefs.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2021-04-24 13:46:52 -0700
committerChris Robinson <[email protected]>2021-04-24 13:46:52 -0700
commit440ce71dcedb39e827660d0925b6cc2046c6d0f0 (patch)
treed8d5f11c71bf8d2852e176a9ec55e0cd1dc140b3 /core/ambidefs.cpp
parentf10cc1e1acb11bbabd5a16b62e0d435d6b1e9337 (diff)
Move GetHFOrderScales to a more appropriate place
Diffstat (limited to 'core/ambidefs.cpp')
-rw-r--r--core/ambidefs.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/core/ambidefs.cpp b/core/ambidefs.cpp
new file mode 100644
index 00000000..2725748e
--- /dev/null
+++ b/core/ambidefs.cpp
@@ -0,0 +1,44 @@
+
+#include "config.h"
+
+#include "ambidefs.h"
+
+#include <cassert>
+
+
+namespace {
+
+constexpr std::array<float,MaxAmbiOrder+1> Ambi3DDecoderHFScale{{
+ 1.00000000e+00f, 1.00000000e+00f
+}};
+constexpr std::array<float,MaxAmbiOrder+1> Ambi3DDecoderHFScale2O{{
+ 7.45355990e-01f, 1.00000000e+00f, 1.00000000e+00f
+}};
+constexpr std::array<float,MaxAmbiOrder+1> Ambi3DDecoderHFScale3O{{
+ 5.89792205e-01f, 8.79693856e-01f, 1.00000000e+00f, 1.00000000e+00f
+}};
+
+inline auto& GetDecoderHFScales(uint order) noexcept
+{
+ if(order >= 3) return Ambi3DDecoderHFScale3O;
+ if(order == 2) return Ambi3DDecoderHFScale2O;
+ return Ambi3DDecoderHFScale;
+}
+
+} // namespace
+
+auto AmbiScale::GetHFOrderScales(const uint in_order, const uint out_order) noexcept
+ -> std::array<float,MaxAmbiOrder+1>
+{
+ std::array<float,MaxAmbiOrder+1> ret{};
+
+ assert(out_order >= in_order);
+
+ const auto &target = GetDecoderHFScales(out_order);
+ const auto &input = GetDecoderHFScales(in_order);
+
+ for(size_t i{0};i < in_order+1;++i)
+ ret[i] = input[i] / target[i];
+
+ return ret;
+}