aboutsummaryrefslogtreecommitdiffstats
path: root/src/atrac/atrac_scale.h
diff options
context:
space:
mode:
authorDaniil Cherednik <dan.cherednik@gmail.com>2016-06-19 02:58:23 +0300
committerDaniil Cherednik <dan.cherednik@gmail.com>2016-06-19 03:31:55 +0300
commit1151d5831f19a9f24dd0c545a4968606712a62d2 (patch)
treec978c1b9a3fc86fef531dd412fe6b7668b7c0567 /src/atrac/atrac_scale.h
parent8d65a0bd0774e03b3d10354e15f2f3361a2ce26a (diff)
downloadatracdenc-1151d5831f19a9f24dd0c545a4968606712a62d2.tar.gz
some improvements of ATRAC3 implementation:atrac3
- simple (ATRAC1 like) psychoacoustic added - possibility to encode tonal components - simple tonal component extractor - refactoring
Diffstat (limited to 'src/atrac/atrac_scale.h')
-rw-r--r--src/atrac/atrac_scale.h46
1 files changed, 41 insertions, 5 deletions
diff --git a/src/atrac/atrac_scale.h b/src/atrac/atrac_scale.h
index dd437a2..499fac2 100644
--- a/src/atrac/atrac_scale.h
+++ b/src/atrac/atrac_scale.h
@@ -4,24 +4,60 @@
#include <cstdint>
#include "atrac1.h"
+#include "../config.h"
+
namespace NAtracDEnc {
struct TScaledBlock {
TScaledBlock(uint8_t sfi) : ScaleFactorIndex(sfi) {}
- const uint8_t ScaleFactorIndex = 0;
- std::vector<double> Values;
+ /* const */ uint8_t ScaleFactorIndex = 0;
+ std::vector<TFloat> Values;
};
+class TBlockSize;
+
template <class TBaseData>
class TScaler : public TBaseData {
- std::map<double, uint8_t>ScaleIndex;
+ std::map<TFloat, uint8_t>ScaleIndex;
public:
TScaler() {
for (int i = 0; i < 64; i++) {
ScaleIndex[TBaseData::ScaleTable[i]] = i;
}
}
- std::vector<TScaledBlock> Scale(const std::vector<double>& specs, const TBlockSize& blockSize);
+ TScaledBlock Scale(const TFloat* in, uint16_t len);
+ std::vector<TScaledBlock> ScaleFrame(const std::vector<TFloat>& specs, const TBlockSize& blockSize);
+};
+
+class TBlockSize {
+ static std::array<int, 4> Parse(NBitStream::TBitStream* stream) {
+ //ATRAC1 - 3 subbands, ATRAC3 - 4 subbands.
+ //TODO: rewrite
+ std::array<int, 4> tmp;
+ tmp[0] = 2 - stream->Read(2);
+ tmp[1] = 2 - stream->Read(2);
+ tmp[2] = 3 - stream->Read(2);
+ stream->Read(2); //skip unused 2 bits
+ return tmp;
+ }
+ static std::array<int, 4> Create(bool lowShort, bool midShort, bool hiShort) {
+ std::array<int, 4> tmp;
+ tmp[0] = lowShort ? 2 : 0;
+ tmp[1] = midShort ? 2 : 0;
+ tmp[2] = hiShort ? 3 : 0;
+ return tmp;
+ }
+public:
+ TBlockSize(NBitStream::TBitStream* stream)
+ : LogCount(Parse(stream))
+ {}
+ TBlockSize(bool lowShort, bool midShort, bool hiShort)
+ : LogCount(Create(lowShort, midShort, hiShort))
+ {}
+ TBlockSize()
+ : LogCount({{0, 0, 0, 0}})
+ {}
+ const std::array<int, 4> LogCount;
};
-}
+} //namespace NAtracDEnc