optimized samplebuffer copying

master
Clyne 3 years ago
parent d002746e25
commit e4a8d6eefc

@ -8,7 +8,7 @@ TARGET_PLATFORM = L4
# Compiler options here.
ifeq ($(USE_OPT),)
USE_OPT = -Os -g3 -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nosys.specs
USE_OPT = -O0 -g3 -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nosys.specs
endif
# C specific options here (added to USE_OPT).
@ -177,9 +177,9 @@ CPPWARN = -Wall -Wextra -Wundef -pedantic -Wno-volatile
# List all user C define here, like -D_DEBUG=1
UDEFS = -DCORTEX_ENABLE_WFI_IDLE=TRUE \
-DPORT_USE_SYSCALL=TRUE \
-DPORT_USE_GUARD_MPU_REGION=MPU_REGION_0 \
-DTARGET_PLATFORM_$(TARGET_PLATFORM)
-DPORT_USE_SYSCALL=TRUE \
-DPORT_USE_GUARD_MPU_REGION=MPU_REGION_0 \
-DTARGET_PLATFORM_$(TARGET_PLATFORM)
# Define ASM defines here
UADEFS =

@ -105,7 +105,7 @@ void MemManage_Handler()
{
// 1. Get the stack pointer.
uint32_t lr;
asm("mov %0, lr" : "=r" (lr));
asm("mov %0, lr" : "=r" (lr));
// 2. Recover from the fault.
ConversionManager::abort();
@ -120,14 +120,14 @@ void HardFault_Handler()
// Get the stack pointer.
//uint32_t *stack;
uint32_t lr;
asm("mov %0, lr" : "=r" (lr));
/*asm("\
tst lr, #4; \
ite eq; \
mrseq %0, msp; \
mrsne %0, psp; \
asm("mov %0, lr" : "=r" (lr));
/*asm("\
tst lr, #4; \
ite eq; \
mrseq %0, msp; \
mrsne %0, psp; \
mov %1, lr; \
" : "=r" (stack), "=r" (lr));*/
" : "=r" (stack), "=r" (lr));*/
// If coming from the algorithm, attempt to recover; otherwise, give up.
if (run_status != RunStatus::Running && (lr & 4) != 0)

@ -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);
}

Loading…
Cancel
Save