Fix use of final flag more than once at end of processing (causing a test failure with libsamplerate)

This commit is contained in:
Chris Cannam
2023-04-05 11:14:04 +01:00
parent 376bf4dbd6
commit b9f2b58e1f
2 changed files with 12 additions and 3 deletions

View File

@@ -695,7 +695,7 @@ D_SRC::resampleInterleaved(float *const BQ_R__ out,
// expected output, and (b) when the ratio has just changed, we
// should aim to supply a shortish block next
if (outcount > int(ceil(incount * ratio) + 5)) {
if (!final && (outcount > int(ceil(incount * ratio) + 5))) {
outcount = int(ceil(incount * ratio) + 5);
}
@@ -754,6 +754,10 @@ D_SRC::resampleInterleaved(float *const BQ_R__ out,
#endif
}
// cerr << "Resampler::process: final = " << final << ", incount = "
// << incount << ", outcount = " << outcount << ", ratio = "
// << ratio << ", gen = " << data.output_frames_gen << endl;
return (int)data.output_frames_gen;
}

View File

@@ -771,7 +771,7 @@ R3Stretcher::process(const float *const *input, size_t samples, bool final)
if (resampleInput == 0) resampleInput = 1;
prepareInput(input, inputIx, resampleInput);
int resampleOutput = m_resampler->resample
(m_channelAssembly.resampled.data(),
maxResampleOutput,
@@ -1008,13 +1008,18 @@ R3Stretcher::consume()
m_channelAssembly.mixdown[c] = cd->mixdown.data();
m_channelAssembly.resampled[c] = cd->resampled.data();
}
bool final = (m_mode == ProcessMode::Finished &&
readSpace < inhop &&
cd0->scales.at(longest)->accumulatorFill <= outhop);
resampledCount = m_resampler->resample
(m_channelAssembly.resampled.data(),
m_channelData[0]->resampled.size(),
m_channelAssembly.mixdown.data(),
outhop,
1.0 / m_pitchScale,
m_mode == ProcessMode::Finished && readSpace < inhop);
final);
}
// Emit