SlideShare a Scribd company logo
1 of 12
MP3 ENCODER CORE
IMPLEMENTATION
Tianyu SuLiu Cheng
University of Ottawa
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
PRINCIPLES
University of Ottawa
Step 1: Subband Filtering
Down sampling and take advantage of polyphase filterbank
PRINCIPLES
University of Ottawa
Step 2: Psychoacoustic Analysis
Take into account of Threshold in Quiet, Frequency Masking and Temporal Masking
PRINCIPLES
University of Ottawa
Step 3: 18 Point MDCT
Use previous analysis to decide Window Mode and reduce Noise Perception
PRINCIPLES
University of Ottawa
Step 4: Quantization & Bit Allocation
Allocate bits and apply Huffman coding
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
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;
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);
}
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);
}
DEMO
University of Ottawa
Shine MP3 Encoder Open Project
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.

More Related Content

Viewers also liked

Present1
Present1Present1
Present1
bigrio
 
El chocolate
El chocolateEl chocolate
El chocolate
elenarovi
 
Circulating micro rn as in monogenic diabetes
Circulating micro rn as in monogenic diabetesCirculating micro rn as in monogenic diabetes
Circulating micro rn as in monogenic diabetes
Wojciech Fendler
 
บริการต่างๆ ของ ภคพล
บริการต่างๆ ของ ภคพลบริการต่างๆ ของ ภคพล
บริการต่างๆ ของ ภคพล
Pakapol Somaketarin
 
Atomic structure powerpoint (boundless)
Atomic structure powerpoint (boundless)Atomic structure powerpoint (boundless)
Atomic structure powerpoint (boundless)
stwwilkinson
 
Exploration: Storyboard
Exploration: StoryboardExploration: Storyboard
Exploration: Storyboard
Rachella01
 

Viewers also liked (18)

Lect5 v2
Lect5 v2Lect5 v2
Lect5 v2
 
The effects of visual realism on search tasks in mixed reality simulations-IE...
The effects of visual realism on search tasks in mixed reality simulations-IE...The effects of visual realism on search tasks in mixed reality simulations-IE...
The effects of visual realism on search tasks in mixed reality simulations-IE...
 
Shopping for MALL
Shopping for MALLShopping for MALL
Shopping for MALL
 
Hackware 1.1
Hackware 1.1Hackware 1.1
Hackware 1.1
 
Sameer gupta ppt
Sameer gupta pptSameer gupta ppt
Sameer gupta ppt
 
Ccss math
Ccss mathCcss math
Ccss math
 
Enviromental
EnviromentalEnviromental
Enviromental
 
Psychiatric manifestations of Epilepsy
Psychiatric manifestations of EpilepsyPsychiatric manifestations of Epilepsy
Psychiatric manifestations of Epilepsy
 
Karen molina unidad i
Karen molina unidad iKaren molina unidad i
Karen molina unidad i
 
SIMULATION KILLS FOOTBALL
SIMULATION KILLS FOOTBALLSIMULATION KILLS FOOTBALL
SIMULATION KILLS FOOTBALL
 
Present1
Present1Present1
Present1
 
El chocolate
El chocolateEl chocolate
El chocolate
 
Circulating micro rn as in monogenic diabetes
Circulating micro rn as in monogenic diabetesCirculating micro rn as in monogenic diabetes
Circulating micro rn as in monogenic diabetes
 
"Kuchnia hiszpańska"
"Kuchnia hiszpańska""Kuchnia hiszpańska"
"Kuchnia hiszpańska"
 
บริการต่างๆ ของ ภคพล
บริการต่างๆ ของ ภคพลบริการต่างๆ ของ ภคพล
บริการต่างๆ ของ ภคพล
 
Tarea sesion 3
Tarea sesion 3Tarea sesion 3
Tarea sesion 3
 
Atomic structure powerpoint (boundless)
Atomic structure powerpoint (boundless)Atomic structure powerpoint (boundless)
Atomic structure powerpoint (boundless)
 
Exploration: Storyboard
Exploration: StoryboardExploration: Storyboard
Exploration: Storyboard
 

Similar to Mp3 Encoding Core Implementation

Ig2 task 1 work sheet
Ig2 task 1 work sheetIg2 task 1 work sheet
Ig2 task 1 work sheet
eduriez
 
Konversa.docx - konversa.googlecode.com
Konversa.docx - konversa.googlecode.comKonversa.docx - konversa.googlecode.com
Konversa.docx - konversa.googlecode.com
butest
 
