分类:
2012-12-07 17:35:42
原文地址:MP3编解码算法分析(17)——帧头帧尾关联表 作者:gliethttp
:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://kware.blogbus.com/logs/30705574.html
1. 头结构 HEADER
bits name comments
---- ----------------- ------------------------------
12 sync 0xFFF
1 version 1=mpeg1.0, 0=mpeg2.0
2 lay 4-lay = layerI, II or III
1 error protection 0=yes, 1=no
4 bitrate_index see table below
2 sampling_freq see table below
1 padding
1 extension see table below
2 mode see table below
2 mode_ext used with "joint stereo" mode
1 copyright 0=no 1=yes
1 original 0=no 1=yes
2 emphasis see table below
2. 位速表 bitrate_index
Mpeg Layer 1 2 3 4 5 6 7 8 9 10 11 12 13 14
------- --- -- -- -- --- --- --- --- --- --- --- --- --- --- ---
mpeg1.0 1 32 64 96 128 160 192 224 256 288 320 352 384 416 448
2 32 48 56 64 80 96 112 128 160 192 224 256 320 384
3 32 40 48 56 64 80 96 112 128 160 192 224 256 320
mpeg2.0 1 32 48 56 64 80 96 112 128 144 160 176 192 224 256
2 8 16 24 32 40 48 56 64 80 96 112 128 144 160
3 8 16 24 32 40 48 56 64 80 96 112 128 144 160
3. 采样率表 sampling_freq 强调 emphasis:
Mpeg 0 1 2 0 "none"
------- ----- ----- ----- 1 "50/15 microsecs"
mpeg1.0 44100 48000 32000 2 "reserved" must not be used!
22050 24000 16000 3 "CCITT J 17"
4. 模式 mode: 扩展模式 mode extension: 接合立体声模式扩展 jsbound mode_ext:
0 "stereo" 0 MPG_MD_LR_LR layer 0 1 2 3
1 "joint stereo" 1 MPG_MD_LR_I 1 4 8 12 16
2 "dual channel" 2 MPG_MD_MS_LR 2 4 8 12 16
3 "single channel" 3 MPG_MD_MS_I 3 0 4 8 16
5. ID3 帧尾结构 TRAILER,尾部 128 字节
帧尾结构
offset type len name
--------------------------------------------
0 char 3 tag "TAG" 标记
3 char 30 title 标题
33 char 30 artist 艺术家
63 char 30 album 专集
93 char 4 year 年月
97 char 30 comments 评论
127 byte 1 genre 流派
--------------------------------------------
流派表 genre:
0 "Blues" 20 "Alternative" 40 "AlternRock" 60 "Top 40"
1 "Classic Rock" 21 "Ska" 41 "Bass" 61 "Christian Rap"
2 "Country" 22 "Death Metal" 42 "Soul" 62 "Pop/Funk"
3 "Dance" 23 "Pranks" 43 "Punk" 63 "Jungle"
4 "Disco" 24 "Soundtrack" 44 "Space" 64 "Native American"
5 "Funk" 25 "Euro-Techno" 45 "Meditative" 65 "Cabaret"
6 "Grunge" 26 "Ambient" 46 "Instrumental Pop" 66 "New Wave"
7 "Hip-Hop" 27 "Trip-Hop" 47 "Instrumental Rock" 67 "Psychadelic"
8 "Jazz" 28 "Vocal" 48 "Ethnic" 68 "Rave"
9 "Metal" 29 "Jazz+Funk" 49 "Gothic" 69 "Showtunes"
10 "New Age" 30 "Fusion" 50 "Darkwave" 70 "Trailer"
11 "Oldies" 31 "Trance" 51 "Techno-Industrial" 71 "Lo-Fi"
12 "Other" 32 "Classical" 52 "Electronic" 72 "Tribal"
13 "Pop" 33 "Instrumental" 53 "Pop-Folk" 73 "Acid Punk"
14 "R&B" 34 "Acid" 54 "Eurodance" 74 "Acid Jazz"
15 "Rap" 35 "House" 55 "Dream" 75 "Polka"
16 "Reggae" 36 "Game" 56 "Southern Rock" 76 "Retro"
17 "Rock" 37 "Sound Clip" 57 "Comedy" 77 "Musical"
18 "Techno" 38 "Gospel" 58 "Cult" 78 "Rock & Roll"
19 "Industrial" 39 "Noise" 59 "Gangsta" 79 "Hard Rock"
80 "Unknown"
6. 帧长计算公式 frame length:
MpegVer Layer Length
------- ----- ------------------------------------------
mpeg1.0 1 (48000 * bitrate)/sampling_freq + padding
2&3 (144000 * bitrate)/sampling_freq + padding
mpeg2.0 1 (24000 * bitrate)/sampling_freq + padding
2&3 (72000 * bitrate)/sampling_freq + padding