50 enum {MPEG_LAYER_1 = 3, MPEG_LAYER_2 = 2, MPEG_LAYER_3 = 1};
51 enum {_MPEG_1 = 3, _MPEG_2 = 2, _MPEG_25 = 0};
53 header_parser parser(p_header);
54 if (parser.read(11) != 0x7FF)
return false;
55 unsigned mpeg_version = parser.read(2);
56 unsigned layer = parser.read(2);
57 unsigned protection = parser.read(1);
58 unsigned bitrate_index = parser.read(4);
59 unsigned sample_rate_index = parser.read(2);
60 if (sample_rate_index == 3)
return false;
61 unsigned paddingbit = parser.read(1);
64 unsigned channel_mode = parser.read(2);
70 unsigned bitrate = 0,sample_rate = 0;
77 paddingdelta = paddingbit ? 1 : 0;
83 p_info.m_duration = 1152;
88 p_info.m_duration = 576;
97 paddingdelta = paddingbit ? 1 : 0;
98 p_info.m_duration = 1152;
114 paddingdelta = paddingbit ? 4 : 0;
115 p_info.m_duration = 384;
131 if (bitrate == 0)
return false;
134 if (sample_rate == 0)
return false;
139 p_info.m_mpegversion =
MPEG_1;
143 p_info.m_mpegversion =
MPEG_2;
146 p_info.m_mpegversion =
MPEG_25;
155 p_info.m_channels = 2;
158 p_info.m_channels = 1;
162 p_info.m_channel_mode = channel_mode;
164 p_info.m_sample_rate = sample_rate;
167 p_info.m_bytes = ( bitrate * (1000/8) * p_info.m_duration ) / sample_rate + paddingdelta;
169 if (p_info.m_layer == 1) p_info.m_bytes &= ~3;
171 p_info.m_crc = protection == 0;
static const uint16 sample_rate_table[]
static const uint16 bitrate_table_l2v1[16]
static const uint16 bitrate_table_l3v1[16]
static const uint16 bitrate_table_l23v2[16]
static const uint16 bitrate_table_l1v1[16]
static const uint16 bitrate_table_l1v2[16]