aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniil Cherednik <dan.cherednik@gmail.com>2016-07-17 19:50:48 +0300
committerDaniil Cherednik <dan.cherednik@gmail.com>2016-07-17 19:50:48 +0300
commitb4df8a7c2dd12eea27c8cc52bd52a1bb8c00943f (patch)
tree5a129afd2113bfe72e9d597f96da6cb18ba66f27
parent5154e84468bba497026d41889ac3648bfcc9f2dd (diff)
downloadatracdenc-b4df8a7c2dd12eea27c8cc52bd52a1bb8c00943f.tar.gz
Compilation warnings fixed
-rw-r--r--src/atrac/atrac1_bitalloc.cpp18
-rw-r--r--src/atracdenc.cpp18
-rw-r--r--src/main.cpp5
-rw-r--r--src/pcmengin.h6
-rw-r--r--src/qmf/qmf.h16
-rw-r--r--src/transient_detector.cpp4
-rw-r--r--src/wav.h4
7 files changed, 33 insertions, 38 deletions
diff --git a/src/atrac/atrac1_bitalloc.cpp b/src/atrac/atrac1_bitalloc.cpp
index 68af205..783ffd1 100644
--- a/src/atrac/atrac1_bitalloc.cpp
+++ b/src/atrac/atrac1_bitalloc.cpp
@@ -32,13 +32,13 @@ static const uint32_t BitBoostMask[MAX_BFUS] = {
//returns 1 for tone-like, 0 - noise-like
static double AnalizeSpread(const std::vector<TScaledBlock>& scaledBlocks) {
double s = 0.0;
- for (int i = 0; i < scaledBlocks.size(); ++i) {
+ for (size_t i = 0; i < scaledBlocks.size(); ++i) {
s += scaledBlocks[i].ScaleFactorIndex;
}
s /= scaledBlocks.size();
double sigma = 0.0;
double xxx = 0.0;
- for (int i = 0; i < scaledBlocks.size(); ++i) {
+ for (size_t i = 0; i < scaledBlocks.size(); ++i) {
xxx = (scaledBlocks[i].ScaleFactorIndex - s);
xxx *= xxx;
sigma += xxx;
@@ -104,7 +104,7 @@ uint32_t TBitsBooster::ApplyBoost(std::vector<uint32_t>* bitsPerEachBlock, uint3
vector<uint32_t> TAtrac1SimpleBitAlloc::CalcBitsAllocation(const std::vector<TScaledBlock>& scaledBlocks, const uint32_t bfuNum, const double spread, const double shift, const TBlockSize& blockSize) {
vector<uint32_t> bitsPerEachBlock(bfuNum);
- for (int i = 0; i < bitsPerEachBlock.size(); ++i) {
+ for (size_t i = 0; i < bitsPerEachBlock.size(); ++i) {
const uint32_t fix = blockSize.LogCount[BfuToBand(i)] ? FixedBitAllocTableShort[i] : FixedBitAllocTableLong[i];
int tmp = spread * ( (double)scaledBlocks[i].ScaleFactorIndex/3.2) + (1.0 - spread) * fix - shift;
if (tmp > 16) {
@@ -172,7 +172,7 @@ uint32_t TAtrac1SimpleBitAlloc::Write(const std::vector<TScaledBlock>& scaledBlo
for (;;) {
const vector<uint32_t>& tmpAlloc = CalcBitsAllocation(scaledBlocks, BfuAmountTab[bfuIdx], spread, shift, blockSize);
uint32_t bitsUsed = 0;
- for (int i = 0; i < tmpAlloc.size(); i++) {
+ for (size_t i = 0; i < tmpAlloc.size(); i++) {
bitsUsed += SpecsPerBlock[i] * tmpAlloc[i];
}
@@ -216,7 +216,7 @@ uint32_t TAtrac1SimpleBitAlloc::Write(const std::vector<TScaledBlock>& scaledBlo
void TAtrac1BitStreamWriter::WriteBitStream(const vector<uint32_t>& bitsPerEachBlock, const std::vector<TScaledBlock>& scaledBlocks, uint32_t bfuAmountIdx, const TBlockSize& blockSize) {
NBitStream::TBitStream bitStream;
- int bitUsed = 0;
+ size_t bitUsed = 0;
if (bfuAmountIdx >= (1 << BitsPerBfuAmountTabIdx)) {
cerr << "Wrong bfuAmountIdx (" << bfuAmountIdx << "), frame skiped" << endl;
return;
@@ -243,11 +243,11 @@ void TAtrac1BitStreamWriter::WriteBitStream(const vector<uint32_t>& bitsPerEachB
bitStream.Write(tmp, 4);
bitUsed+=4;
}
- for (int i = 0; i < bitsPerEachBlock.size(); ++i) {
+ for (size_t i = 0; i < bitsPerEachBlock.size(); ++i) {
bitStream.Write(scaledBlocks[i].ScaleFactorIndex, 6);
bitUsed+=6;
}
- for (int i = 0; i < bitsPerEachBlock.size(); ++i) {
+ for (size_t i = 0; i < bitsPerEachBlock.size(); ++i) {
const auto wordLength = bitsPerEachBlock[i];
if (wordLength == 0 || wordLength == 1)
continue;
@@ -255,8 +255,8 @@ void TAtrac1BitStreamWriter::WriteBitStream(const vector<uint32_t>& bitsPerEachB
const double multiple = ((1 << (wordLength - 1)) - 1);
for (const double val : scaledBlocks[i].Values) {
const int tmp = round(val * multiple);
- const int testwl = bitsPerEachBlock[i] ? (bitsPerEachBlock[i] - 1) : 0;
- const int a = !!testwl + testwl;
+ const uint32_t testwl = bitsPerEachBlock[i] ? (bitsPerEachBlock[i] - 1) : 0;
+ const uint32_t a = !!testwl + testwl;
if (a != wordLength) {
cerr << "wordlen error " << a << " " << wordLength << endl;
abort();
diff --git a/src/atracdenc.cpp b/src/atracdenc.cpp
index 6d66cf3..2de1fda 100644
--- a/src/atracdenc.cpp
+++ b/src/atracdenc.cpp
@@ -73,15 +73,15 @@ void TAtrac1MDCT::Mdct(double Specs[512], double* low, double* mid, double* hi,
vector<double> tmp(512);
uint32_t blockPos = 0;
- for (int k = 0; k < numMdctBlocks; ++k) {
+ for (size_t k = 0; k < numMdctBlocks; ++k) {
memcpy(&tmp[winStart], &srcBuf[bufSz], 32 * sizeof(double));
- for (int i = 0; i < 32; i++) {
+ for (size_t i = 0; i < 32; i++) {
srcBuf[bufSz + i] = TAtrac1Data::SineWindow[i] * srcBuf[blockPos + blockSz - 32 + i];
srcBuf[blockPos + blockSz - 32 + i] = TAtrac1Data::SineWindow[31 - i] * srcBuf[blockPos + blockSz - 32 + i];
}
memcpy(&tmp[winStart+32], &srcBuf[blockPos], blockSz * sizeof(double));
const vector<double>& sp = (numMdctBlocks == 1) ? ((band == 2) ? Mdct512(&tmp[0]) : Mdct256(&tmp[0])) : Mdct64(&tmp[0]);
- for (uint32_t i = 0; i < sp.size(); i++) {
+ for (size_t i = 0; i < sp.size(); i++) {
Specs[blockPos + pos + i] = sp[i] * multiple;
}
if (band) {
@@ -99,7 +99,7 @@ void TAtrac1MDCT::Mdct(double Specs[512], double* low, double* mid, double* hi,
}
void TAtrac1MDCT::IMdct(double Specs[512], const TBlockSize& mode, double* low, double* mid, double* hi) {
uint32_t pos = 0;
- for (uint32_t band = 0; band < QMF_BANDS; band++) {
+ for (size_t band = 0; band < QMF_BANDS; band++) {
const uint32_t numMdctBlocks = 1 << mode.LogCount[band];
const uint32_t bufSz = (band == 2) ? 256 : 128;
const uint32_t blockSz = (numMdctBlocks == 1) ? bufSz : 32;
@@ -120,7 +120,7 @@ void TAtrac1MDCT::IMdct(double Specs[512], const TBlockSize& mode, double* low,
}
vector<double> inv = (numMdctBlocks != 1) ? midct(&Specs[pos], blockSz) : (bufSz == 128) ? Midct256(&Specs[pos]) : Midct512(&Specs[pos]);
- for (int i = 0; i < (inv.size()/2); i++) {
+ for (size_t i = 0; i < (inv.size()/2); i++) {
invBuf[start+i] = inv[i + inv.size()/4];
}
@@ -133,7 +133,7 @@ void TAtrac1MDCT::IMdct(double Specs[512], const TBlockSize& mode, double* low,
if (numMdctBlocks == 1)
memcpy(dstBuf + 32, &invBuf[16], ((band == 2) ? 240 : 112) * sizeof(double));
- for (int j = 0; j < 16; j++) {
+ for (size_t j = 0; j < 16; j++) {
dstBuf[bufSz*2 - 16 + j] = invBuf[bufSz - 16 + j];
}
}
@@ -156,7 +156,7 @@ TPCMEngine<double>::TProcessLambda TAtrac1Processor::GetDecodeLambda() {
IMdct(&specs[0], mode, &PcmBufLow[channel][0], &PcmBufMid[channel][0], &PcmBufHi[channel][0]);
SynthesisFilterBank[channel].Synthesis(&sum[0], &PcmBufLow[channel][0], &PcmBufMid[channel][0], &PcmBufHi[channel][0]);
- for (int i = 0; i < NumSamples; ++i) {
+ for (size_t i = 0; i < NumSamples; ++i) {
if (sum[i] > PcmValueMax)
sum[i] = PcmValueMax;
if (sum[i] < PcmValueMin)
@@ -173,7 +173,7 @@ TPCMEngine<double>::TProcessLambda TAtrac1Processor::GetDecodeLambda() {
TPCMEngine<double>::TProcessLambda TAtrac1Processor::GetEncodeLambda() {
const uint32_t srcChannels = Aea->GetChannelNum();
vector<IAtrac1BitAlloc*> bitAlloc;
- for (int i = 0; i < srcChannels; i++) {
+ for (size_t i = 0; i < srcChannels; i++) {
TAea* atrac1container = dynamic_cast<TAea*>(Aea.get());
if (atrac1container == nullptr)
abort();
@@ -184,7 +184,7 @@ TPCMEngine<double>::TProcessLambda TAtrac1Processor::GetEncodeLambda() {
for (uint32_t channel = 0; channel < srcChannels; channel++) {
double src[NumSamples];
vector<double> specs(512);
- for (int i = 0; i < NumSamples; ++i) {
+ for (size_t i = 0; i < NumSamples; ++i) {
src[i] = data[i * srcChannels + channel];
}
diff --git a/src/main.cpp b/src/main.cpp
index 51794ea..f74b253 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -54,7 +54,6 @@ int main(int argc, char* const* argv) {
{ "bfuidxconst", required_argument, NULL, 1},
{ "bfuidxfast", no_argument, NULL, 2},
{ "notransient", optional_argument, NULL, 3},
- { "mono", no_argument, NULL, 'm'},
{ "nostdout", no_argument, NULL, 4},
{ NULL, 0, NULL, 0}
};
@@ -65,7 +64,6 @@ int main(int argc, char* const* argv) {
uint32_t mode = 0;
uint32_t bfuIdxConst = 0; //0 - auto, no const
bool fastBfuNumSearch = false;
- bool mono = false;
bool nostdout = false;
TAtrac1EncodeSettings::EWindowMode windowMode = TAtrac1EncodeSettings::EWindowMode::EWM_AUTO;
uint32_t winMask = 0; //all is long
@@ -85,9 +83,6 @@ int main(int argc, char* const* argv) {
if (outFile == "-")
nostdout = true;
break;
- case 'm':
- mono = true;
- break;
case 'h':
cout << GetHelp() << endl;
return 0;
diff --git a/src/pcmengin.h b/src/pcmengin.h
index 0dff7aa..a0e0127 100644
--- a/src/pcmengin.h
+++ b/src/pcmengin.h
@@ -106,7 +106,7 @@ public:
}
typedef std::function<void(T* data)> TProcessLambda;
- uint64_t ApplyProcess(int step, TProcessLambda lambda) {
+ uint64_t ApplyProcess(size_t step, TProcessLambda lambda) {
if (step > Buffer.Size()) {
throw TPCMBufferTooSmall();
}
@@ -114,8 +114,8 @@ public:
const uint32_t sizeToRead = Buffer.Size();
Reader->Read(Buffer, sizeToRead);
}
- int32_t lastPos = 0;
- for (int i = 0; i + step <= Buffer.Size(); i+=step) {
+ size_t lastPos = 0;
+ for (size_t i = 0; i + step <= Buffer.Size(); i+=step) {
lambda(Buffer[i]);
lastPos = i + step;
}
diff --git a/src/qmf/qmf.h b/src/qmf/qmf.h
index 11e23ee..19c7d0a 100644
--- a/src/qmf/qmf.h
+++ b/src/qmf/qmf.h
@@ -12,10 +12,10 @@ public:
TQmf() {
const int sz = sizeof(QmfWindow)/sizeof(QmfWindow[0]);
- for (int i = 0 ; i < sz/2; i++) {
+ for (size_t i = 0 ; i < sz/2; i++) {
QmfWindow[i] = QmfWindow[ sz - 1 - i] = TapHalf[i] * 2.0;
}
- for (int i = 0; i < sizeof(PcmBuffer)/sizeof(PcmBuffer[0]); i++) {
+ for (size_t i = 0; i < sizeof(PcmBuffer)/sizeof(PcmBuffer[0]); i++) {
PcmBuffer[i] = 0;
PcmBufferMerge[i] = 0;
}
@@ -23,15 +23,15 @@ public:
void Split(TPCM* in, double* lower, double* upper) {
double temp;
- for (int i = 0; i < 46; i++)
+ for (size_t i = 0; i < 46; i++)
PcmBuffer[i] = PcmBuffer[nIn + i];
- for (int i = 0; i < nIn; i++)
+ for (size_t i = 0; i < nIn; i++)
PcmBuffer[46+i] = in[i];
- for (int j = 0; j<nIn; j+=2) {
+ for (size_t j = 0; j < nIn; j+=2) {
lower[j/2] = upper[j/2] = 0.0;
- for (int i = 0; i < 24; i++) {
+ for (size_t i = 0; i < 24; i++) {
lower[j/2] += QmfWindow[2*i] * PcmBuffer[48-1+j-(2*i)];
upper[j/2] += QmfWindow[(2*i)+1] * PcmBuffer[48-1+j-(2*i)-1];
}
@@ -52,10 +52,10 @@ public:
}
double* winP = &PcmBufferMerge[0];
- for (int j = nIn/2; j != 0; j--) {
+ for (size_t j = nIn/2; j != 0; j--) {
double s1 = 0;
double s2 = 0;
- for (int i = 0; i < 48; i+=2) {
+ for (size_t i = 0; i < 48; i+=2) {
s1 += winP[i] * QmfWindow[i];
s2 += winP[i+1] * QmfWindow[i+1];
}
diff --git a/src/transient_detector.cpp b/src/transient_detector.cpp
index 1c6a2aa..769277e 100644
--- a/src/transient_detector.cpp
+++ b/src/transient_detector.cpp
@@ -21,10 +21,10 @@ void TTransientDetector::HPFilter(const double* in, double* out) {
};
memcpy(HPFBuffer.data() + PrevBufSz, in, BlockSz * sizeof(double));
const double* inBuf = HPFBuffer.data();
- for (int i = 0; i < BlockSz; ++i) {
+ for (size_t i = 0; i < BlockSz; ++i) {
double s = inBuf[i + 10];
double s2 = 0;
- for (int j = 0; j < ((FIRLen - 1) / 2) - 1 ; j += 2) {
+ for (size_t j = 0; j < ((FIRLen - 1) / 2) - 1 ; j += 2) {
s += fircoef[j] * (inBuf[i + j] + inBuf[i + FIRLen - j]);
s2 += fircoef[j + 1] * (inBuf[i + j + 1] + inBuf[i + FIRLen - j - 1]);
}
diff --git a/src/wav.h b/src/wav.h
index 0d34c2e..afad5b5 100644
--- a/src/wav.h
+++ b/src/wav.h
@@ -77,7 +77,7 @@ typedef std::unique_ptr<TWav> TWavPtr;
template<class T>
IPCMReader<T>* TWav::GetPCMReader() const {
return new TWavPcmReader<T>([this](TPCMBuffer<T>& data, const uint32_t size) {
- if (data.Channels() != File.channels())
+ if (data.Channels() != (size_t)File.channels())
throw TWrongReadBuffer();
if (size_t read = File.readf(data[0], size) != size) {
assert(read < size);
@@ -90,7 +90,7 @@ IPCMReader<T>* TWav::GetPCMReader() const {
template<class T>
IPCMWriter<T>* TWav::GetPCMWriter() {
return new TWavPcmWriter<T>([this](const TPCMBuffer<T>& data, const uint32_t size) {
- if (data.Channels() != File.channels())
+ if (data.Channels() != (size_t)File.channels())
throw TWrongReadBuffer();
if (File.writef(data[0], size) != size) {
fprintf(stderr, "can't write block\n");