From 103726ff6179a5ac1987176d95db6b8b81d83d22 Mon Sep 17 00:00:00 2001 From: Tobias Schneider Date: Sat, 3 Oct 2015 23:10:11 +0200 Subject: [PATCH] fix(spectrogram, inputsource): Use off_t where necessary --- inputsource.cpp | 5 ++++- inputsource.h | 2 +- spectrogram.cpp | 4 ++-- spectrogram.h | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/inputsource.cpp b/inputsource.cpp index d92b332..24500e3 100644 --- a/inputsource.cpp +++ b/inputsource.cpp @@ -29,8 +29,11 @@ InputSource::~InputSource() { fclose(m_file); } -bool InputSource::getSamples(fftwf_complex *dest, int start, int length) +bool InputSource::getSamples(fftwf_complex *dest, off_t start, int length) { + if(start < 0 || length < 0) + return false; + if (start + length >= sampleCount) return false; diff --git a/inputsource.h b/inputsource.h index 1118d10..34eb49e 100644 --- a/inputsource.h +++ b/inputsource.h @@ -16,6 +16,6 @@ public: InputSource(const char *filename); ~InputSource(); - bool getSamples(fftwf_complex *dest, int start, int length); + bool getSamples(fftwf_complex *dest, off_t start, int length); off_t getSampleCount() { return sampleCount; }; }; diff --git a/spectrogram.cpp b/spectrogram.cpp index f069ce8..bd97294 100644 --- a/spectrogram.cpp +++ b/spectrogram.cpp @@ -64,7 +64,7 @@ void Spectrogram::paintEvent(QPaintEvent *event) if (inputSource != nullptr) { int height = rect.height(); - int y = rect.y(); + off_t y = rect.y(); QImage image(fftSize, height, QImage::Format_RGB32); @@ -221,7 +221,7 @@ int Spectrogram::getStride() return fftSize / pow(2, zoomLevel); } -off_t Spectrogram::lineToSample(int line) { +off_t Spectrogram::lineToSample(off_t line) { return line * getStride(); } diff --git a/spectrogram.h b/spectrogram.h index f49d835..6a2a17e 100644 --- a/spectrogram.h +++ b/spectrogram.h @@ -55,7 +55,7 @@ private: float* getFFTTile(off_t tile); void getLine(float *dest, off_t sample); void paintTimeAxis(QPainter *painter, QRect rect); - off_t lineToSample(int line); + off_t lineToSample(off_t line); int sampleToLine(off_t sample); QString sampleToTime(off_t sample); int linesPerTile();