aboutsummaryrefslogtreecommitdiffstats
path: root/src/atrac/atrac_scale.cpp
diff options
context:
space:
mode:
authorDaniil Cherednik <dan.cherednik@gmail.com>2024-12-12 23:26:24 +0100
committerDaniil Cherednik <dan.cherednik@gmail.com>2024-12-12 23:52:19 +0100
commit39986e653def9d1130235c1cd6a38c3251bb6d79 (patch)
tree0d84f0c219a8784d6ab22c74face2be230fd939a /src/atrac/atrac_scale.cpp
parent2ca3d7fb3cfdc0b311bb20426d53782910dee64e (diff)
downloadatracdenc-39986e653def9d1130235c1cd6a38c3251bb6d79.tar.gz
[refactoring] Get rid of inheritance from data.
Diffstat (limited to 'src/atrac/atrac_scale.cpp')
-rw-r--r--src/atrac/atrac_scale.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/atrac/atrac_scale.cpp b/src/atrac/atrac_scale.cpp
index edc44a6..fffabbe 100644
--- a/src/atrac/atrac_scale.cpp
+++ b/src/atrac/atrac_scale.cpp
@@ -36,6 +36,13 @@ using std::abs;
static const TFloat MAX_SCALE = 1.0;
template<class TBaseData>
+TScaler<TBaseData>::TScaler() {
+ for (int i = 0; i < 64; i++) {
+ ScaleIndex[TBaseData::ScaleTable[i]] = i;
+ }
+}
+
+template<class TBaseData>
TScaledBlock TScaler<TBaseData>::Scale(const TFloat* in, uint16_t len) {
TFloat maxAbsSpec = 0;
for (uint16_t i = 0; i < len; ++i) {
@@ -71,14 +78,14 @@ template<class TBaseData>
vector<TScaledBlock> TScaler<TBaseData>::ScaleFrame(const vector<TFloat>& specs, const TBlockSize& blockSize) {
vector<TScaledBlock> scaledBlocks;
scaledBlocks.reserve(TBaseData::MaxBfus);
- for (uint8_t bandNum = 0; bandNum < this->NumQMF; ++bandNum) {
+ for (uint8_t bandNum = 0; bandNum < TBaseData::NumQMF; ++bandNum) {
const bool shortWinMode = !!blockSize.LogCount[bandNum];
- for (uint8_t blockNum = this->BlocksPerBand[bandNum]; blockNum < this->BlocksPerBand[bandNum + 1]; ++blockNum) {
- const uint16_t specNumStart = shortWinMode ? TBaseData::SpecsStartShort[blockNum] :
+ for (uint8_t blockNum = TBaseData::BlocksPerBand[bandNum]; blockNum < TBaseData::BlocksPerBand[bandNum + 1]; ++blockNum) {
+ const uint16_t specNumStart = shortWinMode ? TBaseData::SpecsStartShort[blockNum] :
TBaseData::SpecsStartLong[blockNum];
- scaledBlocks.emplace_back(Scale(&specs[specNumStart], this->SpecsPerBlock[blockNum]));
- }
- }
+ scaledBlocks.emplace_back(Scale(&specs[specNumStart], TBaseData::SpecsPerBlock[blockNum]));
+ }
+ }
return scaledBlocks;
}