aboutsummaryrefslogtreecommitdiffstats
path: root/source/samplebuffer.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2021-10-10 20:19:19 -0400
committerClyne Sullivan <clyne@bitgloo.com>2021-10-10 20:19:19 -0400
commite4a8d6eefc267c3a38d5237205421cbbe6eaebe8 (patch)
treee4fd59ab06716dcdb412799771b8d3525ad48656 /source/samplebuffer.cpp
parentd002746e25237738ab45b472c1fff6e8fbe4183b (diff)
optimized samplebuffer copying
Diffstat (limited to 'source/samplebuffer.cpp')
-rw-r--r--source/samplebuffer.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/source/samplebuffer.cpp b/source/samplebuffer.cpp
index 6f588b1..74c6778 100644
--- a/source/samplebuffer.cpp
+++ b/source/samplebuffer.cpp
@@ -19,8 +19,8 @@ void SampleBuffer::clear() {
}
__attribute__((section(".convcode")))
void SampleBuffer::modify(Sample *data, unsigned int srcsize) {
- auto size = std::min(srcsize, m_size);
- size = (size + 15) & 0xFF0;
+ auto size = srcsize < m_size ? srcsize : m_size;
+ size = (size + 15) & (~15);
m_modified = m_buffer;
const int *src = reinterpret_cast<const int *>(data);
@@ -35,22 +35,22 @@ void SampleBuffer::modify(Sample *data, unsigned int srcsize) {
int f = src[5];
int g = src[6];
int h = src[7];
- dst[0] = a;
- dst[1] = b;
- dst[2] = c;
- dst[3] = d;
- dst[4] = e;
- dst[5] = f;
- dst[6] = g;
- dst[7] = h;
- src += 8;
- dst += 8;
+ dst[0] = a;
+ dst[1] = b;
+ dst[2] = c;
+ dst[3] = d;
+ dst[4] = e;
+ dst[5] = f;
+ dst[6] = g;
+ dst[7] = h;
+ src += 8;
+ dst += 8;
} while (src < srcend);
}
__attribute__((section(".convcode")))
void SampleBuffer::midmodify(Sample *data, unsigned int srcsize) {
- auto size = std::min(srcsize, m_size / 2);
- size = (size + 15) & 0xFF0;
+ auto size = srcsize < m_size / 2 ? srcsize : m_size / 2;
+ size = (size + 15) & (~15);
m_modified = middata();
const int *src = reinterpret_cast<const int *>(data);
@@ -65,16 +65,16 @@ void SampleBuffer::midmodify(Sample *data, unsigned int srcsize) {
int f = src[5];
int g = src[6];
int h = src[7];
- dst[0] = a;
- dst[1] = b;
- dst[2] = c;
- dst[3] = d;
- dst[4] = e;
- dst[5] = f;
- dst[6] = g;
- dst[7] = h;
- src += 8;
- dst += 8;
+ dst[0] = a;
+ dst[1] = b;
+ dst[2] = c;
+ dst[3] = d;
+ dst[4] = e;
+ dst[5] = f;
+ dst[6] = g;
+ dst[7] = h;
+ src += 8;
+ dst += 8;
} while (src < srcend);
}