Page 1 of 1

AAC Decoder Optimizations

Posted: Fri May 12, 2017 5:04 pm
by BuddyCasino
I've got the Fraunhofer fdk-aac decoder running, and its fine for LC but too slow for AAC+ (SBR etc.), even on 240MHz.

There are some optimizations for other archs, but not xtensa:
https://github.com/mstorsjo/fdk-aac/tre ... DK/include

Has anyone done anything in that direction? Which of the architectures with optimizations enabled (aarch64, arm, mips, ppc, x86) is most similar to xtensa?

Also, most of the interesting opcodes seem to be optional - is there a document that tells me which ones are implemented in the ESP32?

EDIT: the ISA options are listed here: /esp-idf/components/esp32/include/xtensa/config/core-isa.h
Will check out the MUL32 and DIV32 opcodes (sadly no HIFI DSP extensions).

Edit 2: looks like two functions is all it takes. This is x86, any takers?

Code: Select all

inline INT fixmul_DD (INT a, const INT b)
{
  INT result;

  asm( "imul %2;\n"
       "shl $1, %0;\n"
            : "=d"(result), "+a"(a)
            : "r"(b) );

  return result;
}


inline INT fixmuldiv2_DD (INT a, const INT b)
{
  INT result;

  asm ( "imul %2;"
             : "=d"(result), "+a"(a)
             : "r"(b) );

  return result;
}

Re: AAC Decoder Optimizations

Posted: Sat May 13, 2017 12:15 am
by BuddyCasino
Everything has to be done by myself. ^_^
Added some assembly optimizations, better but still not fast enough.

Anyone knows how to use the pre-defined intrinsics in /esp32/include/xtensa/tie/*.h? I get a linker error when trying to use them. :-/

Re: AAC Decoder Optimizations

Posted: Sat May 13, 2017 10:48 am
by BuddyCasino
Guess I'll just continue talking to myself. AAC+ works now, but it requires a much larger DMA buffer that matches the 4096 byte buffer from the decoder. Optimizations would therefore still be highly welcome.

Re: AAC Decoder Optimizations

Posted: Sat May 13, 2017 3:36 pm
by ESP_igrr
Regarding TIEs: these don't work with GCC compiler. Alternative is to use inline assembly.

Re: AAC Decoder Optimizations

Posted: Sat May 13, 2017 3:53 pm
by BuddyCasino
Ok, too bad. At least I learned some assembly along the way. Still can't believe that really worked.

Re: AAC Decoder Optimizations

Posted: Sun Sep 11, 2022 3:54 pm
by diogovaraujo
LOL, great thread, nice work..

Re: AAC Decoder Optimizations

Posted: Sun Aug 11, 2024 4:09 am
by GerryBriggs
I am also here reading this lol. I used to be able to get AAC to run on ESP32C3 but now it wont initialize. I happen to be good at assembly but I have no idea what you did

Re: AAC Decoder Optimizations

Posted: Wed Sep 18, 2024 4:13 pm
by mark.k92
BuddyCasino wrote:
Sat May 13, 2017 3:53 pm
Ok, too bad. At least I learned some assembly along the way. Still can't believe that really worked.
Are you able to provide your solution code?