1
0

Mp3Header.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #if !defined(MP3HEADER_HPP)
  2. #define MP3HEADER_HPP
  3. #include <iosfwd>
  4. class Mp3Header
  5. {
  6. public:
  7. Mp3Header(unsigned long);
  8. unsigned long id;
  9. unsigned long layer;
  10. unsigned long protectionBit;
  11. unsigned long bitRateIndex;
  12. unsigned long samplingFrequency;
  13. unsigned long paddingBit;
  14. unsigned long privateBit;
  15. unsigned long mode;
  16. unsigned long modeExtension;
  17. unsigned long copyright;
  18. unsigned long originalOrCopy;
  19. unsigned long emphasis;
  20. unsigned long nch;
  21. unsigned long sampleRate;
  22. unsigned long bitRate;
  23. unsigned long frameSize;
  24. unsigned short outFrameSize;
  25. enum { BITRATE_FREE = 0 };
  26. enum { MPEG_FORBIDDEN = -1};
  27. enum { SAMPLING_FREQUENCY_RESERVED = -1};
  28. enum IdTypes
  29. {
  30. MPEG1 = 1,
  31. MPEG2 = 2
  32. };
  33. enum AudioMode
  34. {
  35. STEREO_MODE = 0,
  36. JOINT_STEREO_MODE = 1,
  37. DUAL_CHANNEL_MODE = 2,
  38. SINGLE_CHANNEL_MODE = 3
  39. };
  40. /* layer code, very bad design */
  41. enum AudioLayer
  42. {
  43. AUDIO_LAYER_1 = 3,
  44. AUDIO_LAYER_2 = 2,
  45. AUDIO_LAYER_3 = 1,
  46. AUDIO_LAYER_RESERVED = 0
  47. };
  48. friend std::ostream& operator<<(std::ostream& os, const Mp3Header& mp3);
  49. private:
  50. static const unsigned short samplingFrequencyTable[2][4];
  51. static const short m1BitRateTable[3][16];
  52. static const short m2BitRateTable[3][16];
  53. static const unsigned short outFrameSizes[2][4];
  54. };
  55. #endif