Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- codec_interface.c.orig Mon Jan 9 15:14:20 2023
- +++ codec_interface.c Mon Jan 9 15:14:20 2023
- @@ -36,22 +36,17 @@ void codecDecode(uint8_t *indata_ptr, int numbBlocks)
- {
- uint16_t bitbuffer_decode[49];
- -
- - register int r0 asm ("r0") __attribute__((unused));
- - register int r1 asm ("r1") __attribute__((unused));
- - register int r2 asm ("r2") __attribute__((unused));
- -
- for (int idx = 0; idx < numbBlocks; idx++)
- {
- initFrame(indata_ptr, bitbuffer_decode);
- indata_ptr += 9;
- soundSetupBuffer();// this just sets currentWaveBuffer but the compiler seems to optimise out the code if I try to do it in this file
- - r2 = (int)bitbuffer_decode;
- - r0 = (int)currentWaveBuffer;
- - r1 = (int)ambebuffer_decode;
- asm volatile (
- + "MOV R2, %0\n"
- + "MOV R0, %1\n"
- + "MOV R1, %2\n"
- "PUSH {R4-R11}\n"
- "SUB SP, SP, #0x10\n"
- "STR R1, [SP, #0x08]\n"
- @@ -64,16 +59,21 @@ void codecDecode(uint8_t *indata_ptr, int numbBlocks)
- "BL " QU(AMBE_DECODE)
- "ADD SP, SP, #0x10\n"
- "POP {R4-R11}"
- + :
- + : "r"(bitbuffer_decode),
- + "r"(currentWaveBuffer),
- + "r"(ambebuffer_decode)
- + : "memory"
- );
- soundStoreBuffer();
- soundSetupBuffer();// this just sets currentWaveBuffer but the compiler seems to optimise out the code if I try to do it in this file
- - r2 = (int)bitbuffer_decode;
- - r0 = (int)currentWaveBuffer;
- - r1 = (int)ambebuffer_decode;
- asm volatile (
- + "MOV R2, %0\n"
- + "MOV R0, %1\n"
- + "MOV R1, %2\n"
- "PUSH {R4-R11}\n"
- "SUB SP, SP, #0x10\n"
- "STR R1, [SP, #0x08]\n"
- @@ -86,6 +86,11 @@ void codecDecode(uint8_t *indata_ptr, int numbBlocks)
- "BL " QU(AMBE_DECODE)
- "ADD SP, SP, #0x10\n"
- "POP {R4-R11}"
- + :
- + : "r"(bitbuffer_decode),
- + "r"(currentWaveBuffer),
- + "r"(ambebuffer_decode)
- + : "memory"
- );
- soundStoreBuffer();
- @@ -94,21 +99,16 @@ void codecDecode(uint8_t *indata_ptr, int numbBlocks)
- void codecEncodeBlock(uint8_t *outdata_ptr)
- {
- - register int r0 asm ("r0") __attribute__((unused));
- - register int r1 asm ("r1") __attribute__((unused));
- - register int r2 asm ("r2") __attribute__((unused));
- -
- memset((uint8_t *)outdata_ptr, 0, 9);// fills with zeros
- memset(bitbuffer_encode, 0, sizeof(bitbuffer_encode));// faster to call memset as it will be compiled as optimised code
- soundRetrieveBuffer();// gets currentWaveBuffer pointer used as input r2 to the encoder
- - r0 = (int)bitbuffer_encode;
- - r2 = (int)currentWaveBuffer;//tmp_wavbuffer;
- - r1 = (int)ambebuffer_encode;// seems to be a hard coded (defined) memory address of 0x1FFF6B60. I'm not sure why it has to be hard coded, since its passed as a paramater (register)
- -
- asm volatile (
- + "MOV R0, %0\n"
- + "MOV R2, %1\n"
- + "MOV R1, %2\n"
- "PUSH {R4-R11}\n"
- "SUB SP, SP, #0x14\n"
- "STR R1, [SP, #0x0C]\n"
- @@ -123,15 +123,22 @@ void codecEncodeBlock(uint8_t *outdata_ptr)
- "BL " QU(AMBE_ENCODE)
- "ADD SP, SP, #0x14\n"
- "POP {R4-R11}"
- + :
- + : "r"(bitbuffer_encode),
- + "r"(currentWaveBuffer), //tmp_wavbuffer
- + /* seems to be a hard coded (defined) memory address of
- + 0x1FFF6B60. I'm not sure why it has to be hard coded,
- + since its passed as a paramater (register) */
- + "r"(ambebuffer_encode)
- + : "memory"
- );
- soundRetrieveBuffer();// gets currentWaveBuffer pointer used as input r2 to the encoder
- - r0 = (int)bitbuffer_encode;
- - r2 = (int)currentWaveBuffer;//tmp_wavbuffer;
- - r1 = (int)ambebuffer_encode;
- -
- asm volatile (
- + "MOV R0, %0\n"
- + "MOV R2, %1\n"
- + "MOV R1, %2\n"
- "PUSH {R4-R11}\n"
- "SUB SP, SP, #0x14\n"
- "STR R1, [SP, #0x0C]\n"
- @@ -146,12 +153,16 @@ void codecEncodeBlock(uint8_t *outdata_ptr)
- "BL " QU(AMBE_ENCODE)
- "ADD SP, SP, #0x14\n"
- "POP {R4-R11}"
- + :
- + : "r"(bitbuffer_encode),
- + "r"(currentWaveBuffer), //tmp_wavbuffer
- + "r"(ambebuffer_encode)
- + : "memory"
- );
- - r0 = (int)bitbuffer_encode;
- - r1 = (int)ambebuffer_encode_ecc;
- -
- asm volatile (
- + "MOV R0, %0\n"
- + "MOV R1, %1\n"
- "PUSH {R4-R11}\n"
- "SUB SP, SP, #0x14\n"
- "MOV R3, R1\n"
- @@ -160,6 +171,10 @@ void codecEncodeBlock(uint8_t *outdata_ptr)
- "BL " QU(AMBE_ENCODE_ECC)
- "ADD SP, SP, #0x14\n"
- "POP {R4-R11}"
- + :
- + : "r"(bitbuffer_encode),
- + "r"(ambebuffer_encode_ecc)
- + : "memory"
- );
- for (int i = 0; i < 72; i++)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement