riff.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #ifndef PAL_RIFF_H
  2. #define PAL_RIFF_H
  3. #include <stdint.h>
  4. typedef struct RIFFHeader
  5. {
  6. uint32_t signature; /* 'RIFF' */
  7. uint32_t length; /* Total length minus eight, little-endian */
  8. uint32_t type; /* 'WAVE', 'AVI ', ... */
  9. } RIFFHeader;
  10. typedef struct RIFFChunkHeader
  11. {
  12. uint32_t type; /* 'fmt ', 'hdrl', 'movi' and so on */
  13. uint32_t length; /* Total chunk length minus eight, little-endian */
  14. } RIFFChunkHeader;
  15. typedef struct RIFFChunk
  16. {
  17. RIFFChunkHeader header;
  18. uint8_t data[1];
  19. } RIFFChunk;
  20. typedef struct RIFFListHeader
  21. {
  22. uint32_t signature; /* 'LIST' */
  23. uint32_t length; /* Total list length minus eight, little-endian */
  24. uint32_t type; /* 'fmt ', 'hdrl', 'movi' and so on */
  25. } RIFFListHeader;
  26. typedef union RIFFBlockHeader
  27. {
  28. struct {
  29. uint32_t type;
  30. uint32_t length;
  31. };
  32. RIFFChunkHeader chunk;
  33. RIFFListHeader list;
  34. } RIFFBlockHeader;
  35. typedef struct WAVEFormatPCM
  36. {
  37. uint16_t wFormatTag; /* format type */
  38. uint16_t nChannels; /* number of channels (i.e. mono, stereo, etc.) */
  39. uint32_t nSamplesPerSec; /* sample rate */
  40. uint32_t nAvgBytesPerSec; /* for buffer estimation */
  41. uint16_t nBlockAlign; /* block size of data */
  42. uint16_t wBitsPerSample;
  43. } WAVEFormatPCM;
  44. typedef struct WAVEFormatEx
  45. {
  46. WAVEFormatPCM format;
  47. uint16_t cbSize;
  48. } WAVEFormatEx;
  49. typedef struct AVIMainHeader
  50. {
  51. uint32_t dwMicroSecPerFrame; // frame display rate (or 0)
  52. uint32_t dwMaxBytesPerSec; // max. transfer rate
  53. uint32_t dwPaddingGranularity; // pad to multiples of this size
  54. #define AVIF_HASINDEX 0x00000010 // Index at end of file?
  55. #define AVIF_MUSTUSEINDEX 0x00000020
  56. #define AVIF_ISINTERLEAVED 0x00000100
  57. uint32_t dwFlags; // the ever-present flags
  58. uint32_t dwTotalFrames; // # frames in file
  59. uint32_t dwInitialFrames;
  60. uint32_t dwStreams;
  61. uint32_t dwSuggestedBufferSize;
  62. uint32_t dwWidth;
  63. uint32_t dwHeight;
  64. uint32_t dwReserved[4];
  65. } AVIMainHeader;
  66. typedef struct AVIStreamHeader
  67. {
  68. uint32_t fccType;
  69. uint32_t fccHandler;
  70. uint32_t dwFlags;
  71. uint16_t wPriority;
  72. uint16_t wLanguage;
  73. uint32_t dwInitialFrames;
  74. uint32_t dwScale;
  75. uint32_t dwRate; /* dwRate / dwScale == samples/second */
  76. uint32_t dwStart;
  77. uint32_t dwLength; /* In units above... */
  78. uint32_t dwSuggestedBufferSize;
  79. uint32_t dwQuality;
  80. uint32_t dwSampleSize;
  81. uint16_t rcFrame[4];
  82. } AVIStreamHeader;
  83. typedef struct BitmapInfoHeader
  84. {
  85. uint32_t biSize;
  86. uint32_t biWidth;
  87. uint32_t biHeight;
  88. uint16_t biPlanes;
  89. uint16_t biBitCount;
  90. uint32_t biCompression;
  91. uint32_t biSizeImage;
  92. uint32_t biXPelsPerMeter;
  93. uint32_t biYPelsPerMeter;
  94. uint32_t biClrUsed;
  95. uint32_t biClrImportant;
  96. } BitmapInfoHeader;
  97. #define RIFF_RIFF (((uint32_t)'R') | (((uint32_t)'I') << 8) | (((uint32_t)'F') << 16) | (((uint32_t)'F') << 24))
  98. #define RIFF_WAVE (((uint32_t)'W') | (((uint32_t)'A') << 8) | (((uint32_t)'V') << 16) | (((uint32_t)'E') << 24))
  99. #define WAVE_fmt (((uint32_t)'f') | (((uint32_t)'m') << 8) | (((uint32_t)'t') << 16) | (((uint32_t)' ') << 24))
  100. #define WAVE_data (((uint32_t)'d') | (((uint32_t)'a') << 8) | (((uint32_t)'t') << 16) | (((uint32_t)'a') << 24))
  101. #define RIFF_AVI (((uint32_t)'A') | (((uint32_t)'V') << 8) | (((uint32_t)'I') << 16) | (((uint32_t)' ') << 24))
  102. #define AVI_hdrl (((uint32_t)'h') | (((uint32_t)'d') << 8) | (((uint32_t)'r') << 16) | (((uint32_t)'l') << 24))
  103. #define AVI_strl (((uint32_t)'s') | (((uint32_t)'t') << 8) | (((uint32_t)'r') << 16) | (((uint32_t)'l') << 24))
  104. #define AVI_strh (((uint32_t)'s') | (((uint32_t)'t') << 8) | (((uint32_t)'r') << 16) | (((uint32_t)'h') << 24))
  105. #define AVI_strf (((uint32_t)'s') | (((uint32_t)'t') << 8) | (((uint32_t)'r') << 16) | (((uint32_t)'f') << 24))
  106. #define AVI_avih (((uint32_t)'a') | (((uint32_t)'v') << 8) | (((uint32_t)'i') << 16) | (((uint32_t)'h') << 24))
  107. #define AVI_LIST (((uint32_t)'L') | (((uint32_t)'I') << 8) | (((uint32_t)'S') << 16) | (((uint32_t)'T') << 24))
  108. #define AVI_movi (((uint32_t)'m') | (((uint32_t)'o') << 8) | (((uint32_t)'v') << 16) | (((uint32_t)'i') << 24))
  109. #define AVI_01wb (((uint32_t)'0') | (((uint32_t)'1') << 8) | (((uint32_t)'w') << 16) | (((uint32_t)'b') << 24))
  110. #define AVI_00dc (((uint32_t)'0') | (((uint32_t)'0') << 8) | (((uint32_t)'d') << 16) | (((uint32_t)'c') << 24))
  111. #define AVI_00db (((uint32_t)'0') | (((uint32_t)'0') << 8) | (((uint32_t)'d') << 16) | (((uint32_t)'b') << 24))
  112. #define AVI_rec (((uint32_t)'r') | (((uint32_t)'e') << 8) | (((uint32_t)'c') << 16) | (((uint32_t)' ') << 24))
  113. #define AVI_JUNK (((uint32_t)'J') | (((uint32_t)'U') << 8) | (((uint32_t)'N') << 16) | (((uint32_t)'K') << 24))
  114. #define AVI_vids (((uint32_t)'v') | (((uint32_t)'i') << 8) | (((uint32_t)'d') << 16) | (((uint32_t)'s') << 24))
  115. #define AVI_auds (((uint32_t)'a') | (((uint32_t)'u') << 8) | (((uint32_t)'d') << 16) | (((uint32_t)'s') << 24))
  116. #define VIDS_MSVC (((uint32_t)'M') | (((uint32_t)'S') << 8) | (((uint32_t)'V') << 16) | (((uint32_t)'C') << 24))
  117. #define VIDS_msvc (((uint32_t)'m') | (((uint32_t)'s') << 8) | (((uint32_t)'v') << 16) | (((uint32_t)'c') << 24))
  118. #endif