From 99df77baf2946c09ceb5bd103f28c092d04738bb Mon Sep 17 00:00:00 2001 From: klirktag <78051485+klirktag@users.noreply.github.com> Date: Tue, 14 Nov 2023 00:06:50 +0100 Subject: [PATCH] patterns/mp4: Add childbox support for STBL boxes (#192) * find childboxes in stbl * add implementation for SampleDescriptionBox --- patterns/mp4.hexpat | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/patterns/mp4.hexpat b/patterns/mp4.hexpat index f082aa9..713fba7 100644 --- a/patterns/mp4.hexpat +++ b/patterns/mp4.hexpat @@ -157,6 +157,32 @@ struct VideoMediaHeaderBox : FullBox { u16 opcolor[3]; }; +struct SubSampleDescriptionBox { + u32 type = std::mem::read_unsigned($ + 4, 4, std::mem::Endian::Big); + + match (str(type)) { + (_): UnknownBox box [[inline]]; + } +} [[name(std::format("SubSampleDescriptionBox({})", box.type))]]; + +struct SampleDescriptionBox : FullBox { + u32 entry_count; + SubSampleDescriptionBox box[while($ < endOffset)] [[inline]]; +}; + +struct SubSampleBoxTable { + u32 type = std::mem::read_unsigned($ + 4, 4, std::mem::Endian::Big); + + match (str(type)) { + ("stsd"): SampleDescriptionBox box [[inline]]; + (_): UnknownBox box [[inline]]; + } +} [[name(std::format("SubSampleBoxTable({})", box.type))]]; + +struct SampleBoxTable : BaseBox { + SubSampleBoxTable box[while($ < endOffset)] [[inline]]; +}; + struct SubMediaInformationBox { u32 type = std::mem::read_unsigned($ + 4, 4, std::mem::Endian::Big); @@ -164,6 +190,7 @@ struct SubMediaInformationBox { ("vmhd"): VideoMediaHeaderBox box [[inline]]; ("hdlr"): HandlerBox box [[inline]]; ("dinf"): DataInformationBox box [[inline]]; + ("stbl"): SampleBoxTable box [[inline]]; (_): UnknownBox box [[inline]]; } } [[name(std::format("MediaInformationBox({})", box.type))]]; @@ -172,10 +199,6 @@ struct MediaInformationBox : BaseBox { SubMediaInformationBox box[while($ < endOffset)] [[inline]]; }; -struct SampleBoxTable : FullBox { - SubMediaInformationBox box[while($ < endOffset)] [[inline]]; -}; - struct MediaHeaderBox : FullBox { if (this.version == 1) { u64 creation_time; @@ -199,7 +222,6 @@ struct SubMediaBox { ("mdhd"): MediaHeaderBox box [[inline]]; ("hdlr"): HandlerBox box [[inline]]; ("minf"): MediaInformationBox box [[inline]]; - ("sbtl"): SampleBoxTable box [[inline]]; (_): UnknownBox box [[inline]]; } } [[name(std::format("MediaBox({})", box.type))]];