Symbian-create an MP3 Decoder

Source: Internet
Author: User
Create an MP3 Decoder
Use mad -- (MPEG audio decoder Library) on the Symbian Platform)

Here you can get an introduction to the solution for decoding MP3 using the mad library.
Starting from Symbian 7.0s, you can use the MMF mechanism to play MP3 files on your smartphone,
However, if your mobile phone does not support MP3 decoder, how can I play it? Or you
How can I play an MP3 file in your own format?

Here, I will teach you how to port the mad Library to the Symbian platform and use it
Play MP3.

1. Why transplant the mad database?
Because it is a high-performance MPEG sound decoder, and already on the ARM CPU
The test is passed. (MP3 players in many Pocket PCs and palm systems are using it)

2. Transplantation of mad to Symbian
Download mad'sSource code, You will use the following files:

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

(1) convert static functions and variables into non-static (static variables can be changedConst)

(2) edit the mad. h file, change its device platform to define fpm_arm, and set other platforms to fpm_default.

(3) If your wins compiler does not support the big inline function, add the following at the beginning of the file:
CodeYou can:
# Ifndef _ wins __
Inline
# Endif

(4) In the iii_decode function of the layer3.c file, a stack overflow error occurs.
Because the array size is too large (the Symbian stack space is too small ):
Mad_fixed_t XR [2] [576]; //
You can use alloc to manually allocate space from the stack, or set it to static in simple cases (tips for using wins objects), which can be run on a real machine.

(5) The imdct_l_arm.s file is specially designed to optimize DCT for the armi compilation options.Algorithm, You must
(The corresponding function is iii_imdct_l (...))
# 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:
Optimized imdct_l_arm cannot be compiled in thumb mode, so it can only be used for armi compilation options.

(6) Create an MP3 decoder DLL
The best way is to make the MP3 decoder into a DLL-so that you can compile it once and use it everywhere,
There is no platform adaptation problem.
Use targettype DLL.
Add systeminclude \ epoc32 \ include \ libc to the MPs File
With the libc library, libmad can be compiled.
If you want to use the optimized iii_imdct_l function, add
# If! Defined (WINS)
Source imdct_l_arm.s
# Endif

And add it to the bld. inf file (this is why it cannot be compiled in thumb mode)
Prj_platforms
Armi wins

If you compile and run it under the WINS simulator, you do not needProgramStack check
You can clear the void _ chkstk () function by yourself. If you want to port the function to a real machine, you do not need
.

Well, the rest is to call this decoder in your own app.
The usage is as follows:
(1) read MP3 binary data from the file into the buffer
(2) Call MP3 frame decoding in the decoder buffer
(3) apply Filter)
(4) synchronize decoded frames to corresponding PCM sampling
(5) resynthesize PCM sampling

Filter description:
Most smartphones do not allow stereo playback, so you can
Merge the sound into a single channel or write your own equalizer ?).

Frequency description:
Avoid unnecessary calculation. If the required frequency is 1.5 times the current frame frequency,
You can modify the decoder parameters by calling Filter:
Frame. Options | = mad_option_halfsamplerate;

Finally, let's talk about Compilation:
I suggest using gcc 3.x to compile this library and pass my tests. This will improve the performance compared with using gcc 2.95.
Decoding speed of 20%.

Do not forget that the mad library complies with the gnu gpl protocol, so you should also comply with it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.