Browse Source

copy_to_buffers optimize..

assembler does not help much, i think.. ?
+ perhaps make len const
main
Frank 8 years ago
parent
commit
cc159e2c68
1 changed files with 17 additions and 3 deletions
  1. +17
    -3
      teensy3/usb_audio.cpp

+ 17
- 3
teensy3/usb_audio.cpp View File

@@ -72,12 +72,26 @@ void AudioInputUSB::begin(void)

static void copy_to_buffers(const uint32_t *src, int16_t *left, int16_t *right, unsigned int len)
{
// TODO: optimize...
while (len > 0) {
uint32_t *target = (uint32_t*) src + len;
while ((src < target) && (((uintptr_t) left & 0x02) != 0)) {
uint32_t n = *src++;
*left++ = n & 0xFFFF;
*right++ = n >> 16;
}

while ((src < target - 2)) {
uint32_t n = *src++;
uint32_t n1 = *src++;
*(uint32_t *)left = n & 0xFFFF | ((n1 & 0xFFFF) << 16);
left+=2;
*(uint32_t *)right = (n >> 16) | ((n1 & 0xFFFF0000)) ;
right+=2;
}

while ((src < target)) {
uint32_t n = *src++;
*left++ = n & 0xFFFF;
*right++ = n >> 16;
len--;
}
}


Loading…
Cancel
Save