mirror of
https://github.com/cookiengineer/audacity
synced 2025-04-30 15:49:41 +02:00
More use of constSamplePtr instead of samplePtr
This commit is contained in:
parent
82e8532ee5
commit
9d6dd45973
@ -237,7 +237,7 @@ void Dither::Reset()
|
||||
// stride number of samples.
|
||||
|
||||
void Dither::Apply(enum DitherType ditherType,
|
||||
const samplePtr source, sampleFormat sourceFormat,
|
||||
constSamplePtr source, sampleFormat sourceFormat,
|
||||
samplePtr dest, sampleFormat destFormat,
|
||||
unsigned int len,
|
||||
unsigned int sourceStride /* = 1 */,
|
||||
@ -269,24 +269,24 @@ void Dither::Apply(enum DitherType ditherType,
|
||||
{
|
||||
if (sourceFormat == floatSample)
|
||||
{
|
||||
float* d = (float*)dest;
|
||||
float* s = (float*)source;
|
||||
auto d = (float*)dest;
|
||||
auto s = (const float*)source;
|
||||
|
||||
for (i = 0; i < len; i++, d += destStride, s += sourceStride)
|
||||
*d = *s;
|
||||
} else
|
||||
if (sourceFormat == int24Sample)
|
||||
{
|
||||
int* d = (int*)dest;
|
||||
int* s = (int*)source;
|
||||
auto d = (int*)dest;
|
||||
auto s = (const int*)source;
|
||||
|
||||
for (i = 0; i < len; i++, d += destStride, s += sourceStride)
|
||||
*d = *s;
|
||||
} else
|
||||
if (sourceFormat == int16Sample)
|
||||
{
|
||||
short* d = (short*)dest;
|
||||
short* s = (short*)source;
|
||||
auto d = (short*)dest;
|
||||
auto s = (const short*)source;
|
||||
|
||||
for (i = 0; i < len; i++, d += destStride, s += sourceStride)
|
||||
*d = *s;
|
||||
@ -299,17 +299,17 @@ void Dither::Apply(enum DitherType ditherType,
|
||||
{
|
||||
// No need to dither, just convert samples to float.
|
||||
// No clipping should be necessary.
|
||||
float* d = (float*)dest;
|
||||
auto d = (float*)dest;
|
||||
|
||||
if (sourceFormat == int16Sample)
|
||||
{
|
||||
short* s = (short*)source;
|
||||
auto s = (const short*)source;
|
||||
for (i = 0; i < len; i++, d += destStride, s += sourceStride)
|
||||
*d = FROM_INT16(s);
|
||||
} else
|
||||
if (sourceFormat == int24Sample)
|
||||
{
|
||||
int* s = (int*)source;
|
||||
auto s = (const int*)source;
|
||||
for (i = 0; i < len; i++, d += destStride, s += sourceStride)
|
||||
*d = FROM_INT24(s);
|
||||
} else {
|
||||
@ -319,8 +319,8 @@ void Dither::Apply(enum DitherType ditherType,
|
||||
if (destFormat == int24Sample && sourceFormat == int16Sample)
|
||||
{
|
||||
// Special case when promoting 16 bit to 24 bit
|
||||
int* d = (int*)dest;
|
||||
short* s = (short*)source;
|
||||
auto d = (int*)dest;
|
||||
auto s = (const short*)source;
|
||||
for (i = 0; i < len; i++, d += destStride, s += sourceStride)
|
||||
*d = ((int)*s) << 8;
|
||||
} else
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
/// and hints to the formats of the samples. Even if the sample formats
|
||||
/// are the same, samples are clipped, if necessary.
|
||||
void Apply(DitherType ditherType,
|
||||
const samplePtr source, sampleFormat sourceFormat,
|
||||
constSamplePtr source, sampleFormat sourceFormat,
|
||||
samplePtr dest, sampleFormat destFormat,
|
||||
unsigned int len,
|
||||
unsigned int sourceStride = 1,
|
||||
|
@ -38,7 +38,7 @@ SampleBlockFactoryPtr SampleBlockFactory::New( AudacityProject &project )
|
||||
|
||||
SampleBlockFactory::~SampleBlockFactory() = default;
|
||||
|
||||
SampleBlockPtr SampleBlockFactory::Create(samplePtr src,
|
||||
SampleBlockPtr SampleBlockFactory::Create(constSamplePtr src,
|
||||
size_t numsamples,
|
||||
sampleFormat srcformat)
|
||||
{
|
||||
|
@ -117,7 +117,7 @@ public:
|
||||
virtual ~SampleBlockFactory();
|
||||
|
||||
// Returns a non-null pointer or else throws an exception
|
||||
SampleBlockPtr Create(samplePtr src,
|
||||
SampleBlockPtr Create(constSamplePtr src,
|
||||
size_t numsamples,
|
||||
sampleFormat srcformat);
|
||||
|
||||
@ -145,7 +145,7 @@ public:
|
||||
protected:
|
||||
// The override should throw more informative exceptions on error than the
|
||||
// default InconsistencyException thrown by Create
|
||||
virtual SampleBlockPtr DoCreate(samplePtr src,
|
||||
virtual SampleBlockPtr DoCreate(constSamplePtr src,
|
||||
size_t numsamples,
|
||||
sampleFormat srcformat) = 0;
|
||||
|
||||
|
@ -99,7 +99,7 @@ void ReverseSamples(samplePtr dst, sampleFormat format,
|
||||
}
|
||||
}
|
||||
|
||||
void CopySamples(samplePtr src, sampleFormat srcFormat,
|
||||
void CopySamples(constSamplePtr src, sampleFormat srcFormat,
|
||||
samplePtr dst, sampleFormat dstFormat,
|
||||
unsigned int len,
|
||||
bool highQuality, /* = true */
|
||||
|
@ -124,7 +124,7 @@ private:
|
||||
// Copying, Converting and Clearing Samples
|
||||
//
|
||||
|
||||
void CopySamples(samplePtr src, sampleFormat srcFormat,
|
||||
void CopySamples(constSamplePtr src, sampleFormat srcFormat,
|
||||
samplePtr dst, sampleFormat dstFormat,
|
||||
unsigned int len, bool highQuality=true,
|
||||
unsigned int srcStride=1,
|
||||
|
@ -1109,7 +1109,7 @@ bool Sequence::Get(int b, samplePtr buffer, sampleFormat format,
|
||||
|
||||
// Pass NULL to set silence
|
||||
/*! @excsafety{Strong} */
|
||||
void Sequence::SetSamples(samplePtr buffer, sampleFormat format,
|
||||
void Sequence::SetSamples(constSamplePtr buffer, sampleFormat format,
|
||||
sampleCount start, sampleCount len)
|
||||
{
|
||||
auto &factory = *mpFactory;
|
||||
@ -1165,7 +1165,7 @@ void Sequence::SetSamples(samplePtr buffer, sampleFormat format,
|
||||
ensureSampleBufferSize(scratch, mSampleFormat, tempSize, fileLength,
|
||||
&temp);
|
||||
|
||||
samplePtr useBuffer = buffer;
|
||||
auto useBuffer = buffer;
|
||||
if (buffer && format != mSampleFormat)
|
||||
{
|
||||
// To do: remove the extra movement.
|
||||
@ -1476,7 +1476,7 @@ size_t Sequence::GetIdealAppendLen() const
|
||||
|
||||
/*! @excsafety{Strong} */
|
||||
SeqBlock::SampleBlockPtr Sequence::AppendNewBlock(
|
||||
samplePtr buffer, sampleFormat format, size_t len)
|
||||
constSamplePtr buffer, sampleFormat format, size_t len)
|
||||
{
|
||||
return DoAppend( buffer, format, len, false );
|
||||
}
|
||||
@ -1506,14 +1506,14 @@ void Sequence::AppendSharedBlock(const SeqBlock::SampleBlockPtr &pBlock)
|
||||
}
|
||||
|
||||
/*! @excsafety{Strong} */
|
||||
void Sequence::Append(samplePtr buffer, sampleFormat format, size_t len)
|
||||
void Sequence::Append(constSamplePtr buffer, sampleFormat format, size_t len)
|
||||
{
|
||||
DoAppend(buffer, format, len, true);
|
||||
}
|
||||
|
||||
/*! @excsafety{Strong} */
|
||||
SeqBlock::SampleBlockPtr Sequence::DoAppend(
|
||||
samplePtr buffer, sampleFormat format, size_t len, bool coalesce)
|
||||
constSamplePtr buffer, sampleFormat format, size_t len, bool coalesce)
|
||||
{
|
||||
SeqBlock::SampleBlockPtr result;
|
||||
|
||||
@ -1606,7 +1606,8 @@ SeqBlock::SampleBlockPtr Sequence::DoAppend(
|
||||
|
||||
void Sequence::Blockify(SampleBlockFactory &factory,
|
||||
size_t mMaxSamples, sampleFormat mSampleFormat,
|
||||
BlockArray &list, sampleCount start, samplePtr buffer, size_t len)
|
||||
BlockArray &list, sampleCount start,
|
||||
constSamplePtr buffer, size_t len)
|
||||
{
|
||||
if (len <= 0)
|
||||
return;
|
||||
@ -1620,7 +1621,7 @@ void Sequence::Blockify(SampleBlockFactory &factory,
|
||||
const auto offset = i * len / num;
|
||||
b.start = start + offset;
|
||||
int newLen = ((i + 1) * len / num) - offset;
|
||||
samplePtr bufStart = buffer + (offset * SAMPLE_SIZE(mSampleFormat));
|
||||
auto bufStart = buffer + (offset * SAMPLE_SIZE(mSampleFormat));
|
||||
|
||||
b.sb = factory.Create(bufStart, newLen, mSampleFormat);
|
||||
|
||||
|
@ -82,7 +82,7 @@ class PROFILE_DLL_API Sequence final : public XMLTagHandler{
|
||||
|
||||
// Note that len is not size_t, because nullptr may be passed for buffer, in
|
||||
// which case, silence is inserted, possibly a large amount.
|
||||
void SetSamples(samplePtr buffer, sampleFormat format,
|
||||
void SetSamples(constSamplePtr buffer, sampleFormat format,
|
||||
sampleCount start, sampleCount len);
|
||||
|
||||
// where is input, assumed to be nondecreasing, and its size is len + 1.
|
||||
@ -103,10 +103,11 @@ class PROFILE_DLL_API Sequence final : public XMLTagHandler{
|
||||
void Paste(sampleCount s0, const Sequence *src);
|
||||
|
||||
size_t GetIdealAppendLen() const;
|
||||
void Append(samplePtr buffer, sampleFormat format, size_t len);
|
||||
void Append(constSamplePtr buffer, sampleFormat format, size_t len);
|
||||
|
||||
//! Append data, not coalescing blocks, returning a pointer to the new block.
|
||||
SeqBlock::SampleBlockPtr AppendNewBlock(samplePtr buffer, sampleFormat format, size_t len);
|
||||
SeqBlock::SampleBlockPtr AppendNewBlock(
|
||||
constSamplePtr buffer, sampleFormat format, size_t len);
|
||||
//! Append a complete block, not coalescing
|
||||
void AppendSharedBlock(const SeqBlock::SampleBlockPtr &pBlock);
|
||||
void Delete(sampleCount start, sampleCount len);
|
||||
@ -204,7 +205,7 @@ class PROFILE_DLL_API Sequence final : public XMLTagHandler{
|
||||
int FindBlock(sampleCount pos) const;
|
||||
|
||||
SeqBlock::SampleBlockPtr DoAppend(
|
||||
samplePtr buffer, sampleFormat format, size_t len, bool coalesce);
|
||||
constSamplePtr buffer, sampleFormat format, size_t len, bool coalesce);
|
||||
|
||||
static void AppendBlock(SampleBlockFactory *pFactory, sampleFormat format,
|
||||
BlockArray &blocks,
|
||||
@ -226,7 +227,7 @@ class PROFILE_DLL_API Sequence final : public XMLTagHandler{
|
||||
sampleFormat format,
|
||||
BlockArray &list,
|
||||
sampleCount start,
|
||||
samplePtr buffer,
|
||||
constSamplePtr buffer,
|
||||
size_t len);
|
||||
|
||||
bool Get(int b,
|
||||
|
@ -31,7 +31,8 @@ public:
|
||||
|
||||
void CloseLock() override;
|
||||
|
||||
void SetSamples(samplePtr src, size_t numsamples, sampleFormat srcformat);
|
||||
void SetSamples(
|
||||
constSamplePtr src, size_t numsamples, sampleFormat srcformat);
|
||||
|
||||
//! Numbers of bytes needed for 256 and for 64k summaries
|
||||
using Sizes = std::pair< size_t, size_t >;
|
||||
@ -135,7 +136,7 @@ public:
|
||||
|
||||
SampleBlockIDs GetActiveBlockIDs() override;
|
||||
|
||||
SampleBlockPtr DoCreate(samplePtr src,
|
||||
SampleBlockPtr DoCreate(constSamplePtr src,
|
||||
size_t numsamples,
|
||||
sampleFormat srcformat) override;
|
||||
|
||||
@ -175,7 +176,7 @@ SqliteSampleBlockFactory::SqliteSampleBlockFactory( AudacityProject &project )
|
||||
SqliteSampleBlockFactory::~SqliteSampleBlockFactory() = default;
|
||||
|
||||
SampleBlockPtr SqliteSampleBlockFactory::DoCreate(
|
||||
samplePtr src, size_t numsamples, sampleFormat srcformat )
|
||||
constSamplePtr src, size_t numsamples, sampleFormat srcformat )
|
||||
{
|
||||
auto sb = std::make_shared<SqliteSampleBlock>(shared_from_this());
|
||||
sb->SetSamples(src, numsamples, srcformat);
|
||||
@ -390,7 +391,7 @@ size_t SqliteSampleBlock::DoGetSamples(samplePtr dest,
|
||||
numsamples * SAMPLE_SIZE(mSampleFormat)) / SAMPLE_SIZE(mSampleFormat);
|
||||
}
|
||||
|
||||
void SqliteSampleBlock::SetSamples(samplePtr src,
|
||||
void SqliteSampleBlock::SetSamples(constSamplePtr src,
|
||||
size_t numsamples,
|
||||
sampleFormat srcformat)
|
||||
{
|
||||
|
@ -224,7 +224,7 @@ bool WaveClip::GetSamples(samplePtr buffer, sampleFormat format,
|
||||
}
|
||||
|
||||
/*! @excsafety{Strong} */
|
||||
void WaveClip::SetSamples(samplePtr buffer, sampleFormat format,
|
||||
void WaveClip::SetSamples(constSamplePtr buffer, sampleFormat format,
|
||||
sampleCount start, size_t len)
|
||||
{
|
||||
// use Strong-guarantee
|
||||
@ -1203,7 +1203,7 @@ void WaveClip::AppendSharedBlock(const std::shared_ptr<SampleBlock> &pBlock)
|
||||
/*! @excsafety{Partial}
|
||||
-- Some prefix (maybe none) of the buffer is appended,
|
||||
and no content already flushed to disk is lost. */
|
||||
bool WaveClip::Append(samplePtr buffer, sampleFormat format,
|
||||
bool WaveClip::Append(constSamplePtr buffer, sampleFormat format,
|
||||
size_t len, unsigned int stride)
|
||||
{
|
||||
//wxLogDebug(wxT("Append: len=%lli"), (long long) len);
|
||||
|
@ -238,7 +238,7 @@ public:
|
||||
|
||||
bool GetSamples(samplePtr buffer, sampleFormat format,
|
||||
sampleCount start, size_t len, bool mayThrow = true) const;
|
||||
void SetSamples(samplePtr buffer, sampleFormat format,
|
||||
void SetSamples(constSamplePtr buffer, sampleFormat format,
|
||||
sampleCount start, size_t len);
|
||||
|
||||
Envelope* GetEnvelope() { return mEnvelope.get(); }
|
||||
@ -286,7 +286,7 @@ public:
|
||||
|
||||
/// You must call Flush after the last Append
|
||||
/// @return true if at least one complete block was created
|
||||
bool Append(samplePtr buffer, sampleFormat format,
|
||||
bool Append(constSamplePtr buffer, sampleFormat format,
|
||||
size_t len, unsigned int stride);
|
||||
/// Flush must be called after last Append
|
||||
void Flush();
|
||||
|
@ -1530,7 +1530,7 @@ void WaveTrack::Join(double t0, double t1)
|
||||
/*! @excsafety{Partial}
|
||||
-- Some prefix (maybe none) of the buffer is appended,
|
||||
and no content already flushed to disk is lost. */
|
||||
bool WaveTrack::Append(samplePtr buffer, sampleFormat format,
|
||||
bool WaveTrack::Append(constSamplePtr buffer, sampleFormat format,
|
||||
size_t len, unsigned int stride /* = 1 */)
|
||||
{
|
||||
return RightmostOrNewClip()->Append(buffer, format, len, stride);
|
||||
@ -1961,7 +1961,7 @@ bool WaveTrack::Get(samplePtr buffer, sampleFormat format,
|
||||
}
|
||||
|
||||
/*! @excsafety{Weak} */
|
||||
void WaveTrack::Set(samplePtr buffer, sampleFormat format,
|
||||
void WaveTrack::Set(constSamplePtr buffer, sampleFormat format,
|
||||
sampleCount start, size_t len)
|
||||
{
|
||||
for (const auto &clip: mClips)
|
||||
@ -1994,7 +1994,7 @@ void WaveTrack::Set(samplePtr buffer, sampleFormat format,
|
||||
}
|
||||
|
||||
clip->SetSamples(
|
||||
(samplePtr)(((char*)buffer) +
|
||||
(constSamplePtr)(((const char*)buffer) +
|
||||
startDelta.as_size_t() *
|
||||
SAMPLE_SIZE(format)),
|
||||
format, inclipDelta, samplesToCopy.as_size_t() );
|
||||
|
@ -228,7 +228,7 @@ private:
|
||||
*
|
||||
* @return true if at least one complete block was created
|
||||
*/
|
||||
bool Append(samplePtr buffer, sampleFormat format,
|
||||
bool Append(constSamplePtr buffer, sampleFormat format,
|
||||
size_t len, unsigned int stride=1);
|
||||
/// Flush must be called after last Append
|
||||
void Flush();
|
||||
@ -254,7 +254,7 @@ private:
|
||||
// filled according to fillFormat; but these were not necessarily one
|
||||
// contiguous range.
|
||||
sampleCount * pNumWithinClips = nullptr) const;
|
||||
void Set(samplePtr buffer, sampleFormat format,
|
||||
void Set(constSamplePtr buffer, sampleFormat format,
|
||||
sampleCount start, size_t len);
|
||||
|
||||
// Fetch envelope values corresponding to uniformly separated sample times
|
||||
|
Loading…
x
Reference in New Issue
Block a user