From f1a3f5cbce0654fbccbdd407ca1514ea2cc5f3f2 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sat, 28 Jul 2018 21:20:02 +0200 Subject: [PATCH] Fix warnings in MpegAudioFrame --- mpegaudio/mpegaudioframe.cpp | 12 ++++-------- mpegaudio/mpegaudioframe.h | 14 +++++++------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/mpegaudio/mpegaudioframe.cpp b/mpegaudio/mpegaudioframe.cpp index c1996bd..de266ab 100644 --- a/mpegaudio/mpegaudioframe.cpp +++ b/mpegaudio/mpegaudioframe.cpp @@ -28,21 +28,17 @@ const char *mpegChannelModeString(MpegChannelMode channelMode) } } -const uint64 MpegAudioFrame::m_xingHeaderOffset = 0x24; - /*! * \class TagParser::MpegAudioFrame * \brief The MpegAudioFrame class is used to parse MPEG audio frames. */ -const int MpegAudioFrame::m_bitrateTable[0x2][0x3][0xF] = { { { 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 }, - { 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 }, - { 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 } }, +const uint16 MpegAudioFrame::s_bitrateTable[0x2][0x3][0xF] = { { { 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 }, + { 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 }, + { 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 } }, { { 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 }, { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160 } } }; -const uint32 MpegAudioFrame::m_sync = 0xFFE00000u; - /*! * \brief Parses the header read using the specified \a reader. * \throws Throws InvalidDataException if the data read from the stream is @@ -55,7 +51,7 @@ void MpegAudioFrame::parseHeader(BinaryReader &reader, Diagnostics &diag) diag.emplace_back(DiagLevel::Critical, "Header is invalid.", "parsing MPEG audio frame header"); throw InvalidDataException(); } - reader.stream()->seekg(m_xingHeaderOffset - 4, ios_base::cur); + reader.stream()->seekg(s_xingHeaderOffset - 4, ios_base::cur); m_xingHeader = reader.readUInt64BE(); m_xingHeaderFlags = static_cast(m_xingHeader & 0xffffffffuL); if (isXingHeaderAvailable()) { diff --git a/mpegaudio/mpegaudioframe.h b/mpegaudio/mpegaudioframe.h index c283ab0..9bdb6c3 100644 --- a/mpegaudio/mpegaudioframe.h +++ b/mpegaudio/mpegaudioframe.h @@ -44,7 +44,7 @@ public: double mpegVersion() const; int layer() const; constexpr bool isProtectedByCrc() const; - uint32 bitrate() const; + uint16 bitrate() const; uint32 samplingFrequency() const; constexpr uint32 paddingSize() const; MpegChannelMode channelMode() const; @@ -63,9 +63,9 @@ public: constexpr uint32 xingQualityIndicator() const; private: - static const uint64 m_xingHeaderOffset; - static const int m_bitrateTable[0x2][0x3][0xF]; - static const uint32 m_sync; + static constexpr uint64 s_xingHeaderOffset = 0x24; + static constexpr uint32 s_sync = 0xFFE00000u; + static const uint16 s_bitrateTable[0x2][0x3][0xF]; uint32 m_header; uint64 m_xingHeader; XingHeaderFlags m_xingHeaderFlags; @@ -92,7 +92,7 @@ constexpr MpegAudioFrame::MpegAudioFrame() */ constexpr bool MpegAudioFrame::isValid() const { - return (m_header & m_sync) == m_sync; + return (m_header & s_sync) == s_sync; } /*! @@ -106,10 +106,10 @@ constexpr bool MpegAudioFrame::isProtectedByCrc() const /*! * \brief Returns the bitrate of the frame if known; otherwise returns 0. */ -inline uint32 MpegAudioFrame::bitrate() const +inline uint16 MpegAudioFrame::bitrate() const { if (mpegVersion() > 0.0 && layer() > 0) { - return m_bitrateTable[mpegVersion() == 1.0 ? 0 : 1][layer() - 1][(m_header & 0xf000u) >> 12]; + return s_bitrateTable[mpegVersion() == 1.0 ? 0 : 1][layer() - 1][(m_header & 0xf000u) >> 12]; } else { return 0; }