aboutsummaryrefslogtreecommitdiffstats
path: root/src/atrac
diff options
context:
space:
mode:
authorDaniil Cherednik <dan.cherednik@gmail.com>2024-12-20 22:31:20 +0100
committerDaniil Cherednik <dan.cherednik@gmail.com>2024-12-21 16:30:07 +0100
commit74d6e04c21bddd435bd74c34dbe027b883772a76 (patch)
tree4221df9da5a17897296e5f7f841f01b1f6428c74 /src/atrac
parent78649b2f5941e0649db960cafb2997b5ca432be1 (diff)
downloadatracdenc-74d6e04c21bddd435bd74c34dbe027b883772a76.tar.gz
[refactoring] Get rid of TFloat parameter. Use float.
Diffstat (limited to 'src/atrac')
-rw-r--r--src/atrac/atrac1.cpp4
-rw-r--r--src/atrac/atrac1.h4
-rw-r--r--src/atrac/atrac1_bitalloc.cpp20
-rw-r--r--src/atrac/atrac1_bitalloc.h4
-rw-r--r--src/atrac/atrac1_dequantiser.cpp8
-rw-r--r--src/atrac/atrac1_dequantiser.h2
-rw-r--r--src/atrac/atrac1_qmf.h20
-rw-r--r--src/atrac/atrac3.cpp12
-rw-r--r--src/atrac/atrac3.h12
-rw-r--r--src/atrac/atrac3_bitstream.cpp34
-rw-r--r--src/atrac/atrac3_bitstream.h6
-rw-r--r--src/atrac/atrac3_qmf.h6
-rw-r--r--src/atrac/atrac_psy_common.cpp8
-rw-r--r--src/atrac/atrac_psy_common.h2
-rw-r--r--src/atrac/atrac_scale.cpp24
-rw-r--r--src/atrac/atrac_scale.h10
16 files changed, 89 insertions, 87 deletions
diff --git a/src/atrac/atrac1.cpp b/src/atrac/atrac1.cpp
index d463a1c..0c1c053 100644
--- a/src/atrac/atrac1.cpp
+++ b/src/atrac/atrac1.cpp
@@ -26,8 +26,8 @@ constexpr uint32_t TAtrac1Data::SpecsPerBlock[MaxBfus];
constexpr uint32_t TAtrac1Data::SpecsStartLong[MaxBfus];
constexpr uint32_t TAtrac1Data::SpecsStartShort[MaxBfus];
constexpr uint32_t TAtrac1Data::BfuAmountTab[8];
-TFloat TAtrac1Data::ScaleTable[64] = {0};
-TFloat TAtrac1Data::SineWindow[32] = {0};
+float TAtrac1Data::ScaleTable[64] = {0};
+float TAtrac1Data::SineWindow[32] = {0};
const static TAtrac1Data Atrac1Data;
diff --git a/src/atrac/atrac1.h b/src/atrac/atrac1.h
index 54beedc..ae1809b 100644
--- a/src/atrac/atrac1.h
+++ b/src/atrac/atrac1.h
@@ -78,8 +78,8 @@ public:
static const uint32_t BitsPerIDWL = 4;
static const uint32_t BitsPerIDSF = 6;
- static TFloat ScaleTable[64];
- static TFloat SineWindow[32];
+ static float ScaleTable[64];
+ static float SineWindow[32];
static uint32_t BfuToBand(uint32_t i) {
if (i < 20)
return 0;
diff --git a/src/atrac/atrac1_bitalloc.cpp b/src/atrac/atrac1_bitalloc.cpp
index a4b6cd0..5b20cc8 100644
--- a/src/atrac/atrac1_bitalloc.cpp
+++ b/src/atrac/atrac1_bitalloc.cpp
@@ -98,7 +98,7 @@ uint32_t TBitsBooster::ApplyBoost(std::vector<uint32_t>* bitsPerEachBlock, uint3
return surplus;
}
-std::vector<TFloat> TAtrac1SimpleBitAlloc::ATHLong;
+std::vector<float> TAtrac1SimpleBitAlloc::ATHLong;
TAtrac1SimpleBitAlloc::TAtrac1SimpleBitAlloc(ICompressedOutput* container, uint32_t bfuIdxConst, bool fastBfuNumSearch)
: TAtrac1BitStreamWriter(container)
@@ -125,8 +125,8 @@ TAtrac1SimpleBitAlloc::TAtrac1SimpleBitAlloc(ICompressedOutput* container, uint3
vector<uint32_t> TAtrac1SimpleBitAlloc::CalcBitsAllocation(const std::vector<TScaledBlock>& scaledBlocks,
const uint32_t bfuNum,
- const TFloat spread,
- const TFloat shift,
+ const float spread,
+ const float shift,
const TBlockSize& blockSize,
const float loudness) {
vector<uint32_t> bitsPerEachBlock(bfuNum);
@@ -138,7 +138,7 @@ vector<uint32_t> TAtrac1SimpleBitAlloc::CalcBitsAllocation(const std::vector<TSc
if (!shortBlock && scaledBlocks[i].MaxEnergy < ath) {
bitsPerEachBlock[i] = 0;
} else {
- int tmp = spread * ( (TFloat)scaledBlocks[i].ScaleFactorIndex/3.2) + (1.0 - spread) * fix - shift;
+ int tmp = spread * ( (float)scaledBlocks[i].ScaleFactorIndex/3.2) + (1.0 - spread) * fix - shift;
if (tmp > 16) {
bitsPerEachBlock[i] = 16;
} else if (tmp < 2) {
@@ -189,7 +189,7 @@ uint32_t TAtrac1SimpleBitAlloc::CheckBfuUsage(bool* changed,
uint32_t TAtrac1SimpleBitAlloc::Write(const std::vector<TScaledBlock>& scaledBlocks, const TBlockSize& blockSize, float loudness) {
uint32_t bfuIdx = BfuIdxConst ? BfuIdxConst - 1 : 7;
bool autoBfu = !BfuIdxConst;
- TFloat spread = AnalizeScaleFactorSpread(scaledBlocks);
+ float spread = AnalizeScaleFactorSpread(scaledBlocks);
vector<uint32_t> bitsPerEachBlock(TAtrac1Data::BfuAmountTab[bfuIdx]);
uint32_t targetBitsPerBfus;
@@ -200,9 +200,9 @@ uint32_t TAtrac1SimpleBitAlloc::Write(const std::vector<TScaledBlock>& scaledBlo
TAtrac1Data::BitsPerBfuAmountTabIdx - 32 - 2 - 3 -
bitsPerEachBlock.size() * (TAtrac1Data::BitsPerIDWL + TAtrac1Data::BitsPerIDSF);
- TFloat maxShift = 15;
- TFloat minShift = -3;
- TFloat shift = 3.0;
+ float maxShift = 15;
+ float minShift = -3;
+ float shift = 3.0;
const uint32_t maxBits = bitsAvaliablePerBfus;
const uint32_t minBits = bitsAvaliablePerBfus - 110;
@@ -299,8 +299,8 @@ void TAtrac1BitStreamWriter::WriteBitStream(const vector<uint32_t>& bitsPerEachB
if (wordLength == 0 || wordLength == 1)
continue;
- const TFloat multiple = ((1 << (wordLength - 1)) - 1);
- for (const TFloat val : scaledBlocks[i].Values) {
+ const float multiple = ((1 << (wordLength - 1)) - 1);
+ for (const float val : scaledBlocks[i].Values) {
const int tmp = lrint(val * multiple);
const uint32_t testwl = bitsPerEachBlock[i] ? (bitsPerEachBlock[i] - 1) : 0;
const uint32_t a = !!testwl + testwl;
diff --git a/src/atrac/atrac1_bitalloc.h b/src/atrac/atrac1_bitalloc.h
index 4a33cb0..ca01b13 100644
--- a/src/atrac/atrac1_bitalloc.h
+++ b/src/atrac/atrac1_bitalloc.h
@@ -55,11 +55,11 @@ public:
class TAtrac1SimpleBitAlloc : public TAtrac1BitStreamWriter, public TBitsBooster, public virtual IAtrac1BitAlloc {
std::vector<uint32_t> CalcBitsAllocation(const std::vector<TScaledBlock>& scaledBlocks, const uint32_t bfuNum,
- const TFloat spread, const TFloat shift, const TBlockSize& blockSize,
+ const float spread, const float shift, const TBlockSize& blockSize,
const float loudness);
const uint32_t BfuIdxConst;
const bool FastBfuNumSearch;
- static std::vector<TFloat> ATHLong;
+ static std::vector<float> ATHLong;
uint32_t GetMaxUsedBfuId(const std::vector<uint32_t>& bitsPerEachBlock);
uint32_t CheckBfuUsage(bool* changed, uint32_t curBfuId, const std::vector<uint32_t>& bitsPerEachBlock);
diff --git a/src/atrac/atrac1_dequantiser.cpp b/src/atrac/atrac1_dequantiser.cpp
index 0b1c065..bcc087d 100644
--- a/src/atrac/atrac1_dequantiser.cpp
+++ b/src/atrac/atrac1_dequantiser.cpp
@@ -26,7 +26,7 @@ using namespace NBitStream;
TAtrac1Dequantiser::TAtrac1Dequantiser() {
}
-void TAtrac1Dequantiser::Dequant(TBitStream* stream, const TBlockSize& bs, TFloat specs[512]) {
+void TAtrac1Dequantiser::Dequant(TBitStream* stream, const TBlockSize& bs, float specs[512]) {
uint32_t wordLens[TAtrac1Data::MaxBfus];
uint32_t idScaleFactors[TAtrac1Data::MaxBfus];
const uint32_t numBFUs = TAtrac1Data::BfuAmountTab[stream->Read(3)];
@@ -48,17 +48,17 @@ void TAtrac1Dequantiser::Dequant(TBitStream* stream, const TBlockSize& bs, TFloa
for (uint32_t bfuNum = TAtrac1Data::BlocksPerBand[bandNum]; bfuNum < TAtrac1Data::BlocksPerBand[bandNum + 1]; bfuNum++) {
const uint32_t numSpecs = TAtrac1Data::SpecsPerBlock[bfuNum];
const uint32_t wordLen = !!wordLens[bfuNum] + wordLens[bfuNum];
- const TFloat scaleFactor = TAtrac1Data::ScaleTable[idScaleFactors[bfuNum]];
+ const float scaleFactor = TAtrac1Data::ScaleTable[idScaleFactors[bfuNum]];
const uint32_t startPos = bs.LogCount[bandNum] ?
TAtrac1Data::SpecsStartShort[bfuNum] : TAtrac1Data::SpecsStartLong[bfuNum];
if (wordLen) {
- TFloat maxQuant = 1.0 / (TFloat)((1 << (wordLen - 1)) - 1);
+ float maxQuant = 1.0 / (float)((1 << (wordLen - 1)) - 1);
//cout << "BFU ("<< bfuNum << ") :" << "wordLen " << wordLen << " maxQuant " << maxQuant << " scaleFactor " << scaleFactor << " id " << idScaleFactors[bfuNum] << " num Specs " << numSpecs << " short: "<< (int)bs.LogCount[bandNum] << endl;
for (uint32_t i = 0; i < numSpecs; i++ ) {
specs[startPos + i] = scaleFactor * maxQuant * MakeSign(stream->Read(wordLen), wordLen);
}
} else {
- memset(&specs[startPos], 0, numSpecs * sizeof(TFloat));
+ memset(&specs[startPos], 0, numSpecs * sizeof(float));
}
}
diff --git a/src/atrac/atrac1_dequantiser.h b/src/atrac/atrac1_dequantiser.h
index 95fd250..0b57c08 100644
--- a/src/atrac/atrac1_dequantiser.h
+++ b/src/atrac/atrac1_dequantiser.h
@@ -27,7 +27,7 @@ namespace NAtrac1 {
class TAtrac1Dequantiser {
public:
TAtrac1Dequantiser();
- void Dequant(NBitStream::TBitStream* stream, const TBlockSize& bs, TFloat specs[512]);
+ void Dequant(NBitStream::TBitStream* stream, const TBlockSize& bs, float specs[512]);
};
} //namespace NAtrac1
diff --git a/src/atrac/atrac1_qmf.h b/src/atrac/atrac1_qmf.h
index d8fdae3..0276160 100644
--- a/src/atrac/atrac1_qmf.h
+++ b/src/atrac/atrac1_qmf.h
@@ -28,18 +28,18 @@ class Atrac1AnalysisFilterBank {
const static int delayComp = 39;
TQmf<TIn, nInSamples> Qmf1;
TQmf<TIn, nInSamples / 2> Qmf2;
- std::vector<TFloat> MidLowTmp;
- std::vector<TFloat> DelayBuf;
+ std::vector<float> MidLowTmp;
+ std::vector<float> DelayBuf;
public:
Atrac1AnalysisFilterBank() {
MidLowTmp.resize(512);
DelayBuf.resize(delayComp + 512);
}
- void Analysis(TIn* pcm, TFloat* low, TFloat* mid, TFloat* hi) {
- memcpy(&DelayBuf[0], &DelayBuf[256], sizeof(TFloat) * delayComp);
+ void Analysis(TIn* pcm, float* low, float* mid, float* hi) {
+ memcpy(&DelayBuf[0], &DelayBuf[256], sizeof(float) * delayComp);
Qmf1.Analysis(pcm, &MidLowTmp[0], &DelayBuf[delayComp]);
Qmf2.Analysis(&MidLowTmp[0], low, mid);
- memcpy(hi, &DelayBuf[0], sizeof(TFloat) * 256);
+ memcpy(hi, &DelayBuf[0], sizeof(float) * 256);
}
};
@@ -49,16 +49,16 @@ class Atrac1SynthesisFilterBank {
const static int delayComp = 39;
TQmf<TOut, nInSamples> Qmf1;
TQmf<TOut, nInSamples / 2> Qmf2;
- std::vector<TFloat> MidLowTmp;
- std::vector<TFloat> DelayBuf;
+ std::vector<float> MidLowTmp;
+ std::vector<float> DelayBuf;
public:
Atrac1SynthesisFilterBank() {
MidLowTmp.resize(512);
DelayBuf.resize(delayComp + 512);
}
- void Synthesis(TOut* pcm, TFloat* low, TFloat* mid, TFloat* hi) {
- memcpy(&DelayBuf[0], &DelayBuf[256], sizeof(TFloat) * delayComp);
- memcpy(&DelayBuf[delayComp], hi, sizeof(TFloat) * 256);
+ void Synthesis(TOut* pcm, float* low, float* mid, float* hi) {
+ memcpy(&DelayBuf[0], &DelayBuf[256], sizeof(float) * delayComp);
+ memcpy(&DelayBuf[delayComp], hi, sizeof(float) * 256);
Qmf2.Synthesis(&MidLowTmp[0], &low[0], &mid[0]);
Qmf1.Synthesis(&pcm[0], &MidLowTmp[0], &DelayBuf[0]);
}
diff --git a/src/atrac/atrac3.cpp b/src/atrac/atrac3.cpp
index 363a32e..1e5b8e9 100644
--- a/src/atrac/atrac3.cpp
+++ b/src/atrac/atrac3.cpp
@@ -24,7 +24,7 @@ namespace NAtrac3 {
constexpr uint32_t TAtrac3Data::BlockSizeTab[33];
constexpr uint32_t TAtrac3Data::ClcLengthTab[8];
-constexpr double TAtrac3Data::MaxQuant[8];
+constexpr float TAtrac3Data::MaxQuant[8];
constexpr uint32_t TAtrac3Data::BlocksPerBand[4 + 1];
constexpr uint32_t TAtrac3Data::SpecsPerBlock[33];
constexpr TAtrac3Data::THuffEntry TAtrac3Data::HuffTable1[HuffTable1Sz];
@@ -36,11 +36,11 @@ constexpr TAtrac3Data::THuffEntry TAtrac3Data::HuffTable7[HuffTable7Sz];
constexpr TAtrac3Data::THuffTablePair TAtrac3Data::HuffTables[7];
constexpr TContainerParams TAtrac3Data::ContainerParams[8];
-double TAtrac3Data::EncodeWindow[256] = {0};
-double TAtrac3Data::DecodeWindow[256] = {0};
-double TAtrac3Data::ScaleTable[64] = {0};
-double TAtrac3Data::GainLevel[16];
-double TAtrac3Data::GainInterpolation[31];
+float TAtrac3Data::EncodeWindow[256] = {0};
+float TAtrac3Data::DecodeWindow[256] = {0};
+float TAtrac3Data::ScaleTable[64] = {0};
+float TAtrac3Data::GainLevel[16];
+float TAtrac3Data::GainInterpolation[31];
static const TAtrac3Data Atrac3Data;
diff --git a/src/atrac/atrac3.h b/src/atrac/atrac3.h
index 6ce0283..103f6fc 100644
--- a/src/atrac/atrac3.h
+++ b/src/atrac/atrac3.h
@@ -56,11 +56,11 @@ public:
static constexpr uint32_t NumSamples = 1024;
static const uint32_t MDCTSz = 512;
- static double ScaleTable[64];
- static double EncodeWindow[256];
- static double DecodeWindow[256];
- static double GainLevel[16];
- static double GainInterpolation[31];
+ static float ScaleTable[64];
+ static float EncodeWindow[256];
+ static float DecodeWindow[256];
+ static float GainLevel[16];
+ static float GainInterpolation[31];
static constexpr int32_t ExponentOffset = 4;
static constexpr int32_t LocScale = 3;
static constexpr int32_t LocSz = 1 << LocScale;
@@ -68,7 +68,7 @@ public:
static constexpr uint32_t NumSpecs = NumSamples;
static const uint32_t frameSz = 152;
- static constexpr double MaxQuant[8] = {
+ static constexpr float MaxQuant[8] = {
0.0, 1.5, 2.5, 3.5,
4.5, 7.5, 15.5, 31.5
};
diff --git a/src/atrac/atrac3_bitstream.cpp b/src/atrac/atrac3_bitstream.cpp
index e3194b1..9bada6f 100644
--- a/src/atrac/atrac3_bitstream.cpp
+++ b/src/atrac/atrac3_bitstream.cpp
@@ -40,7 +40,7 @@ static const uint32_t FixedBitAllocTable[TAtrac3Data::MaxBfus] = {
1, 0
};
-std::vector<TFloat> TAtrac3BitStreamWriter::ATH;
+std::vector<float> TAtrac3BitStreamWriter::ATH;
TAtrac3BitStreamWriter::TAtrac3BitStreamWriter(ICompressedOutput* container, const TContainerParams& params, uint32_t bfuIdxConst)
: Container(container)
, Params(params)
@@ -120,7 +120,7 @@ uint32_t TAtrac3BitStreamWriter::VLCEnc(const uint32_t selector, const int manti
return bitsUsed;
}
-static inline int ToInt(double x) {
+static inline int ToInt(float x) {
#if defined(_MSC_VER) && !defined(_WIN64)
int n;
__asm {
@@ -133,7 +133,7 @@ static inline int ToInt(double x) {
#endif
}
-static inline void CalcMantisas(const TFloat* values, const uint32_t first, const uint32_t last, const TFloat mul, int* mantisas) {
+static inline void CalcMantisas(const float* values, const uint32_t first, const uint32_t last, const float mul, int* mantisas) {
for (uint32_t j = 0, f = first; f < last; f++, j++) {
mantisas[f] = ToInt(values[j] * mul);
}
@@ -156,9 +156,9 @@ std::pair<uint8_t, uint32_t> TAtrac3BitStreamWriter::CalcSpecsBitsConsumption(co
const uint32_t first = TAtrac3Data::BlockSizeTab[i];
const uint32_t last = TAtrac3Data::BlockSizeTab[i+1];
const uint32_t blockSize = last - first;
- const TFloat mul = TAtrac3Data::MaxQuant[std::min(precisionPerEachBlocks[i], (uint32_t)7)];
+ const float mul = TAtrac3Data::MaxQuant[std::min(precisionPerEachBlocks[i], (uint32_t)7)];
if (calcMant) {
- const TFloat* values = scaledBlocks[i].Values.data();
+ const float* values = scaledBlocks[i].Values.data();
CalcMantisas(values, first, last, mul, mantisas);
}
bits += clcMode ? CLCEnc(precisionPerEachBlocks[i], mantisas + first, blockSize, nullptr) :
@@ -197,7 +197,7 @@ std::pair<uint8_t, vector<uint32_t>> TAtrac3BitStreamWriter::CreateAllocation(co
return DUMMY_ALLOC;
}
- TFloat spread = AnalizeScaleFactorSpread(scaledBlocks);
+ float spread = AnalizeScaleFactorSpread(scaledBlocks);
uint16_t numBfu = BfuIdxConst ? BfuIdxConst : 32;
@@ -215,10 +215,10 @@ std::pair<uint8_t, vector<uint32_t>> TAtrac3BitStreamWriter::CreateAllocation(co
bool cont = true;
while (cont) {
precisionPerEachBlocks.resize(numBfu);
- TFloat maxShift = 20;
- TFloat minShift = -8;
+ double maxShift = 20;
+ double minShift = -8;
for (;;) {
- TFloat shift = (maxShift + minShift) / 2;
+ double shift = (maxShift + minShift) / 2;
const vector<uint32_t>& tmpAlloc = CalcBitsAllocation(scaledBlocks, numBfu, spread, shift, laudness);
auto consumption = CalcSpecsBitsConsumption(sce, tmpAlloc, mt);
@@ -451,7 +451,7 @@ uint16_t TAtrac3BitStreamWriter::EncodeTonalComponents(const TSingleChannelEleme
ASSERT(curGroup.SubGroupPtr[k]->ScaledBlock.Values.size() < 8);
int mantisas[256];
- const TFloat mul = TAtrac3Data::MaxQuant[std::min((uint32_t)(i>>3), (uint32_t)7)];
+ const float mul = TAtrac3Data::MaxQuant[std::min((uint32_t)(i>>3), (uint32_t)7)];
ASSERT(codedValues == curGroup.SubGroupPtr[k]->ScaledBlock.Values.size());
for (uint32_t z = 0; z < curGroup.SubGroupPtr[k]->ScaledBlock.Values.size(); ++z) {
mantisas[z] = lrint(curGroup.SubGroupPtr[k]->ScaledBlock.Values[z] * mul);
@@ -477,9 +477,9 @@ uint16_t TAtrac3BitStreamWriter::EncodeTonalComponents(const TSingleChannelEleme
vector<uint32_t> TAtrac3BitStreamWriter::CalcBitsAllocation(const std::vector<TScaledBlock>& scaledBlocks,
const uint32_t bfuNum,
- const TFloat spread,
- const TFloat shift,
- const TFloat loudness)
+ const float spread,
+ const float shift,
+ const float loudness)
{
vector<uint32_t> bitsPerEachBlock(bfuNum);
for (size_t i = 0; i < bitsPerEachBlock.size(); ++i) {
@@ -489,7 +489,7 @@ vector<uint32_t> TAtrac3BitStreamWriter::CalcBitsAllocation(const std::vector<TS
bitsPerEachBlock[i] = 0;
} else {
const uint32_t fix = FixedBitAllocTable[i];
- int tmp = spread * ( (TFloat)scaledBlocks[i].ScaleFactorIndex/3.2) + (1.0 - spread) * fix - shift;
+ int tmp = spread * ( (float)scaledBlocks[i].ScaleFactorIndex/3.2) + (1.0 - spread) * fix - shift;
if (tmp > 7) {
bitsPerEachBlock[i] = 7;
} else if (tmp < 0) {
@@ -514,8 +514,8 @@ void WriteJsParams(NBitStream::TBitStream* bs)
// 0.5 - M only (mono)
// 0.0 - Uncorrelated
// -0.5 - S only
-static TFloat CalcMSRatio(TFloat mEnergy, TFloat sEnergy) {
- TFloat total = sEnergy + mEnergy;
+static float CalcMSRatio(float mEnergy, float sEnergy) {
+ float total = sEnergy + mEnergy;
if (total > 0)
return mEnergy / total - 0.5;
@@ -535,7 +535,7 @@ static int32_t CalcMSBytesShift(uint32_t frameSz,
if (elements[1].ScaledBlocks.empty()) {
return maxAllowedShift;
} else {
- TFloat ratio = CalcMSRatio(elements[0].Loudness, elements[1].Loudness);
+ float ratio = CalcMSRatio(elements[0].Loudness, elements[1].Loudness);
//std::cerr << ratio << std::endl;
return std::max(std::min(ToInt(frameSz * ratio), maxAllowedShift), -maxAllowedShift);
}
diff --git a/src/atrac/atrac3_bitstream.h b/src/atrac/atrac3_bitstream.h
index 75a39ea..93ee72e 100644
--- a/src/atrac/atrac3_bitstream.h
+++ b/src/atrac/atrac3_bitstream.h
@@ -45,10 +45,10 @@ public:
TAtrac3Data::SubbandInfo SubbandInfo;
std::vector<TTonalBlock> TonalBlocks;
std::vector<TScaledBlock> ScaledBlocks;
- TFloat Loudness;
+ float Loudness;
};
private:
- static std::vector<TFloat> ATH;
+ static std::vector<float> ATH;
struct TTonalComponentsSubGroup {
std::vector<uint8_t> SubGroupMap;
@@ -66,7 +66,7 @@ private:
const uint32_t blockSize, NBitStream::TBitStream* bitStream);
std::vector<uint32_t> CalcBitsAllocation(const std::vector<TScaledBlock>& scaledBlocks,
- uint32_t bfuNum, TFloat spread, TFloat shift, TFloat loudness);
+ uint32_t bfuNum, float spread, float shift, float loudness);
std::pair<uint8_t, std::vector<uint32_t>> CreateAllocation(const TSingleChannelElement& sce,
uint16_t targetBits, int mt[TAtrac3Data::MaxSpecs], float laudness);
diff --git a/src/atrac/atrac3_qmf.h b/src/atrac/atrac3_qmf.h
index 2fc33fa..1ed137e 100644
--- a/src/atrac/atrac3_qmf.h
+++ b/src/atrac/atrac3_qmf.h
@@ -28,14 +28,14 @@ class Atrac3AnalysisFilterBank {
TQmf<TIn, nInSamples> Qmf1;
TQmf<TIn, nInSamples / 2> Qmf2;
TQmf<TIn, nInSamples / 2> Qmf3;
- std::vector<TFloat> Buf1;
- std::vector<TFloat> Buf2;
+ std::vector<float> Buf1;
+ std::vector<float> Buf2;
public:
Atrac3AnalysisFilterBank() {
Buf1.resize(nInSamples);
Buf2.resize(nInSamples);
}
- void Analysis(TIn* pcm, TFloat* subs[4]) {
+ void Analysis(TIn* pcm, float* subs[4]) {
Qmf1.Analysis(pcm, Buf1.data(), Buf2.data());
Qmf2.Analysis(Buf1.data(), subs[0], subs[1]);
Qmf3.Analysis(Buf2.data(), subs[3], subs[2]);
diff --git a/src/atrac/atrac_psy_common.cpp b/src/atrac/atrac_psy_common.cpp
index a034a78..186915e 100644
--- a/src/atrac/atrac_psy_common.cpp
+++ b/src/atrac/atrac_psy_common.cpp
@@ -99,15 +99,15 @@ namespace NAtracDEnc {
using std::vector;
//returns 1 for tone-like, 0 - noise-like
-TFloat AnalizeScaleFactorSpread(const vector<TScaledBlock>& scaledBlocks)
+float AnalizeScaleFactorSpread(const vector<TScaledBlock>& scaledBlocks)
{
- TFloat s = 0.0;
+ float s = 0.0;
for (size_t i = 0; i < scaledBlocks.size(); ++i) {
s += scaledBlocks[i].ScaleFactorIndex;
}
s /= scaledBlocks.size();
- TFloat sigma = 0.0;
- TFloat t = 0.0;
+ float sigma = 0.0;
+ float t = 0.0;
for (size_t i = 0; i < scaledBlocks.size(); ++i) {
t = (scaledBlocks[i].ScaleFactorIndex - s);
t *= t;
diff --git a/src/atrac/atrac_psy_common.h b/src/atrac/atrac_psy_common.h
index 854dfd1..c433b90 100644
--- a/src/atrac/atrac_psy_common.h
+++ b/src/atrac/atrac_psy_common.h
@@ -21,7 +21,7 @@
namespace NAtracDEnc {
-TFloat AnalizeScaleFactorSpread(const std::vector<TScaledBlock>& scaledBlocks);
+float AnalizeScaleFactorSpread(const std::vector<TScaledBlock>& scaledBlocks);
std::vector<float> CalcATH(int len, int sampleRate);
inline float TrackLoudness(float prevLoud, float l0, float l1)
diff --git a/src/atrac/atrac_scale.cpp b/src/atrac/atrac_scale.cpp
index fffabbe..d6f5960 100644
--- a/src/atrac/atrac_scale.cpp
+++ b/src/atrac/atrac_scale.cpp
@@ -33,7 +33,7 @@ using std::endl;
using std::abs;
-static const TFloat MAX_SCALE = 1.0;
+static const float MAX_SCALE = 1.0;
template<class TBaseData>
TScaler<TBaseData>::TScaler() {
@@ -43,10 +43,10 @@ TScaler<TBaseData>::TScaler() {
}
template<class TBaseData>
-TScaledBlock TScaler<TBaseData>::Scale(const TFloat* in, uint16_t len) {
- TFloat maxAbsSpec = 0;
+TScaledBlock TScaler<TBaseData>::Scale(const float* in, uint16_t len) {
+ float maxAbsSpec = 0;
for (uint16_t i = 0; i < len; ++i) {
- const TFloat absSpec = abs(in[i]);
+ const float absSpec = abs(in[i]);
if (absSpec > maxAbsSpec) {
maxAbsSpec = absSpec;
}
@@ -55,17 +55,19 @@ TScaledBlock TScaler<TBaseData>::Scale(const TFloat* in, uint16_t len) {
cerr << "Scale error: absSpec > MAX_SCALE, val: " << maxAbsSpec << endl;
maxAbsSpec = MAX_SCALE;
}
- const map<TFloat, uint8_t>::const_iterator scaleIter = ScaleIndex.lower_bound(maxAbsSpec);
- const TFloat scaleFactor = scaleIter->first;
+ const map<float, uint8_t>::const_iterator scaleIter = ScaleIndex.lower_bound(maxAbsSpec);
+ const float scaleFactor = scaleIter->first;
const uint8_t scaleFactorIndex = scaleIter->second;
TScaledBlock res(scaleFactorIndex);
- TFloat maxEnergy = 0.0;
+ float maxEnergy = 0.0;
for (uint16_t i = 0; i < len; ++i) {
- TFloat scaledValue = in[i] / scaleFactor;
- TFloat energy = in[i] * in[i];
+ float scaledValue = in[i] / scaleFactor;
+ float energy = in[i] * in[i];
maxEnergy = std::max(maxEnergy, energy);
if (abs(scaledValue) >= 1.0) {
- cerr << "got "<< scaledValue << " it is wrong scalling" << endl;
+ if (abs(scaledValue) > 1.0) {
+ cerr << "clipping, scaled value: "<< scaledValue << endl;
+ }
scaledValue = (scaledValue > 0) ? 0.99999 : -0.99999;
}
res.Values.push_back(scaledValue);
@@ -75,7 +77,7 @@ TScaledBlock TScaler<TBaseData>::Scale(const TFloat* in, uint16_t len) {
}
template<class TBaseData>
-vector<TScaledBlock> TScaler<TBaseData>::ScaleFrame(const vector<TFloat>& specs, const TBlockSize& blockSize) {
+vector<TScaledBlock> TScaler<TBaseData>::ScaleFrame(const vector<float>& specs, const TBlockSize& blockSize) {
vector<TScaledBlock> scaledBlocks;
scaledBlocks.reserve(TBaseData::MaxBfus);
for (uint8_t bandNum = 0; bandNum < TBaseData::NumQMF; ++bandNum) {
diff --git a/src/atrac/atrac_scale.h b/src/atrac/atrac_scale.h
index 6cea7a9..059360d 100644
--- a/src/atrac/atrac_scale.h
+++ b/src/atrac/atrac_scale.h
@@ -30,19 +30,19 @@ namespace NAtracDEnc {
struct TScaledBlock {
TScaledBlock(uint8_t sfi) : ScaleFactorIndex(sfi) {}
/* const */ uint8_t ScaleFactorIndex = 0;
- std::vector<TFloat> Values;
- TFloat MaxEnergy;
+ std::vector<float> Values;
+ float MaxEnergy;
};
class TBlockSize;
template <class TBaseData>
class TScaler {
- std::map<TFloat, uint8_t> ScaleIndex;
+ std::map<float, uint8_t> ScaleIndex;
public:
TScaler();
- TScaledBlock Scale(const TFloat* in, uint16_t len);
- std::vector<TScaledBlock> ScaleFrame(const std::vector<TFloat>& specs, const TBlockSize& blockSize);
+ TScaledBlock Scale(const float* in, uint16_t len);
+ std::vector<TScaledBlock> ScaleFrame(const std::vector<float>& specs, const TBlockSize& blockSize);
};
class TBlockSize {