AAC Decoder Optimizations

BuddyCasino
Posts: 263
Joined: Sun Jun 19, 2016 12:00 am

AAC Decoder Optimizations

Postby BuddyCasino » Fri May 12, 2017 5:04 pm

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;
}

BuddyCasino
Posts: 263
Joined: Sun Jun 19, 2016 12:00 am

Re: AAC Decoder Optimizations

Postby BuddyCasino » Sat May 13, 2017 12:15 am

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. :-/

BuddyCasino
Posts: 263
Joined: Sun Jun 19, 2016 12:00 am

Re: AAC Decoder Optimizations

Postby BuddyCasino » Sat May 13, 2017 10:48 am

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.

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: AAC Decoder Optimizations

Postby ESP_igrr » Sat May 13, 2017 3:36 pm

Regarding TIEs: these don't work with GCC compiler. Alternative is to use inline assembly.

BuddyCasino
Posts: 263
Joined: Sun Jun 19, 2016 12:00 am

Re: AAC Decoder Optimizations

Postby BuddyCasino » 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.

diogovaraujo
Posts: 1
Joined: Wed Apr 29, 2020 12:39 pm

Re: AAC Decoder Optimizations

Postby diogovaraujo » Sun Sep 11, 2022 3:54 pm

LOL, great thread, nice work..

GerryBriggs
Posts: 20
Joined: Tue Oct 24, 2023 10:11 pm

Re: AAC Decoder Optimizations

Postby GerryBriggs » Sun Aug 11, 2024 4:09 am

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

mark.k92
Posts: 1
Joined: Wed Sep 18, 2024 4:09 pm

Re: AAC Decoder Optimizations

Postby mark.k92 » Wed Sep 18, 2024 4:13 pm

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?

Who is online

Users browsing this forum: No registered users and 245 guests