Fix handling of oversized process buffers in mid-side mode

This commit is contained in:
Chris Cannam
2023-06-07 17:01:47 +01:00
parent 74395b9976
commit 73f7f7bb0a
2 changed files with 9 additions and 1 deletions

View File

@@ -669,6 +669,9 @@ R3Stretcher::ensureInbuf(int required, bool warn)
for (int c = 0; c < m_parameters.channels; ++c) {
auto newBuf = m_channelData[c]->inbuf->resized(newSize);
m_channelData[c]->inbuf = std::unique_ptr<RingBuffer<float>>(newBuf);
// mixdown is used for mid-side mixing as well as the single
// hop output mix, so it needs to be enough to match the inbuf
m_channelData[c]->mixdown.resize(newSize, 0.f);
}
}
@@ -913,6 +916,11 @@ R3Stretcher::prepareInput(const float *const *input, int ix, int n)
if (useMidSide()) {
auto &c0 = m_channelData.at(0)->mixdown;
auto &c1 = m_channelData.at(1)->mixdown;
int bufsize = c0.size();
if (n > bufsize) {
m_log.log(0, "R3Stretcher::prepareInput: WARNING: called with size greater than mixdown buffer length", n, bufsize);
n = bufsize;
}
for (int i = 0; i < n; ++i) {
float l = input[0][i + ix];
float r = input[1][i + ix];

View File

@@ -245,7 +245,7 @@ protected:
BinClassifier::Classification::Residual),
segmenter(new BinSegmenter(segmenterParameters)),
segmentation(), prevSegmentation(), nextSegmentation(),
mixdown(hopBufferSize, 0.f),
mixdown(inRingBufferSize, 0.f),
resampled(hopBufferSize, 0.f),
inbuf(new RingBuffer<float>(inRingBufferSize)),
outbuf(new RingBuffer<float>(outRingBufferSize)),