mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 16:10:06 +02:00
Avoid repeated FindBlock call in Sequence::Get when we can
This commit is contained in:
parent
dc599116f7
commit
dd3df60a83
@ -439,7 +439,7 @@ bool Sequence::Copy(sampleCount s0, sampleCount s1, Sequence **dest)
|
|||||||
BlockFile *const file = block0.f;
|
BlockFile *const file = block0.f;
|
||||||
blocklen = std::min(s1, block0.start + file->GetLength()) - s0;
|
blocklen = std::min(s1, block0.start + file->GetLength()) - s0;
|
||||||
wxASSERT(file->IsAlias() || (blocklen <= mMaxSamples)); // Vaughan, 2012-02-29
|
wxASSERT(file->IsAlias() || (blocklen <= mMaxSamples)); // Vaughan, 2012-02-29
|
||||||
Get(buffer.ptr(), mSampleFormat, s0, blocklen);
|
Get(b0, buffer.ptr(), mSampleFormat, s0, blocklen);
|
||||||
|
|
||||||
(*dest)->Append(buffer.ptr(), mSampleFormat, blocklen);
|
(*dest)->Append(buffer.ptr(), mSampleFormat, blocklen);
|
||||||
}
|
}
|
||||||
@ -457,7 +457,7 @@ bool Sequence::Copy(sampleCount s0, sampleCount s1, Sequence **dest)
|
|||||||
blocklen = (s1 - block.start);
|
blocklen = (s1 - block.start);
|
||||||
wxASSERT(file->IsAlias() || (blocklen <= mMaxSamples)); // Vaughan, 2012-02-29
|
wxASSERT(file->IsAlias() || (blocklen <= mMaxSamples)); // Vaughan, 2012-02-29
|
||||||
if (blocklen < file->GetLength()) {
|
if (blocklen < file->GetLength()) {
|
||||||
Get(buffer.ptr(), mSampleFormat, block.start, blocklen);
|
Get(b1, buffer.ptr(), mSampleFormat, block.start, blocklen);
|
||||||
(*dest)->Append(buffer.ptr(), mSampleFormat, blocklen);
|
(*dest)->Append(buffer.ptr(), mSampleFormat, blocklen);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -548,7 +548,7 @@ bool Sequence::Paste(sampleCount s, const Sequence *src)
|
|||||||
|
|
||||||
int splitPoint = s - block.start;
|
int splitPoint = s - block.start;
|
||||||
Read(buffer.ptr(), mSampleFormat, block, 0, splitPoint);
|
Read(buffer.ptr(), mSampleFormat, block, 0, splitPoint);
|
||||||
src->Get(buffer.ptr() + splitPoint*sampleSize,
|
src->Get(0, buffer.ptr() + splitPoint*sampleSize,
|
||||||
mSampleFormat, 0, addedLen);
|
mSampleFormat, 0, addedLen);
|
||||||
Read(buffer.ptr() + (splitPoint + addedLen)*sampleSize,
|
Read(buffer.ptr() + (splitPoint + addedLen)*sampleSize,
|
||||||
mSampleFormat, block,
|
mSampleFormat, block,
|
||||||
@ -587,7 +587,7 @@ bool Sequence::Paste(sampleCount s, const Sequence *src)
|
|||||||
|
|
||||||
SampleBuffer sumBuffer(sum, mSampleFormat);
|
SampleBuffer sumBuffer(sum, mSampleFormat);
|
||||||
Read(sumBuffer.ptr(), mSampleFormat, splitBlock, 0, splitPoint);
|
Read(sumBuffer.ptr(), mSampleFormat, splitBlock, 0, splitPoint);
|
||||||
src->Get(sumBuffer.ptr() + splitPoint * sampleSize,
|
src->Get(0, sumBuffer.ptr() + splitPoint * sampleSize,
|
||||||
mSampleFormat,
|
mSampleFormat,
|
||||||
0, addedLen);
|
0, addedLen);
|
||||||
Read(sumBuffer.ptr() + (splitPoint + addedLen) * sampleSize, mSampleFormat,
|
Read(sumBuffer.ptr() + (splitPoint + addedLen) * sampleSize, mSampleFormat,
|
||||||
@ -617,7 +617,7 @@ bool Sequence::Paste(sampleCount s, const Sequence *src)
|
|||||||
SampleBuffer sampleBuffer(std::max(leftLen, rightLen), mSampleFormat);
|
SampleBuffer sampleBuffer(std::max(leftLen, rightLen), mSampleFormat);
|
||||||
|
|
||||||
Read(sampleBuffer.ptr(), mSampleFormat, splitBlock, 0, splitPoint);
|
Read(sampleBuffer.ptr(), mSampleFormat, splitBlock, 0, splitPoint);
|
||||||
src->Get(sampleBuffer.ptr() + splitPoint*sampleSize,
|
src->Get(0, sampleBuffer.ptr() + splitPoint*sampleSize,
|
||||||
mSampleFormat, 0, srcFirstTwoLen);
|
mSampleFormat, 0, srcFirstTwoLen);
|
||||||
|
|
||||||
Blockify(newBlock, splitBlock.start, sampleBuffer.ptr(), leftLen);
|
Blockify(newBlock, splitBlock.start, sampleBuffer.ptr(), leftLen);
|
||||||
@ -634,7 +634,7 @@ bool Sequence::Paste(sampleCount s, const Sequence *src)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sampleCount lastStart = penultimate.start;
|
sampleCount lastStart = penultimate.start;
|
||||||
src->Get(sampleBuffer.ptr(), mSampleFormat,
|
src->Get(srcNumBlocks - 2, sampleBuffer.ptr(), mSampleFormat,
|
||||||
lastStart, srcLastTwoLen);
|
lastStart, srcLastTwoLen);
|
||||||
Read(sampleBuffer.ptr() + srcLastTwoLen * sampleSize, mSampleFormat,
|
Read(sampleBuffer.ptr() + srcLastTwoLen * sampleSize, mSampleFormat,
|
||||||
splitBlock, splitPoint, rightSplit);
|
splitBlock, splitPoint, rightSplit);
|
||||||
@ -1169,10 +1169,16 @@ bool Sequence::Get(samplePtr buffer, sampleFormat format,
|
|||||||
sampleCount start, sampleCount len) const
|
sampleCount start, sampleCount len) const
|
||||||
{
|
{
|
||||||
if (start < 0 || start >= mNumSamples ||
|
if (start < 0 || start >= mNumSamples ||
|
||||||
start+len > mNumSamples)
|
start + len > mNumSamples)
|
||||||
return false;
|
return false;
|
||||||
int b = FindBlock(start);
|
int b = FindBlock(start);
|
||||||
|
|
||||||
|
return Get(b, buffer, format, start, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Sequence::Get(int b, samplePtr buffer, sampleFormat format,
|
||||||
|
sampleCount start, sampleCount len) const
|
||||||
|
{
|
||||||
while (len) {
|
while (len) {
|
||||||
const SeqBlock &block = mBlock.at(b);
|
const SeqBlock &block = mBlock.at(b);
|
||||||
const sampleCount bstart = (start - (block.start));
|
const sampleCount bstart = (start - (block.start));
|
||||||
|
@ -252,6 +252,9 @@ class Sequence: public XMLTagHandler {
|
|||||||
|
|
||||||
void Blockify(BlockArray &list, sampleCount start, samplePtr buffer, sampleCount len);
|
void Blockify(BlockArray &list, sampleCount start, samplePtr buffer, sampleCount len);
|
||||||
|
|
||||||
|
bool Get(int b, samplePtr buffer, sampleFormat format,
|
||||||
|
sampleCount start, sampleCount len) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user