Optimal Communication Of Real Time Data On Secure Cdma Ip...
Optimal Communication Of Real Time Data On Secure Cdma Ip...Optimal Communication Of Real Time Data On Secure Cdma Ip...
Optimal Communication Of Real Time Data On Secure Cdma Ip...
Stefanie Yang
 
Sip technology overview
Sip technology overviewSip technology overview
Sip technology overview
Oded Ben-Dori
 

Similar to Mp3 Encoding Core Implementation (20)

Snort
SnortSnort
Snort
 
TinyML - 4 speech recognition
TinyML - 4 speech recognition TinyML - 4 speech recognition
TinyML - 4 speech recognition
 
Ig2 task 1 work sheet
Ig2 task 1 work sheetIg2 task 1 work sheet
Ig2 task 1 work sheet
 
Audio compression
Audio compressionAudio compression
Audio compression
 
Ig2 task 1 work sheet
Ig2 task 1 work sheetIg2 task 1 work sheet
Ig2 task 1 work sheet
 
Konversa.docx - konversa.googlecode.com
Konversa.docx - konversa.googlecode.comKonversa.docx - konversa.googlecode.com
Konversa.docx - konversa.googlecode.com
 
Атаки на видеоконвертеры: год спустя
Атаки на видеоконвертеры: год спустяАтаки на видеоконвертеры: год спустя
Атаки на видеоконвертеры: год спустя
 
Embedded Android : System Development - Part IV
Embedded Android : System Development - Part IVEmbedded Android : System Development - Part IV
Embedded Android : System Development - Part IV
 
Efficient System Monitoring in Cloud Native Environments
Efficient System Monitoring in Cloud Native EnvironmentsEfficient System Monitoring in Cloud Native Environments
Efficient System Monitoring in Cloud Native Environments
 
Linux System Programming - Buffered I/O
Linux System Programming - Buffered I/O Linux System Programming - Buffered I/O
Linux System Programming - Buffered I/O
 
Sound Recording Glossary
Sound Recording GlossarySound Recording Glossary
Sound Recording Glossary
 
Parallel programming using MPI
Parallel programming using MPIParallel programming using MPI
Parallel programming using MPI
 
Embedded Android : System Development - Part III (Audio / Video HAL)
Embedded Android : System Development - Part III (Audio / Video HAL)Embedded Android : System Development - Part III (Audio / Video HAL)
Embedded Android : System Development - Part III (Audio / Video HAL)
 
Ai Brt
Ai BrtAi Brt
Ai Brt
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
 
Designing Tracing Tools
Designing Tracing ToolsDesigning Tracing Tools
Designing Tracing Tools
 
Workshop NGS data analysis - 2
Workshop NGS data analysis - 2Workshop NGS data analysis - 2
Workshop NGS data analysis - 2
 
Optimal Communication Of Real Time Data On Secure Cdma Ip...
Optimal Communication Of Real Time Data On Secure Cdma Ip...Optimal Communication Of Real Time Data On Secure Cdma Ip...
Optimal Communication Of Real Time Data On Secure Cdma Ip...
 
Sip technology overview
Sip technology overviewSip technology overview
Sip technology overview
 
MATLAB Audio processing
MATLAB Audio processingMATLAB Audio processing
MATLAB Audio processing
 

Recently uploaded

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
Kamal Acharya
 
Verification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxVerification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptx
chumtiyababu
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 

Recently uploaded (20)

School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
Verification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxVerification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptx
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 

Mp3 Encoding Core Implementation

  • 1. MP3 ENCODER CORE IMPLEMENTATION Tianyu SuLiu Cheng University of Ottawa
  • 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
  • 3. PRINCIPLES University of Ottawa Step 1: Subband Filtering Down sampling and take advantage of polyphase filterbank
  • 4. PRINCIPLES University of Ottawa Step 2: Psychoacoustic Analysis Take into account of Threshold in Quiet, Frequency Masking and Temporal Masking
  • 5. PRINCIPLES University of Ottawa Step 3: 18 Point MDCT Use previous analysis to decide Window Mode and reduce Noise Perception
  • 6. PRINCIPLES University of Ottawa Step 4: Quantization & Bit Allocation Allocate bits and apply Huffman coding
  • 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); }
  • 11. DEMO University of Ottawa Shine MP3 Encoder Open Project
  • 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.