You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

183 lines
4.3KB

  1. #ifndef _mov_atom_h_
  2. #define _mov_atom_h_
  3. #include <stdint.h>
  4. #include <stddef.h>
  5. #define N_BRAND 8
  6. struct mov_ftyp_t
  7. {
  8. uint32_t major_brand;
  9. uint32_t minor_version;
  10. uint32_t compatible_brands[N_BRAND];
  11. int brands_count;
  12. };
  13. // A.4 Temporal structure of the media (p148)
  14. // The movie, and each track, has a timescale.
  15. // This defines a time axis which has a number of ticks per second
  16. struct mov_mvhd_t
  17. {
  18. // FullBox
  19. uint32_t version : 8;
  20. uint32_t flags : 24;
  21. uint32_t timescale; // time-scale for the entire presentation, the number of time units that pass in one second
  22. uint64_t duration; // default UINT64_MAX(by timescale)
  23. uint64_t creation_time; // seconds sine midnight, Jan. 1, 1904, UTC
  24. uint64_t modification_time; // seconds sine midnight, Jan. 1, 1904, UTC
  25. uint32_t rate;
  26. uint16_t volume; // fixed point 8.8 number, 1.0 (0x0100) is full volume
  27. //uint16_t reserved;
  28. //uint32_t reserved2[2];
  29. int32_t matrix[9]; // u,v,w
  30. //int32_t pre_defined[6];
  31. uint32_t next_track_ID;
  32. };
  33. enum
  34. {
  35. MOV_TKHD_FLAG_TRACK_ENABLE = 0x01,
  36. MOV_TKHD_FLAG_TRACK_IN_MOVIE = 0x02,
  37. MOV_TKHD_FLAG_TRACK_IN_PREVIEW = 0x04,
  38. };
  39. struct mov_tkhd_t
  40. {
  41. // FullBox
  42. uint32_t version : 8;
  43. uint32_t flags : 24; // MOV_TKHD_FLAG_XXX
  44. uint32_t track_ID; // cannot be zero
  45. uint64_t creation_time; // seconds sine midnight, Jan. 1, 1904, UTC
  46. uint64_t modification_time; // seconds sine midnight, Jan. 1, 1904, UTC
  47. uint64_t duration; // default UINT64_MAX(by Movie Header Box timescale)
  48. //uint32_t reserved;
  49. //uint32_t reserved2[2];
  50. int16_t layer;
  51. int16_t alternate_group;
  52. int16_t volume; // fixed point 8.8 number, 1.0 (0x0100) is full volume
  53. //uint16_t reserved;
  54. int32_t matrix[9]; // u,v,w
  55. uint32_t width; // fixed-point 16.16 values
  56. uint32_t height; // fixed-point 16.16 values
  57. };
  58. struct mov_mdhd_t
  59. {
  60. // FullBox
  61. uint32_t version : 8;
  62. uint32_t flags : 24;
  63. uint32_t timescale; // second
  64. uint64_t duration; // default UINT64_MAX(by timescale)
  65. uint64_t creation_time; // seconds sine midnight, Jan. 1, 1904, UTC
  66. uint64_t modification_time; // seconds sine midnight, Jan. 1, 1904, UTC
  67. uint32_t pad : 1;
  68. uint32_t language : 15;
  69. uint32_t pre_defined : 16;
  70. };
  71. struct mov_sample_entry_t
  72. {
  73. uint16_t data_reference_index; // ref [dref] Data Reference Boxes
  74. uint8_t object_type_indication; // H.264/AAC MOV_OBJECT_XXX (DecoderConfigDescriptor)
  75. uint8_t stream_type; // MP4_STREAM_XXX
  76. uint8_t* extra_data; // H.264 sps/pps
  77. int extra_data_size;
  78. union
  79. {
  80. struct mov_bitrate_t
  81. {
  82. uint32_t bufferSizeDB;
  83. uint32_t maxBitrate;
  84. uint32_t avgBitrate;
  85. } bitrate;
  86. //struct mov_uri_t
  87. //{
  88. // char uri[256];
  89. //} uri;
  90. // visual
  91. struct mov_visual_sample_t
  92. {
  93. uint16_t width;
  94. uint16_t height;
  95. uint32_t horizresolution; // 0x00480000 - 72dpi
  96. uint32_t vertresolution; // 0x00480000 - 72dpi
  97. uint16_t frame_count; // default 1
  98. uint16_t depth; // 0x0018
  99. struct mov_pixel_aspect_ratio_t
  100. {
  101. uint32_t h_spacing;
  102. uint32_t v_spacing;
  103. } pasp;
  104. } visual;
  105. struct mov_audio_sample_t
  106. {
  107. uint16_t channelcount; // default 2
  108. uint16_t samplesize; // default 16
  109. uint32_t samplerate; // { default samplerate of media } << 16
  110. } audio;
  111. } u;
  112. };
  113. struct mov_stsd_t
  114. {
  115. struct mov_sample_entry_t *current; // current entry, read only
  116. struct mov_sample_entry_t *entries;
  117. uint32_t entry_count;
  118. };
  119. struct mov_stts_t
  120. {
  121. uint32_t sample_count;
  122. uint32_t sample_delta; // in the time-scale of the media
  123. };
  124. struct mov_stsc_t
  125. {
  126. uint32_t first_chunk;
  127. uint32_t samples_per_chunk;
  128. uint32_t sample_description_index;
  129. };
  130. struct mov_elst_t
  131. {
  132. uint64_t segment_duration; // by Movie Header Box timescale
  133. int64_t media_time;
  134. int16_t media_rate_integer;
  135. int16_t media_rate_fraction;
  136. };
  137. struct mov_trex_t
  138. {
  139. // uint32_t track_ID;
  140. uint32_t default_sample_description_index;
  141. uint32_t default_sample_duration;
  142. uint32_t default_sample_size;
  143. uint32_t default_sample_flags;
  144. };
  145. struct mov_tfhd_t
  146. {
  147. uint32_t flags;
  148. // uint32_t track_ID;
  149. uint64_t base_data_offset;
  150. uint32_t sample_description_index;
  151. uint32_t default_sample_duration;
  152. uint32_t default_sample_size;
  153. uint32_t default_sample_flags;
  154. };
  155. #endif /* !_mov_atom_h_ */