Mercurial > hg > svcore
comparison transform/FeatureExtractionPluginTransform.cpp @ 73:e9b8b51f6326
* fix compile warnings and genuine int/size_t overflow
author | Chris Cannam |
---|---|
date | Thu, 06 Apr 2006 17:24:13 +0000 |
parents | 9bbc57e8bf43 |
children | 47fd14e29813 |
comparison
equal
deleted
inserted
replaced
72:9bbc57e8bf43 | 73:e9b8b51f6326 |
---|---|
127 case Vamp::Plugin::OutputDescriptor::OneSamplePerStep: | 127 case Vamp::Plugin::OutputDescriptor::OneSamplePerStep: |
128 modelResolution = m_stepSize; | 128 modelResolution = m_stepSize; |
129 break; | 129 break; |
130 | 130 |
131 case Vamp::Plugin::OutputDescriptor::FixedSampleRate: | 131 case Vamp::Plugin::OutputDescriptor::FixedSampleRate: |
132 modelRate = m_descriptor->sampleRate; | 132 modelRate = size_t(m_descriptor->sampleRate + 0.001); |
133 break; | 133 break; |
134 } | 134 } |
135 | 135 |
136 if (binCount == 0) { | 136 if (binCount == 0) { |
137 | 137 |
240 long prevCompletion = 0; | 240 long prevCompletion = 0; |
241 | 241 |
242 while (1) { | 242 while (1) { |
243 | 243 |
244 if (fftPlan) { | 244 if (fftPlan) { |
245 if (blockFrame - m_blockSize/2 > endFrame) break; | 245 if (blockFrame - int(m_blockSize)/2 > endFrame) break; |
246 } else { | 246 } else { |
247 if (blockFrame >= endFrame) break; | 247 if (blockFrame >= endFrame) break; |
248 } | 248 } |
249 | 249 |
250 // std::cerr << "FeatureExtractionPluginTransform::run: blockFrame " | 250 // std::cerr << "FeatureExtractionPluginTransform::run: blockFrame " |
254 (((blockFrame - startFrame) / m_stepSize) * 99) / | 254 (((blockFrame - startFrame) / m_stepSize) * 99) / |
255 ( (endFrame - startFrame) / m_stepSize); | 255 ( (endFrame - startFrame) / m_stepSize); |
256 | 256 |
257 // channelCount is either m_input->channelCount or 1 | 257 // channelCount is either m_input->channelCount or 1 |
258 | 258 |
259 for (int ch = 0; ch < channelCount; ++ch) { | 259 for (size_t ch = 0; ch < channelCount; ++ch) { |
260 if (fftPlan) { | 260 if (fftPlan) { |
261 getFrames(ch, channelCount, | 261 getFrames(ch, channelCount, |
262 blockFrame - m_blockSize/2, m_blockSize, buffers[ch]); | 262 blockFrame - m_blockSize/2, m_blockSize, buffers[ch]); |
263 } else { | 263 } else { |
264 getFrames(ch, channelCount, | 264 getFrames(ch, channelCount, |
265 blockFrame, m_blockSize, buffers[ch]); | 265 blockFrame, m_blockSize, buffers[ch]); |
266 } | 266 } |
267 } | 267 } |
268 | 268 |
269 if (fftPlan) { | 269 if (fftPlan) { |
270 for (int ch = 0; ch < channelCount; ++ch) { | 270 for (size_t ch = 0; ch < channelCount; ++ch) { |
271 for (int i = 0; i < m_blockSize; ++i) { | 271 for (size_t i = 0; i < m_blockSize; ++i) { |
272 fftInput[i] = buffers[ch][i]; | 272 fftInput[i] = buffers[ch][i]; |
273 } | 273 } |
274 windower.cut(fftInput); | 274 windower.cut(fftInput); |
275 for (int i = 0; i < m_blockSize/2; ++i) { | 275 for (size_t i = 0; i < m_blockSize/2; ++i) { |
276 double temp = fftInput[i]; | 276 double temp = fftInput[i]; |
277 fftInput[i] = fftInput[i + m_blockSize/2]; | 277 fftInput[i] = fftInput[i + m_blockSize/2]; |
278 fftInput[i + m_blockSize/2] = temp; | 278 fftInput[i + m_blockSize/2] = temp; |
279 } | 279 } |
280 fftw_execute(fftPlan); | 280 fftw_execute(fftPlan); |
281 for (int i = 0; i < m_blockSize/2; ++i) { | 281 for (size_t i = 0; i < m_blockSize/2; ++i) { |
282 buffers[ch][i*2] = fftOutput[i][0]; | 282 buffers[ch][i*2] = fftOutput[i][0]; |
283 buffers[ch][i*2 + 1] = fftOutput[i][1]; | 283 buffers[ch][i*2 + 1] = fftOutput[i][1]; |
284 } | 284 } |
285 } | 285 } |
286 } | 286 } |
334 size -= offset; | 334 size -= offset; |
335 if (size <= 0) return; | 335 if (size <= 0) return; |
336 startFrame = 0; | 336 startFrame = 0; |
337 } | 337 } |
338 | 338 |
339 size_t got = getInput()->getValues | 339 long got = getInput()->getValues |
340 ((channelCount == 1 ? m_channel : channel), | 340 ((channelCount == 1 ? m_channel : channel), |
341 startFrame, startFrame + size, buffer + offset); | 341 startFrame, startFrame + size, buffer + offset); |
342 | 342 |
343 while (got < size) { | 343 while (got < size) { |
344 buffer[offset + got] = 0.0; | 344 buffer[offset + got] = 0.0; |