LAMEinfo.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #ifndef NULLSOFT_LAMEINFOH
  2. #define NULLSOFT_LAMEINFOH
  3. #define FRAMES_FLAG 0x0001
  4. #define BYTES_FLAG 0x0002
  5. #define TOC_FLAG 0x0004
  6. #define VBR_SCALE_FLAG 0x0008
  7. #define FRAMES_AND_BYTES (FRAMES_FLAG | BYTES_FLAG)
  8. #include <memory.h>
  9. #pragma intrinsic(memset)
  10. struct LAMEinfo
  11. {
  12. LAMEinfo()
  13. {
  14. memset(this, 0, sizeof(LAMEinfo));
  15. }
  16. int cbr; // set to 1 if the file is actually just CBR
  17. // Xing
  18. int h_id;
  19. int samprate; // determined from MPEG header
  20. int flags; // from Xing header data
  21. int frames; // total bit stream frames from Xing header data
  22. int bytes; // total bit stream bytes from Xing header data
  23. int vbr_scale; // encoded vbr scale from Xing header data
  24. unsigned char *toc; // pointer to unsigned char toc_buffer[100]
  25. // may be NULL if toc not desired
  26. // LAME
  27. char lameTag[10]; // 9 characters, but we'll add an extra NULL just in case
  28. float peak;
  29. float replaygain_album_gain;
  30. float replaygain_track_gain;
  31. unsigned short lowpass;
  32. unsigned short encoderDelay;
  33. unsigned short padding;
  34. int encodingMethod;
  35. };
  36. enum
  37. {
  38. ENCODING_METHOD_LAME = 0,
  39. ENCODING_METHOD_CBR = 1,
  40. ENCODING_METHOD_ABR = 2,
  41. ENCODING_METHOD_VBR1 = 3,
  42. ENCODING_METHOD_VBR2 = 4,
  43. ENCODING_METHOD_VBR3 = 5,
  44. ENCODING_METHOD_VBR4 = 6,
  45. ENCODING_METHOD_CBR_2PASS = 8,
  46. ENCODING_METHOD_ABR_2PASS = 9,
  47. };
  48. int ReadLAMEinfo(unsigned char *buffer, LAMEinfo *lameInfo);
  49. class MPEGFrame
  50. {
  51. public:
  52. int GetNumChannels();
  53. void ReadBuffer(const unsigned char *buffer);
  54. bool IsSync();
  55. int GetBitrate();
  56. int GetPadding();
  57. int HeaderSize();
  58. int GetSampleRate() const;
  59. int FrameSize();
  60. const char *GetMPEGVersionString();
  61. const char *GetChannelModeString();
  62. const char *GetEmphasisString();
  63. int GetLayer();
  64. bool IsCRC();
  65. bool IsCopyright();
  66. bool IsOriginal();
  67. int MPEGFrame::GetSamplesPerFrame() const;
  68. enum
  69. {
  70. NotPadded=0,
  71. Padded=1,
  72. CRC = 0,
  73. NoProtection = 1,
  74. Stereo = 0,
  75. JointStereo = 1,
  76. DualChannel = 2,
  77. Mono = 3,
  78. MPEG1 = 3,
  79. MPEG2 = 2,
  80. MPEG_Error = 1,
  81. MPEG2_5 = 0,
  82. Layer1 = 3,
  83. Layer2 = 2,
  84. Layer3 = 1,
  85. LayerError = 0,
  86. Emphasis_None = 0,
  87. Emphasis_50_15_ms = 1,
  88. Emphasis_reserved = 2,
  89. Emphasis_CCIT_J_17 = 3,
  90. };
  91. unsigned int sync:11,
  92. mpegVersion:2,
  93. layer:2,
  94. protection:1,
  95. bitrateIndex:4,
  96. paddingBit:1,
  97. privateBit:1,
  98. channelMode:2,
  99. modeExtension:2,
  100. sampleRateIndex:2,
  101. copyright:1,
  102. original:1,
  103. emphasis:2;
  104. };
  105. #endif