1
0

avi_header.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. #pragma once
  2. #include <bfc/platform/types.h>
  3. namespace nsavi
  4. {
  5. #pragma pack(push, 1)
  6. static const uint32_t avi_header_flags_has_index = 0x10;
  7. static const uint32_t avi_header_flags_must_use_index = 0x20;
  8. static const uint32_t avi_header_flags_is_interleaved = 0x100;
  9. static const uint32_t avi_header_trust_ck_type = 0x800; // benski> i have no fucking clue
  10. static const uint32_t avi_header_flags_was_capture_file = 0x10000;
  11. static const uint32_t avi_header_flags_copyrighted = 0x20000;
  12. static const uint32_t stream_type_audio = 0x73647561;
  13. static const uint32_t stream_type_video = 0x73646976;
  14. const uint16_t audio_format_pcm = 1;
  15. const uint16_t audio_format_ms_adpcm = 2;
  16. const uint16_t audio_format_alaw = 6;
  17. const uint16_t audio_format_ulaw = 7;
  18. const uint16_t audio_format_ima_adpcm = 17;
  19. const uint16_t audio_format_truespeech = 34;
  20. const uint16_t audio_format_mp2 = 80;
  21. const uint16_t audio_format_mp3 = 85;
  22. const uint16_t audio_format_a52 = 8192;
  23. const uint16_t audio_format_aac = 255;
  24. const uint16_t audio_format_vorbis = 26447;
  25. const uint16_t audio_format_speex = 41225;
  26. const uint16_t audio_format_extensible = 65534; // aka WAVE_FORMAT_EXTENSIBLE
  27. const uint16_t audio_format_dts = 8193;
  28. static uint32_t video_format_rgb = 0;
  29. static uint32_t video_format_rle8 = 1;
  30. static uint32_t video_format_rle4 = 2;
  31. static const uint32_t idx1_flags_keyframe = 0x10;
  32. static const uint32_t idx1_flags_no_duration= 0x100;
  33. struct AVIH
  34. {
  35. uint32_t size_bytes;
  36. uint32_t microseconds_per_frame;
  37. uint32_t max_bytes_per_second;
  38. uint32_t padding_granularity;
  39. uint32_t flags;
  40. uint32_t total_frames;
  41. uint32_t initial_frames;
  42. uint32_t streams;
  43. uint32_t suggested_buffer_size;
  44. uint32_t width;
  45. uint32_t height;
  46. uint8_t reserved[16];
  47. };
  48. struct STRH
  49. {
  50. uint32_t size_bytes;
  51. uint32_t stream_type;
  52. uint32_t fourcc;
  53. uint32_t flags;
  54. uint16_t priority;
  55. uint16_t language;
  56. uint32_t initial_frames;
  57. uint32_t scale;
  58. uint32_t rate;
  59. uint32_t start;
  60. uint32_t length;
  61. uint32_t suggested_buffer_size;
  62. uint32_t quality;
  63. uint32_t sample_size;
  64. int16_t left;
  65. int16_t top;
  66. int16_t right;
  67. int16_t bottom;
  68. };
  69. struct VIDEO_FIELD_DESC
  70. {
  71. uint32_t compressed_height;
  72. uint32_t compressed_width;
  73. uint32_t valid_height;
  74. uint32_t valid_width;
  75. uint32_t valid_x_offset;
  76. uint32_t valid_y_offset;
  77. uint32_t x_offset;
  78. uint32_t valid_y_start_line;
  79. };
  80. struct VPRP
  81. {
  82. uint32_t size_bytes;
  83. uint32_t video_format_token;
  84. uint32_t video_standard;
  85. uint32_t vertical_refresh_rate;
  86. uint32_t horizontal_total;
  87. uint32_t vertical_total;
  88. uint32_t aspect_ratio;
  89. uint32_t frame_width;
  90. uint32_t frame_height;
  91. uint32_t field_info_size;
  92. VIDEO_FIELD_DESC field_info[1];
  93. };
  94. struct STRF
  95. {
  96. uint32_t size_bytes;
  97. };
  98. struct STRD
  99. {
  100. uint32_t size_bytes;
  101. };
  102. struct STRN
  103. {
  104. uint32_t size_bytes;
  105. };
  106. struct DMLH
  107. {
  108. uint32_t size_bytes;
  109. uint32_t total_frames;
  110. };
  111. struct IDX1_INDEX
  112. {
  113. uint32_t chunk_id;
  114. uint32_t flags;
  115. uint32_t offset;
  116. uint32_t chunk_size;
  117. };
  118. struct IDX1
  119. {
  120. uint32_t index_count;
  121. IDX1_INDEX indices[1];
  122. };
  123. static const uint8_t indx_type_master = 0x0;
  124. static const uint8_t indx_type_chunk = 0x1;
  125. static const uint8_t indx_type_data = 0x80;
  126. static const uint8_t indx_subtype_field = 0x1;
  127. struct INDX
  128. {
  129. uint32_t size_bytes;
  130. uint16_t entry_size;
  131. uint8_t index_sub_type;
  132. uint8_t index_type;
  133. uint32_t number_of_entries;
  134. uint32_t chunk_id;
  135. };
  136. struct INDX_MASTER_ENTRY
  137. {
  138. uint64_t offset;
  139. uint32_t index_size;
  140. uint32_t duration;
  141. };
  142. struct AVISUPERINDEX
  143. {
  144. INDX indx;
  145. uint32_t reserved[3];
  146. INDX_MASTER_ENTRY entries[1]; // actual size determined by indx.number_of_entries
  147. };
  148. struct INDX_CHUNK_ENTRY
  149. {
  150. uint32_t offset;
  151. uint32_t size ;// bit 31 is set if this is NOT a keyframe
  152. };
  153. struct AVISTDINDEX
  154. {
  155. INDX indx;
  156. uint64_t base_offset;
  157. uint32_t reserved;
  158. INDX_CHUNK_ENTRY entries[1]; // actual size determined by indx.number_of_entries
  159. };
  160. struct INDX_FIELD_ENTRY
  161. {
  162. uint32_t offset;
  163. uint32_t size; // size of all fields. bit 31 set for NON-keyframes
  164. uint32_t offset_field2; // offset to second field
  165. };
  166. struct AVIFIELDINDEX
  167. {
  168. INDX indx;
  169. uint64_t base_offset;
  170. uint32_t reserved;
  171. INDX_FIELD_ENTRY entries[1]; // actual size determined by indx.number_of_entries
  172. };
  173. struct video_format
  174. {
  175. uint32_t size_bytes;
  176. uint32_t video_format_size_bytes; // redundant, I know
  177. int32_t width;
  178. int32_t height;
  179. uint16_t planes;
  180. uint16_t bits_per_pixel;
  181. uint32_t compression;
  182. uint32_t image_size;
  183. int32_t x_pixels_per_meter;
  184. int32_t y_pixels_per_meter;
  185. uint32_t color_used;
  186. uint32_t color_important;
  187. };
  188. struct audio_format
  189. {
  190. uint32_t size_bytes;
  191. uint16_t format;
  192. uint16_t channels;
  193. uint32_t sample_rate;
  194. uint32_t average_bytes_per_second;
  195. uint16_t block_align;
  196. uint16_t bits_per_sample;
  197. uint16_t extra_size_bytes;
  198. };
  199. struct mp3_format
  200. {
  201. audio_format format;
  202. uint16_t id;
  203. uint32_t flags;
  204. uint16_t block_size;
  205. uint16_t frames_per_block;
  206. uint16_t codec_delay;
  207. };
  208. struct STRL
  209. {
  210. STRH *stream_header;
  211. STRF *stream_format;
  212. STRD *stream_data;
  213. STRN *stream_name;
  214. INDX *stream_index;
  215. VPRP *video_properties;
  216. };
  217. #pragma pack(pop)
  218. }