diff options
author | Daniil Cherednik <dan.cherednik@gmail.com> | 2020-07-08 00:08:50 +0300 |
---|---|---|
committer | Daniil Cherednik <dan.cherednik@gmail.com> | 2020-07-08 00:08:50 +0300 |
commit | 40d971c988fd9ccfb82cc6aaacc57ca1ad477d52 (patch) | |
tree | 66c4a8d87450e0318be6621d9315b90ec5229978 /src/util.h | |
parent | 240ca54145159a7aefc74ca8b23ed273e0ce2cbf (diff) | |
download | atracdenc-40d971c988fd9ccfb82cc6aaacc57ca1ad477d52.tar.gz |
[atrac3] Simple adaptive MS bitrate shift
Diffstat (limited to 'src/util.h')
-rw-r--r-- | src/util.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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; + }); +} + |