aboutsummaryrefslogtreecommitdiffstats
path: root/src/util.h
diff options
context:
space:
mode:
authorDaniil Cherednik <dan.cherednik@gmail.com>2020-07-08 00:08:50 +0300
committerDaniil Cherednik <dan.cherednik@gmail.com>2020-07-08 00:08:50 +0300
commit40d971c988fd9ccfb82cc6aaacc57ca1ad477d52 (patch)
tree66c4a8d87450e0318be6621d9315b90ec5229978 /src/util.h
parent240ca54145159a7aefc74ca8b23ed273e0ce2cbf (diff)
downloadatracdenc-40d971c988fd9ccfb82cc6aaacc57ca1ad477d52.tar.gz
[atrac3] Simple adaptive MS bitrate shift
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h
index 01162e4..7405c68 100644
--- a/src/util.h
+++ b/src/util.h
@@ -21,6 +21,7 @@
#include <vector>
#include <algorithm>
#include <cmath>
+#include <numeric>
#include "config.h"
#include <cstring>
@@ -72,3 +73,12 @@ inline T CalcMedian(T* in, uint32_t len) {
uint32_t pos = (len - 1) / 2;
return tmp[pos];
}
+
+template<class T>
+inline T CalcEnergy(const std::vector<T>& in) {
+ return std::accumulate(in.begin(), in.end(), 0.0,
+ [](const T& a, const T& b) {
+ return a + b * b;
+ });
+}
+