From 22e30cfef9ff0659762e0bf34afb5463ca7a4170 Mon Sep 17 00:00:00 2001 From: klirktag <78051485+klirktag@users.noreply.github.com> Date: Thu, 7 Dec 2023 16:36:07 +0100 Subject: [PATCH] patterns/mp4: Add STBL-box children (#202) add STBL-box children --- patterns/mp4.hexpat | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/patterns/mp4.hexpat b/patterns/mp4.hexpat index 4aeb0c8..ab362fb 100644 --- a/patterns/mp4.hexpat +++ b/patterns/mp4.hexpat @@ -231,12 +231,60 @@ struct SampleTimeToSampleBox: FullBox { u8 unk[while($ != endOffset)]; }; +struct SampleToChunkEntry { + u32 first_chunk; + u32 samples_per_chunk; + u32 sample_description_index; +}; + +struct SampleToChunkBox: FullBox { + u32 entry_count; + SampleToChunkEntry entry_list[this.entry_count]; + u8 unk[while($ != endOffset)]; +}; + +struct ChunkOffsetBox: FullBox { + u32 entry_count; + u32 chunk_offset[this.entry_count]; + u8 unk[while($ != endOffset)]; +}; + +struct SyncSampleBox: FullBox { + u32 entry_count; + u32 sample_number[this.entry_count]; + u8 unk[while($ != endOffset)]; +}; + +struct CompositionOffsetEntryV0 { + u32 sample_count; + u32 sample_offset; +}; + +struct CompositionOffsetEntryV1 { + u32 sample_count; + s32 sample_offset; +}; + +struct CompositionOffsetBox: FullBox { + u32 entry_count; + if(this.version == 0) { + CompositionOffsetEntryV0 entry_list[this.entry_count]; + } + else if (this.version == 1) { + CompositionOffsetEntryV1 entry_list[this.entry_count]; + } +}; + struct SubSampleBoxTable { u32 type = std::mem::read_unsigned($ + 4, 4, std::mem::Endian::Big); match (str(type)) { ("stsd"): SampleDescriptionBox box [[inline]]; ("stts"): SampleTimeToSampleBox box [[inline]]; + ("stsc"): SampleToChunkBox box [[inline]]; + ("stco"): ChunkOffsetBox box [[inline]]; + ("stss"): SyncSampleBox box [[inline]]; + ("ctts"): CompositionOffsetBox box [[inline]]; (_): UnknownBox box [[inline]]; } } [[name(std::format("SubSampleBoxTable({})", box.type))]];