1
0

LAMEInfo.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #pragma once
  2. #include "foundation/types.h"
  3. #include "MPEGHeader.h"
  4. #define FRAMES_FLAG 0x0001
  5. #define BYTES_FLAG 0x0002
  6. #define TOC_FLAG 0x0004
  7. #define VBR_SCALE_FLAG 0x0008
  8. #define FRAMES_AND_BYTES (FRAMES_FLAG | BYTES_FLAG)
  9. struct LAMEInfo
  10. {
  11. LAMEInfo();
  12. uint64_t GetSeekPoint(double percent) const; /* 0 <= percent <= 1.0 */
  13. int Read(const MPEGHeader &frame, const uint8_t *buffer, size_t bufferlen);
  14. double GetLengthSeconds() const;
  15. uint64_t GetSamples() const;
  16. uint32_t GetFrames() const;
  17. bool Flag(int flag) const;
  18. int GetGaps(size_t *pregap, size_t *postgap);
  19. protected:
  20. int version;
  21. int sample_rate;
  22. int samples_per_frame;
  23. int cbr; // set to 1 if the file is actually just CBR
  24. // Xing
  25. int flags; // from Xing header data
  26. uint32_t frames; // total bit stream frames from Xing header data
  27. uint64_t bytes; // total bit stream bytes from Xing header data
  28. int vbr_scale; // encoded vbr scale from Xing header data
  29. uint8_t toc[100]; // pointer to unsigned char toc_buffer[100]
  30. // may be NULL if toc not desired
  31. // LAME
  32. char encoder[32]; // 9 characters, but we'll add an extra NULL just in case
  33. float peak;
  34. float replaygain_album_gain;
  35. float replaygain_track_gain;
  36. unsigned short lowpass;
  37. unsigned short encoder_delay;
  38. unsigned short padding;
  39. uint8_t encoding_method;
  40. uint8_t tag_revision;
  41. uint8_t abr_bitrate;
  42. uint32_t music_length;
  43. uint16_t music_crc;
  44. uint16_t tag_crc;
  45. };
  46. enum
  47. {
  48. ENCODING_METHOD_LAME = 0,
  49. ENCODING_METHOD_CBR = 1,
  50. ENCODING_METHOD_ABR = 2,
  51. ENCODING_METHOD_VBR1 = 3,
  52. ENCODING_METHOD_VBR2 = 4,
  53. ENCODING_METHOD_VBR3 = 5,
  54. ENCODING_METHOD_VBR4 = 6,
  55. ENCODING_METHOD_CBR_2PASS = 8,
  56. ENCODING_METHOD_ABR_2PASS = 9,
  57. };
  58. int ReadLAMEInfo(const MPEGHeader &frame, const uint8_t *buffer, LAMEInfo *lameInfo);