MP4.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /******************************************************************************/
  2. struct MP4
  3. {
  4. struct Track
  5. {
  6. struct STTS
  7. {
  8. UInt count, delta;
  9. };
  10. struct STSC
  11. {
  12. UInt first_chunk, frames_per_chunk, frame_desc_index;
  13. };
  14. struct Part
  15. {
  16. Long pos;
  17. UInt frames;
  18. UInt frame_duration; Mems<UInt> frame_durations;
  19. UInt frame_size ; Mems<UInt> frame_sizes ;
  20. UInt frameDuration(Int i)C {return InRange(i, frame_durations) ? frame_durations[i] : frame_duration;}
  21. UInt frameSize (Int i)C {return InRange(i, frame_sizes ) ? frame_sizes [i] : frame_size ;}
  22. Long dataSize()C;
  23. };
  24. Int id;
  25. UInt frame_size, channels, sample_rate, time_scale, avg_bit_rate;
  26. Long duration;
  27. Mems<UInt> frame_sizes;
  28. Mems<Long> chunk_offset;
  29. Mems<Byte> decoder_config;
  30. Mems<STTS> stts;
  31. Mems<STSC> stsc;
  32. Mems<Part> parts;
  33. Int frames()C;
  34. UInt frameRangeSize(Int start, Int end)C;
  35. void frameChunk (Int frame, Int &chunk, Int &chunk_frame)C;
  36. Long chunkOffset(Int i)C;
  37. Long frameOffset(Int i)C;
  38. UInt frameSize (Int i)C;
  39. Long dataSize ()C;
  40. C Part* findPart (Int &frame)C;
  41. Track() {id=-1; frame_size=channels=sample_rate=time_scale=avg_bit_rate=0; duration=-1;}
  42. };
  43. UInt time_scale;
  44. Long duration;
  45. Memc<Track> tracks;
  46. #if EE_PRIVATE
  47. Track* findTrack(Int id);
  48. void zero();
  49. Bool read(File &f, Long max_pos, Track *track, Long moof_pos);
  50. #endif
  51. Bool read(File &f);
  52. MP4();
  53. };
  54. /******************************************************************************/