3 #include "../exceptions.h" 5 #include <c++utilities/io/binaryreader.h> 17 switch (channelMode) {
18 case MpegChannelMode::Stereo:
19 return "2 channels: stereo";
20 case MpegChannelMode::JointStereo:
21 return "2 channels: joint stereo";
22 case MpegChannelMode::DualChannel:
23 return "2 channels: dual channel";
24 case MpegChannelMode::SingleChannel:
25 return "1 channel: single channel";
31 const uint64 MpegAudioFrame::m_xingHeaderOffset = 0x24;
38 const int MpegAudioFrame::m_bitrateTable[0x2][0x3][0xF] = { { { 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 },
39 { 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 },
40 { 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 } },
41 { { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256 }, { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160 },
42 { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160 } } };
44 const uint32 MpegAudioFrame::m_sync = 0xFFE00000u;
51 void MpegAudioFrame::parseHeader(BinaryReader &reader)
53 m_header = reader.readUInt32BE();
57 reader.stream()->seekg(m_xingHeaderOffset - 4, ios_base::cur);
58 m_xingHeader = reader.readUInt64BE();
59 m_xingHeaderFlags =
static_cast<XingHeaderFlags>(m_xingHeader & 0xffffffffuL);
60 if (isXingHeaderAvailable()) {
61 if (isXingFramefieldPresent()) {
62 m_xingFramefield = reader.readUInt32BE();
64 if (isXingBytesfieldPresent()) {
65 m_xingBytesfield = reader.readUInt32BE();
67 if (isXingTocFieldPresent()) {
68 reader.stream()->seekg(64, ios_base::cur);
70 if (isXingQualityIndicatorFieldPresent()) {
71 m_xingQualityIndicator = reader.readUInt32BE();
79 double MpegAudioFrame::mpegVersion()
const 81 switch (m_header & 0x180000u) {
96 int MpegAudioFrame::layer()
const 98 switch (m_header & 0x60000u) {
113 uint32 MpegAudioFrame::samplingFrequency()
const 115 switch (m_header & 0xc00u) {
119 switch (m_header & 0x180000u) {
129 switch (m_header & 0x180000u) {
139 switch (m_header & 0x180000u) {
158 switch (m_header & 0xc0u) {
160 return MpegChannelMode::SingleChannel;
162 return MpegChannelMode::DualChannel;
164 return MpegChannelMode::JointStereo;
166 return MpegChannelMode::Stereo;
170 return MpegChannelMode::Unspecifed;
176 uint32 MpegAudioFrame::sampleCount()
const 178 switch (m_header & 0x60000u) {
184 switch (m_header & 0x180000u) {
199 uint32 MpegAudioFrame::size()
const 201 switch (m_header & 0x60000u) {
203 return static_cast<uint32
>(
204 ((
static_cast<double>(
bitrate()) * 1024.0 / 8.0) /
static_cast<double>(samplingFrequency())) *
static_cast<double>(sampleCount())
205 + static_cast<double>(paddingSize()));
208 return static_cast<uint32
>(
209 ((
static_cast<double>(
bitrate()) * 1024.0 / 8.0) /
static_cast<double>(samplingFrequency())) *
static_cast<double>(sampleCount())
210 + static_cast<double>(paddingSize()));
MpegChannelMode
Specifies the channel mode.
TAG_PARSER_EXPORT const char * bitrate()
The track's bit rate in bits per second.
Contains utility classes helping to read and write streams.
TAG_PARSER_EXPORT const char * mpegChannelModeString(MpegChannelMode channelMode)
Returns the string representation for the specified channelMode.