Mercurial > hg > svcore
comparison data/fileio/CodedAudioFileReader.cpp @ 1379:96a6ea30933e
Fix occasional off-by-one error in resampled audio file reader
author | Chris Cannam |
---|---|
date | Tue, 21 Feb 2017 17:42:40 +0000 |
parents | 49b43306778b |
children | cc62d7862203 |
comparison
equal
deleted
inserted
replaced
1378:b5728e69802b | 1379:96a6ea30933e |
---|---|
523 padding, | 523 padding, |
524 int(padFrames), | 524 int(padFrames), |
525 ratio, | 525 ratio, |
526 true); | 526 true); |
527 | 527 |
528 if (m_frameCount + out > sv_frame_t(double(m_fileFrameCount) * ratio)) { | 528 SVDEBUG << "CodedAudioFileReader::pushBufferResampling: resampled padFrames to " << out << " frames" << endl; |
529 out = sv_frame_t(double(m_fileFrameCount) * ratio) - m_frameCount; | 529 |
530 sv_frame_t expected = sv_frame_t(round(double(m_fileFrameCount) * ratio)); | |
531 if (m_frameCount + out > expected) { | |
532 out = expected - m_frameCount; | |
533 SVDEBUG << "CodedAudioFileReader::pushBufferResampling: clipping that to " << out << " to avoid producing more samples than desired" << endl; | |
530 } | 534 } |
531 | 535 |
532 pushBufferNonResampling(m_resampleBuffer, out); | 536 pushBufferNonResampling(m_resampleBuffer, out); |
533 delete[] padding; | 537 delete[] padding; |
534 } | 538 } |