Forum Discussion
Altera_Forum
Honored Contributor
16 years agoMp3 decoder too slow on NiosII
Hi,all
I'm now designing a mp3 player for DE2 board, which use libmad for mp3 decoding. But currently, the speed is too slow for real time playing. The core is NiosII fastest core,i cache=8kb, d cache=16kb, cpu clk is set to 100MHz. It still require 380s to decode a 274s mp3 file. Can anyone tell me, is it reasonable? I have also tried to add custom instruction to replace the macro "mad_f_mul" in libmad, but the decoding speed remain the same or even worse. I can't understand it. The platform I'm using is QuartusII 9.1. any guidelines, thx!20 Replies
- Altera_Forum
Honored Contributor
did you tell the gcc that there are new CI used ?
- Altera_Forum
Honored Contributor
I just use the new CI marco in system.h. The gcc will not compile the new CI automatically? But it still give the correct results.
- Altera_Forum
Honored Contributor
Have you enabled -O2 or -O3 ?
If you rip out all calls into libc, can you fit the whole code into internal memory? (It might be that the resident set fits in the cache though.) - Altera_Forum
Honored Contributor
No, I get the result with optimization off. Does that make so much difference?
I tired to enable -O3 once, but the program didn't work correctly, it seems the program stopped at some place and a lot of codes can't be executed, so I change it back to no optimization. I don't quite understand the meaning of "If you rip out all calls into libc, can you fit the whole code into internal memory? (It might be that the resident set fits in the cache though.)". I use the 512K sram as memory and the program size is 167K. - Altera_Forum
Honored Contributor
Definitely use -O3 - the speed-up is huge. Also, create onchip RAM and find the most often called functions and move them to this RAM until it's full.
Bill - Altera_Forum
Honored Contributor
Thank you. I shall try -O3 or -O2 again.
I don't know how to create onchip RAM and move any function to it. I just know how to add the onchip RAM componet to the system using SOPC, what else should I do? - Altera_Forum
Honored Contributor
--- Quote Start --- Thank you. I shall try -O3 or -O2 again. I don't know how to create onchip RAM and move any function to it. I just know how to add the onchip RAM componet to the system using SOPC, what else should I do? --- Quote End --- Use this before functions going into onchip ram:
Of course onchip_mem has to match the name used in SOPC. Billvoid function(void) __attribute__((section(".onchip_mem"))); void function(void) { } - Altera_Forum
Honored Contributor
--- Quote Start --- cpu clk is set to 100Hz. --- Quote End --- I imagine cpu is set to 100MHz. If you are really using 100Hz cpu clk that might be the problem. - Altera_Forum
Honored Contributor
You are right, the cpu is set to 100MHz.
- Altera_Forum
Honored Contributor
FYI here is a MP3 player that handles the audio in real time that might be useful: http://www.nioswiki.com/index.php?title=nios2embeddedevaluationkit/mp3_player&highlight=mp3