Create an MP3 decoder-use mad (MPEG audio decoding library) in Symbian
Some time ago, I wrote a program on newlc.com to create an MP3 player for Series 60. I have received many emails about MP3 decoding and using it on Symbian. Here, we use mad (MPEG audio decoding library) in Symbian to solve the problem.
Overview
Because in Symbian 7.0, you can use MMF to play MP3 videos in smartphones. However, if your mobile phone does not support MP3 decoding, or if you want to receive or decode mp3 videos on your own. Here I will demonstrate how to use mad (MPEG audio decoding, libmad) in Symbian.
Why use mad? Because it is a high-quality MPEG audio decoder, and it has been tested in ARM (that is, it can be used by different micro-computers and handheld MP3 ).
Port mad to Symbian
To obtain the mad source, the following files are required:
[Copy to clipboard]
Code:
+ Inc
-D. dat
-Imdct_s.dat
-Qc_table.dat
-Rq_table.dat
-Sf_table.dat
-Bit. h
-Config. h
-Decoder. h
-Fixed. h
-Frame. h
-Global. h
-Huffman. h
-Layer12.h
-Layer3.h
-Mad. h
-Stream. h
-Synth. h
-Timer. h
-Version. h
+ SRC
-Bit. c
-Decoder. c
-Fixed. c
-Frame. c
-Huffman. c
-Layer12.c
-Layer3.c
-Stream. c
-Synth. c
-Timer. c
-Version. c
-Imdct_l_arm.s
Fixed static functions/variables are non-static. (variables can be converted to "static const ").
Edit mad. h to define fpm_arm for the device object and fpm_default. If your wins compiler does not support big inline, you need to do this:
[Copy to clipboard]
Code:
# Ifndef _ wins __
Inline
# Endif
Stack errors may occur in the layer3.c iii_decode function, that is, in the string:
[Copy to clipboard]
Code:
Mad_fixed_t XR [2] [576];
You can allocate storage or (in the case of a simple program) for the WINS object and set it as a static variable. It will run normally on the real machine.
Imdct_l_arm.s is optimized for armi. to use it, you must add its header (function iii_imdct_l ).
[Copy to clipboard]
Code:
# Ifndef _ wins __
Void iii_imdct_l (mad_fixed_t const X [18], mad_fixed_t Z [36], unsigned int block_type );
# Else
Static
Void iii_imdct_l (mad_fixed_t const X [18], mad_fixed_t Z [36], unsigned int block_type)
...
Note! The optimized imdct_l_arm cannot be compiled under thumb, so only the armi object is used.
Create an MP3 decoding Dynamic Link Library
The best way to use an MP3 decoder is DLL. You can compile it once or effectively several times without any special events on the platform. Therefore, use ettype. To add/epoc32/include/libc to systeminclude in the mm file for libmad. If you want to use the optimized iii_imdct_l function, add it to MMP:
[Copy to clipboard]
Code:
# If! Defined (WINS)
Source imdct_l_arm.s
# Endif
Also added to bld. inf :( so imdct_l_arm compiles thumb)
[Copy to clipboard]
Code:
Prj_platforms
Armi wins
If you use tips for Stack errors in the iii_decode function and do not have _ chkstk in the wins database, you need to add it yourself (empty void _ chkstk ()):
To use DLL in a program, add a function.
You can use the main loop of the madplay-Based MP3 decoder:
- Read File to buffer
- MP3 structure Decoding
- Application Filter
- Merged and decoded to PCM sample
- Retrieve PCM sample again
FilterMost Symbian smartphones do not support stereo playback, so here you can achieve single sound synthesis. You can also use a balancer.
FrequencyYou do not need to do unnecessary calculations. If the required frequency is more than half of the current frame circulation frequency, after applying for a filter, switch the frame option:
[Copy to clipboard]
Code:
Frame. Options | = mad_option_halfsamplerate;
Compiler
We recommend that you use GCC 3 to compile this program. According to my tests, it is 2.95 faster than the normal GCC 20% decoder. Do not forget that mad is licensed under GNU General Public License version 2.
I hope the article will be helpful to you, and you are welcome to write comments or give valuable comments.