chipaudette
Well-known member
I'm trying to understand the interleaving that is done with the audio samples in the AudioOutputI2SQuad class. Looking at the isr() method, I see that it calls the memcpy_tointerleaveQuad, which is in assembly. Not being an assembly guy, I'm having a hard time figuring it out.
The core part of this assembly function seems to be:
The core part is clearly this:
Can someone help me see what is happening here? The pkhbt and pkhtb lines, in particular, are confusing me because I totally don't understand what end format is desired.
What is the end format that is desired? What is the order of the samples? How tightly are they packed? Is this flipping the endian-ness?
I'd appreciate any help!
Chip
The core part of this assembly function seems to be:
Code:
/* void memcpy_tointerleaveQuad(int16_t *dst, const int16_t *src1, const int16_t *src2, const int16_t *src3, const int16_t *src4) */
.global memcpy_tointerleaveQuad
.thumb_func
memcpy_tointerleaveQuad:
@ r0: dst
@ r1: src1
@ r2: src2
@ r3: src3
@ r4: src4
push {r4-r11}
ldr r4, [sp, #(0+32)] //5th parameter is saved on the stack
add r11,r0,#(AUDIO_BLOCK_SAMPLES*4)
.align 2
.loopQuad:
ldr r5, [r1],4
ldr r6, [r3],4
pkhbt r7,r5,r6,LSL #16
pkhtb r9,r6,r5,ASR #16
ldr r5, [r2],4
ldr r6, [r4],4
pkhbt r8,r5,r6,LSL #16
pkhtb r10,r6,r5,ASR #16
stmia r0!, {r7-r10}
cmp r11, r0
bne .loopQuad
pop {r4-r11}
BX lr
.END
#endif
The core part is clearly this:
Code:
ldr r5, [r1],4
ldr r6, [r3],4
pkhbt r7,r5,r6,LSL #16
pkhtb r9,r6,r5,ASR #16
ldr r5, [r2],4
ldr r6, [r4],4
pkhbt r8,r5,r6,LSL #16
pkhtb r10,r6,r5,ASR #16
Can someone help me see what is happening here? The pkhbt and pkhtb lines, in particular, are confusing me because I totally don't understand what end format is desired.
What is the end format that is desired? What is the order of the samples? How tightly are they packed? Is this flipping the endian-ness?
I'd appreciate any help!
Chip