Fix some compiler warnings

This commit is contained in:
Chris Cannam
2022-06-14 15:15:55 +01:00
parent 141c314c72
commit b160475b07
5 changed files with 21 additions and 16 deletions

View File

@@ -6,6 +6,7 @@ project(
license: 'GPL-2.0-or-later', license: 'GPL-2.0-or-later',
default_options: [ default_options: [
'cpp_std=c++11', 'cpp_std=c++11',
'warning_level=3',
'buildtype=release', 'buildtype=release',
'default_library=both', 'default_library=both',
'b_ndebug=if-release', 'b_ndebug=if-release',

View File

@@ -51,10 +51,14 @@ public:
int getFilterLength() const { int getFilterLength() const {
return m_buffer.getSize(); return m_buffer.getSize();
} }
int getNValues() const {
return int(m_histogram.size());
}
void reset() { void reset() {
m_buffer.reset(); m_buffer.reset();
for (int i = 0; i < m_histogram.size(); ++i) { for (int i = 0; i < getNValues(); ++i) {
m_histogram[i] = 0; m_histogram[i] = 0;
} }
} }
@@ -89,7 +93,8 @@ public:
int getMedian() const { int getMedian() const {
int half = (m_buffer.getReadSpace() + 1) / 2; int half = (m_buffer.getReadSpace() + 1) / 2;
int acc = 0; int acc = 0;
for (int i = 0; i < m_histogram.size(); ++i) { int nvalues = getNValues();
for (int i = 0; i < nvalues; ++i) {
acc += m_histogram[i]; acc += m_histogram[i];
if (acc >= half) { if (acc >= half) {
return i; return i;
@@ -108,7 +113,8 @@ public:
} }
int max = 0; int max = 0;
int mode = 0; int mode = 0;
for (int i = 0; i < m_histogram.size(); ++i) { int nvalues = getNValues();
for (int i = 0; i < nvalues; ++i) {
int h = m_histogram[i]; int h = m_histogram[i];
if (i == 0 || h > max) { if (i == 0 || h > max) {
max = h; max = h;

View File

@@ -53,7 +53,7 @@ public:
m_binCount(parameters.fftSize / 2 + 1), m_binCount(parameters.fftSize / 2 + 1),
m_peakPicker(m_binCount), m_peakPicker(m_binCount),
m_reported(false) { m_reported(false) {
size_t ch = m_parameters.channels; int ch = m_parameters.channels;
m_currentPeaks = allocate_and_zero_channels<int>(ch, m_binCount); m_currentPeaks = allocate_and_zero_channels<int>(ch, m_binCount);
m_prevPeaks = allocate_and_zero_channels<int>(ch, m_binCount); m_prevPeaks = allocate_and_zero_channels<int>(ch, m_binCount);
m_greatestChannel = allocate_and_zero<int>(m_binCount); m_greatestChannel = allocate_and_zero<int>(m_binCount);
@@ -69,7 +69,7 @@ public:
} }
~GuidedPhaseAdvance() { ~GuidedPhaseAdvance() {
size_t ch = m_parameters.channels; int ch = m_parameters.channels;
deallocate_channels(m_currentPeaks, ch); deallocate_channels(m_currentPeaks, ch);
deallocate_channels(m_prevPeaks, ch); deallocate_channels(m_prevPeaks, ch);
deallocate(m_greatestChannel); deallocate(m_greatestChannel);
@@ -79,7 +79,7 @@ public:
} }
void reset() { void reset() {
size_t ch = m_parameters.channels; int ch = m_parameters.channels;
v_zero_channels(m_prevPeaks, ch, m_binCount); v_zero_channels(m_prevPeaks, ch, m_binCount);
v_zero_channels(m_prevInPhase, ch, m_binCount); v_zero_channels(m_prevInPhase, ch, m_binCount);
v_zero_channels(m_prevOutPhase, ch, m_binCount); v_zero_channels(m_prevOutPhase, ch, m_binCount);

View File

@@ -279,7 +279,7 @@ void
R3StretcherImpl::updateRatioFromMap() R3StretcherImpl::updateRatioFromMap()
{ {
if (m_keyFrameMap.empty()) return; if (m_keyFrameMap.empty()) return;
auto itr = m_keyFrameMap.upper_bound(m_processInputDuration); //!!! auto itr = m_keyFrameMap.upper_bound(m_processInputDuration);
} }
@@ -370,7 +370,7 @@ R3StretcherImpl::getSamplesRequired() const
{ {
if (available() != 0) return 0; if (available() != 0) return 0;
int longest = m_guideConfiguration.longestFftSize; int longest = m_guideConfiguration.longestFftSize;
size_t rs = m_channelData[0]->inbuf->getReadSpace(); int rs = m_channelData[0]->inbuf->getReadSpace();
if (rs < longest) { if (rs < longest) {
return longest - rs; return longest - rs;
} else { } else {
@@ -406,8 +406,6 @@ R3StretcherImpl::process(const float *const *input, size_t samples, bool final)
m_mode = ProcessMode::Processing; m_mode = ProcessMode::Processing;
} }
bool allConsumed = false;
size_t ws = m_channelData[0]->inbuf->getWriteSpace(); size_t ws = m_channelData[0]->inbuf->getWriteSpace();
if (samples > ws) { if (samples > ws) {
//!!! check this //!!! check this
@@ -444,15 +442,15 @@ R3StretcherImpl::available() const
size_t size_t
R3StretcherImpl::retrieve(float *const *output, size_t samples) const R3StretcherImpl::retrieve(float *const *output, size_t samples) const
{ {
size_t got = samples; int got = samples;
for (size_t c = 0; c < m_parameters.channels; ++c) { for (int c = 0; c < m_parameters.channels; ++c) {
size_t gotHere = m_channelData[c]->outbuf->read(output[c], got); int gotHere = m_channelData[c]->outbuf->read(output[c], got);
if (gotHere < got) { if (gotHere < got) {
if (c > 0) { if (c > 0) {
m_parameters.logger("R3StretcherImpl::retrieve: WARNING: channel imbalance detected"); m_parameters.logger("R3StretcherImpl::retrieve: WARNING: channel imbalance detected");
} }
got = gotHere; got = std::min(got, std::max(gotHere, 0));
} }
} }

View File

@@ -248,8 +248,8 @@ protected:
analysisWindowLength(fftSize)), analysisWindowLength(fftSize)),
synthesisWindow(synthesisWindowShape(fftSize), synthesisWindow(synthesisWindowShape(fftSize),
synthesisWindowLength(fftSize)), synthesisWindowLength(fftSize)),
guided(guidedParameters), windowScaleFactor(0.0),
windowScaleFactor(0.0) guided(guidedParameters)
{ {
int asz = analysisWindow.getSize(), ssz = synthesisWindow.getSize(); int asz = analysisWindow.getSize(), ssz = synthesisWindow.getSize();
int off = (asz - ssz) / 2; int off = (asz - ssz) / 2;