1
0

mpegheader.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /***************************************************************************\
  2. *
  3. * MPEG Layer3-Audio Decoder
  4. * © 1997-2006 by Fraunhofer IIS
  5. * All Rights Reserved
  6. *
  7. * filename: mpegheader.h
  8. * project : MPEG Decoder
  9. * author : Martin Sieler
  10. * date : 1997-12-05
  11. * contents/description: ISO/MPEG Header
  12. *
  13. *
  14. \***************************************************************************/
  15. /*
  16. * $Date: 2010/11/17 20:46:04 $
  17. * $Id: mpegheader.h,v 1.1 2010/11/17 20:46:04 audiodsp Exp $
  18. */
  19. #ifndef __MPEGHEADER_H__
  20. #define __MPEGHEADER_H__
  21. /* ------------------------ includes --------------------------------------*/
  22. /*-------------------------- defines --------------------------------------*/
  23. class CBitStream;
  24. /*-------------------------------------------------------------------------*/
  25. //
  26. // MPEG header class.
  27. //
  28. // This object reads and decodes an ISO/MPEG header.
  29. //
  30. class CMpegHeader
  31. {
  32. public:
  33. CMpegHeader();
  34. virtual ~CMpegHeader();
  35. int ReadFrom(CBitStream &sBS);
  36. int FromInt(unsigned long dwHdrBits);
  37. int GetMpegVersion() const { return m_MpegVersion;}
  38. int GetLayer() const { return m_Layer;}
  39. int GetChannels() const { return m_Channels;}
  40. int GetSampleRate() const { return m_SampleRate;}
  41. int GetSampleRateNdx() const { return m_SampleRateNdx;}
  42. int GetBitrate() const { return m_Bitrate;}
  43. int GetBitrateNdx() const { return m_BitrateNdx;}
  44. int GetMode() const { return m_Mode;}
  45. int GetModeExt() const { return m_ModeExt;}
  46. int GetPadding() const { return m_Padding; }
  47. int GetCrcCheck() const { return m_CrcCheck;}
  48. int GetCopyright() const { return m_Copyright;}
  49. int GetOriginal() const { return m_Original;}
  50. int GetEmphasis() const { return m_Emphasis;}
  51. int GetHeaderLen() const
  52. { return MPEG_HDRLEN+(m_CrcCheck?MPEG_CRCLEN:0); }
  53. int GetFrameLen() const { return m_FrameLen;}
  54. float GetDuration() const { return m_Duration;}
  55. int GetSamplesPerFrame() const;
  56. protected:
  57. private:
  58. enum { MPEG_HDRLEN = 32, MPEG_CRCLEN = 16 };
  59. int CalcFrameLen();
  60. void ResetMembers();
  61. void SetMembers();
  62. // header fields
  63. int m_Syncword;
  64. int m_Idex;
  65. int m_Id;
  66. int m_Layer;
  67. int m_CrcCheck;
  68. int m_BitrateNdx;
  69. int m_SampleRateNdx;
  70. int m_Padding;
  71. int m_Private;
  72. int m_Mode;
  73. int m_ModeExt;
  74. int m_Copyright;
  75. int m_Original;
  76. int m_Emphasis;
  77. // calculated data
  78. int m_HeaderValid;
  79. int m_MpegVersion;
  80. int m_Channels;
  81. int m_SampleRate;
  82. int m_Bitrate;
  83. int m_FrameLen;
  84. float m_Duration;
  85. };
  86. /*-------------------------------------------------------------------------*/
  87. #endif