optimized samplebuffer copying

master
Clyne 3 years ago
parent d002746e25
commit e4a8d6eefc

@ -8,7 +8,7 @@ TARGET_PLATFORM = L4
# Compiler options here. # Compiler options here.
ifeq ($(USE_OPT),) 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 endif
# C specific options here (added to USE_OPT). # 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 # List all user C define here, like -D_DEBUG=1
UDEFS = -DCORTEX_ENABLE_WFI_IDLE=TRUE \ UDEFS = -DCORTEX_ENABLE_WFI_IDLE=TRUE \
-DPORT_USE_SYSCALL=TRUE \ -DPORT_USE_SYSCALL=TRUE \
-DPORT_USE_GUARD_MPU_REGION=MPU_REGION_0 \ -DPORT_USE_GUARD_MPU_REGION=MPU_REGION_0 \
-DTARGET_PLATFORM_$(TARGET_PLATFORM) -DTARGET_PLATFORM_$(TARGET_PLATFORM)
# Define ASM defines here # Define ASM defines here
UADEFS = UADEFS =

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

@ -19,8 +19,8 @@ void SampleBuffer::clear() {
} }
__attribute__((section(".convcode"))) __attribute__((section(".convcode")))
void SampleBuffer::modify(Sample *data, unsigned int srcsize) { void SampleBuffer::modify(Sample *data, unsigned int srcsize) {
auto size = std::min(srcsize, m_size); auto size = srcsize < m_size ? srcsize : m_size;
size = (size + 15) & 0xFF0; size = (size + 15) & (~15);
m_modified = m_buffer; m_modified = m_buffer;
const int *src = reinterpret_cast<const int *>(data); 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 f = src[5];
int g = src[6]; int g = src[6];
int h = src[7]; int h = src[7];
dst[0] = a; dst[0] = a;
dst[1] = b; dst[1] = b;
dst[2] = c; dst[2] = c;
dst[3] = d; dst[3] = d;
dst[4] = e; dst[4] = e;
dst[5] = f; dst[5] = f;
dst[6] = g; dst[6] = g;
dst[7] = h; dst[7] = h;
src += 8; src += 8;
dst += 8; dst += 8;
} while (src < srcend); } while (src < srcend);
} }
__attribute__((section(".convcode"))) __attribute__((section(".convcode")))
void SampleBuffer::midmodify(Sample *data, unsigned int srcsize) { void SampleBuffer::midmodify(Sample *data, unsigned int srcsize) {
auto size = std::min(srcsize, m_size / 2); auto size = srcsize < m_size / 2 ? srcsize : m_size / 2;
size = (size + 15) & 0xFF0; size = (size + 15) & (~15);
m_modified = middata(); m_modified = middata();
const int *src = reinterpret_cast<const int *>(data); 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 f = src[5];
int g = src[6]; int g = src[6];
int h = src[7]; int h = src[7];
dst[0] = a; dst[0] = a;
dst[1] = b; dst[1] = b;
dst[2] = c; dst[2] = c;
dst[3] = d; dst[3] = d;
dst[4] = e; dst[4] = e;
dst[5] = f; dst[5] = f;
dst[6] = g; dst[6] = g;
dst[7] = h; dst[7] = h;
src += 8; src += 8;
dst += 8; dst += 8;
} while (src < srcend); } while (src < srcend);
} }

Loading…
Cancel
Save