2. SUMMARY
• MP3 is originally developed by Fraunhofer IIS partly under EUREKA project
EU147, Digital Audio Broadcasting (DAB). It is then adopted as ISO-
MPEAudioLayer - 3, 1991 (developed followed by Layer 1 and 2).
• MP3 FILE STRUCTURE IS DIVIDED BY 3 PARTS.
TAG.V2→Frame→TAG.V1
TAG.V2
* Version
* Reversion
* Flag etc
TAG.V1
* Title
* Artist
* Album etc
Frame
* IntBitrate
* IntFrequency
* IntLayer etc
University of Ottawa
7. APPLICATIONS
University of Ottawa
KEY CODES IN SHINE MP3 ENCODER PROGRAM
THIS IS PART OF SHINE FIXED-POINT MP3 ENCODER LIBRARY OPEN PROJECT
("libshine-fxp")
libshine-fxp_20070104/
libshine-fxp /
types.h
types.c
bitstream.h
bitstream.c
Main.c
Layer3.h
Layer3.c
L3subband.h
L3subband.c
L3mdct.h
L3mdct.c
L3loop.h
L3loop.c
L3bitstream.h
L3bitstream.c
8. APPLICATIONS
University of Ottawa
KEY CODES IN SHINE MP3 ENCODER PROGRAM
types.h
typedef struct { time_t start_time; // define start time of encoding
wave_t wave; // remain the head information of source before encoding
mpeg_t mpeg; // generated head information after encoding
/* These two app-supplied routines are used to read and write data */
int (*get_pcm)(short buffer[2][samp_per_frame], void *config_in);
int (*write_mp3)(long bytes, void *buffer, void *config_in);
} config_t;
bitstream.h
typedef struct bit_stream_struc {
FILE *pt; // pointer to bit stream
unsigned char *buf; // bit stream buffer
int mode; /* bit stream open in read or write mode */
} bitstream_t;
9. APPLICATIONS
University of Ottawa
KEY CODES IN SHINE MP3 ENCODER PROGRAM
Main.c
#include "Layer3.h"
int main(int argc, char **argv) {
wave_open(&config);
/* set up the read PCM stream and write MP3 stream functions */
config.get_pcm=&wave_get;
config.write_mp3=&write_mp3;
L3_compress(&config);
wave_close(&config);
}
10. APPLICATIONS
University of Ottawa
KEY CODES IN SHINE MP3 ENCODER PROGRAM
Layer3.c
#include "L3subband.h“
#include "L3mdct.h“
#include "L3loop.h“
#include "L3bitstream.h"
void L3_compress(config_t *config) {
for(gr=0; gr<config.mpeg.granules; gr++) /* polyphase filtering, refered in L3subband.h*/
for(ch=0; ch<config.mpeg.channels; ch++)
for(i=0;i<18;i++)
L3_window_filter_subband(&buffer[ch],&l3_sb_sample[ch][gr+1][i][0]
,ch);
/* apply MDCT to the polyphase output, refered in L3mdct.h */
L3_mdct_sub(l3_sb_sample, mdct_freq); /
bit and noise allocation according to, refered in L3loop.h */
L3_iteration_loop(mdct_freq, &side_info, l3_enc,mean_bits);
/* write the frame to the bitstream, declared in L3bitstream.h */
L3_format_bitstream(l3_enc, &side_info);
}
12. REFERENCES
University of Ottawa
1. Shine Fixed-pt MP3 Encoder Library: Project Web Hosting - Open Source
Software(n.d.). Retrieved November 17, 2014, from http://libshine-
fxp.sourceforge.net
2. Brandenburg K. MP3 and AAC explained[C]//Audio Engineering Society
Conference: 17th International Conference: High-Quality Audio Coding.
Audio Engineering Society, 1999.
3. 张芷燕. MP3 编码法之研究与实现[D]. 台湾国立交通大学, 2002.
4. Noll P. MPnn H G. Genesis of the MP3 audio coding standard[J]. Consumer
Electronics, IEEE Transactions on, 2006, 52(3): 1043-1049EG digital audio
coding[J]. Signal Processing Magazine, IEEE, 1997, 14(5): 59-81.
5. Herre J, Purnhagen H, Breebaart J, et al. The reference model architecture
for MPEG spatial audio coding[C]//Audio Engineering Society Convention
Paper. 2005, 6447: 28-31.