From 7a31cd87e8f6ded5539f2eae509f75c98de1a140 Mon Sep 17 00:00:00 2001 From: Amarghosh Vadakkoot Date: Mon, 25 Mar 2024 23:31:46 +0000 Subject: [PATCH] Include size, version, and flags in FullBox super().generate_fields() will not yield anything from the super function; replace them with `yield from super().generate_fields()`. --- pyproject.toml | 2 +- src/mp4viewer/isobmff/box.py | 6 ++-- src/mp4viewer/isobmff/cenc.py | 8 +++--- src/mp4viewer/isobmff/flv.py | 8 +++--- src/mp4viewer/isobmff/fragment.py | 14 +++++----- src/mp4viewer/isobmff/movie.py | 46 +++++++++++++++---------------- 6 files changed, 42 insertions(+), 42 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0061d1e..f01182f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "mp4viewer" -version = "0.1.1" +version = "0.1.2" authors = [ { name="Amarghosh Vadakkoot", email="myfirstname@gmail.com" }, ] diff --git a/src/mp4viewer/isobmff/box.py b/src/mp4viewer/isobmff/box.py index 89eb886..d5537f4 100755 --- a/src/mp4viewer/isobmff/box.py +++ b/src/mp4viewer/isobmff/box.py @@ -188,7 +188,7 @@ def generate_fields(self): """ Generator that yields either boxes or tuples. Each tuple shall be or format (name-of-field, actual-value, ). - Subclasses shall call super().generate_fields() from the overriden functions. + Subclasses shall call `yield from super().generate_fields()` from the overriden functions. """ yield ("size", self.size) @@ -207,7 +207,7 @@ def parse(self, parse_ctx): self.consumed_bytes += 4 def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("version", self.version) yield ("flags", f"0x{self.flags:06X}") @@ -227,7 +227,7 @@ def parse(self, parse_ctx): self.consumed_bytes += 4 def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("major brand", self.major_brand) yield ("minor version", self.minor_version) yield ("brands", ",".join(self.brands)) diff --git a/src/mp4viewer/isobmff/cenc.py b/src/mp4viewer/isobmff/cenc.py index c4ecdd3..d9b09e3 100644 --- a/src/mp4viewer/isobmff/cenc.py +++ b/src/mp4viewer/isobmff/cenc.py @@ -28,7 +28,7 @@ def parse(self, parse_ctx): self.default_constant_iv.append(buf.readbyte()) def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() if self.version != 0: yield ("Default crypt byte block", self.default_crypt_byte_block) yield ("Default skip byte block", self.default_skip_byte_block) @@ -62,7 +62,7 @@ def parse(self, parse_ctx): buf.skipbytes(self.data_size) def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("System ID", "0x" + "%x" * 16 % tuple(self.system_id)) if self.version > 0: yield ("KID count", self.kid_count) @@ -84,7 +84,7 @@ def parse(self, parse_ctx): self.scheme_uri = buf.read_cstring(self.size - self.consumed_bytes)[0] def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("Scheme type", self.scheme_type) yield ("Scheme version", f"0x{self.scheme_version:x}") if self.flags & 0x000001: @@ -100,7 +100,7 @@ def parse(self, parse_ctx): self.data_format = buf.readstr(4) def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("Original format", self.data_format) diff --git a/src/mp4viewer/isobmff/flv.py b/src/mp4viewer/isobmff/flv.py index 59ab21e..3c2b265 100644 --- a/src/mp4viewer/isobmff/flv.py +++ b/src/mp4viewer/isobmff/flv.py @@ -38,7 +38,7 @@ def parse(self, parse_ctx): self.global_entries.append((time, eid)) def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("Long IDs", self.long_ids) yield ("Long offsets", self.long_offsets) yield ("Global entries present", self.global_entries_present) @@ -87,7 +87,7 @@ def parse(self, parse_ctx): self.fragment_run_table_entries.append(AdobeFragmentRunTable(buf)) def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("Profile", self.profile) yield ("Live", self.live) yield ("Update", self.update) @@ -127,7 +127,7 @@ def parse(self, parse_ctx): self.segment_entries.append((first_segment, fragments_per_segment)) def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("Quality entry count", self.quality_entry_count) for q in self.quality_url_modifiers: yield ("Quality url modifier", q if len(q) else "") @@ -169,7 +169,7 @@ def parse(self, parse_ctx): ) def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("Timescale", self.timescale) yield ("Quality entry count", self.quality_entry_count) for q in self.quality_url_modifiers: diff --git a/src/mp4viewer/isobmff/fragment.py b/src/mp4viewer/isobmff/fragment.py index 8be4069..088db85 100644 --- a/src/mp4viewer/isobmff/fragment.py +++ b/src/mp4viewer/isobmff/fragment.py @@ -14,7 +14,7 @@ def parse(self, parse_ctx): self.sequence_number = buf.readint32() def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("Sequence number", self.sequence_number) @@ -39,7 +39,7 @@ def parse(self, parse_ctx): self.default_base_is_moof = self.flags & 0x020000 != 0 def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("Track id", self.track_id) if self.flags & 0x000001: yield ("Base data offset", self.base_data_offset) @@ -89,7 +89,7 @@ def parse(self, parse_ctx): self.samples.append((dur, size, flags, off)) def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("Sample count", self.sample_count) if self.flags & 0x000001: yield ("Data offset", self.data_offset) @@ -127,7 +127,7 @@ def parse(self, parse_ctx): self.samples.append(buf.readbyte()) def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() if self.flags & 1: yield ("Aux info type", self.aux_info_type) yield ("Aux info type parameter", self.aux_info_type_parameter) @@ -157,7 +157,7 @@ def parse(self, parse_ctx): self.offsets.append(buf.readint64()) def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() if self.flags & 1: yield ("Aux info type", self.aux_info_type) yield ("Aux info type parameter", self.aux_info_type_parameter) @@ -178,7 +178,7 @@ def parse(self, parse_ctx): self.decode_time = buf.readint32() def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("Base media decode time", self.decode_time) @@ -228,7 +228,7 @@ def parse(self, parse_ctx): def generate_fields(self): # pylint: disable=consider-using-f-string - super().generate_fields() + yield from super().generate_fields() yield ("Reference ID", self.reference_id) yield ("Timescale", self.timescale) yield ("Earliest presentation time", self.earliest_presentation_time) diff --git a/src/mp4viewer/isobmff/movie.py b/src/mp4viewer/isobmff/movie.py index fc56799..8e313b8 100644 --- a/src/mp4viewer/isobmff/movie.py +++ b/src/mp4viewer/isobmff/movie.py @@ -33,7 +33,7 @@ def parse(self, parse_ctx): self.next_track_id = buf.readint32() def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ( "creation time", self.creation_time, @@ -84,7 +84,7 @@ def parse(self, parse_ctx): self.height = buf.readint32() def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ( "creation time", self.creation_time, @@ -134,7 +134,7 @@ def parse(self, parse_ctx): buf.skipbytes(2) def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ( "creation time", self.creation_time, @@ -166,7 +166,7 @@ def parse(self, parse_ctx): self.opcolor.append(buf.readint16()) def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("graphics mode", self.graphicsmode) yield ("opcolor", self.opcolor) @@ -181,7 +181,7 @@ def parse(self, parse_ctx): buf.skipbytes(2) def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("balance", self.balance) @@ -197,7 +197,7 @@ def parse(self, parse_ctx): self.avg_bitrate = buf.readint16() def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("Max PDU size", self.max_pdu_size) yield ("Average PDU size", self.avg_pdu_size) yield ("Max bitrate", self.max_bitrate) @@ -217,7 +217,7 @@ def parse(self, parse_ctx): self.name = buf.read_cstring(self.size - self.consumed_bytes)[0] def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("handler", self.handler) yield ("name", self.name if len(self.name) else "") @@ -233,7 +233,7 @@ def parse(self, parse_ctx): self.consumed_bytes += 8 def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("data reference index", self.data_ref_index) @@ -268,7 +268,7 @@ def parse(self, parse_ctx): self.has_children = True def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("width", self.width) yield ("height", self.height) yield ("horizontal resolution", f"0x{self.hori_resolution:08X}") @@ -303,7 +303,7 @@ def parse(self, parse_ctx): self.has_children = True def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("channel count", self.channel_count) yield ("sample size", self.sample_size) yield ( @@ -338,7 +338,7 @@ def parse(self, parse_ctx): self.has_children = True def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("entry count", self.entry_count) @@ -352,7 +352,7 @@ def parse(self, parse_ctx): self.location = buf.read_cstring()[0] def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("name", self.name) yield ("location", self.location) @@ -366,7 +366,7 @@ def parse(self, parse_ctx): self.location = buf.read_cstring(self.size - self.consumed_bytes)[0] def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("location", self.location) @@ -382,7 +382,7 @@ def parse(self, parse_ctx): self.children.append(parse_ctx.getnextbox(self)) def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("entry count", self.entry_count) @@ -400,7 +400,7 @@ def parse(self, parse_ctx): self.entries.append((count, delta)) def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("entry count", self.entry_count) for entry in self.entries: yield ("sample count", entry[0]) @@ -422,7 +422,7 @@ def parse(self, parse_ctx): self.entries.append((first, samples_per_chunk, sdix)) def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("entry count", self.entry_count) if self.entry_count > 10: yield ( @@ -446,7 +446,7 @@ def parse(self, parse_ctx): self.entries = [buf.readint32() for i in range(self.entry_count)] def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("entry count", self.entry_count) yield ("chunk offsets", self.entries) @@ -461,7 +461,7 @@ def parse(self, parse_ctx): self.entries = [buf.readint32() for i in range(self.entry_count)] def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("entry count", self.entry_count) yield ("sample numbers", self.entries) @@ -480,7 +480,7 @@ def parse(self, parse_ctx): self.entries = [] def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("sample size", self.sample_size) yield ("sample count", self.sample_count) if self.sample_size == 0: @@ -502,7 +502,7 @@ def parse(self, parse_ctx): buf.readbits(4) def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("field size", self.field_size) yield ("sample count", self.sample_count) yield ("entries", self.entries) @@ -520,7 +520,7 @@ def parse(self, parse_ctx): self.fragment_duration = buf.readint32() def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("Fragment duration", self.fragment_duration) @@ -537,7 +537,7 @@ def parse(self, parse_ctx): self.default_sample_flags = buf.readint32() def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("Track ID", self.track_id) yield ( "Default sample description index", @@ -589,7 +589,7 @@ def parse(self, parse_ctx): self.has_children = False def generate_fields(self): - super().generate_fields() + yield from super().generate_fields() yield ("Confiuration level", self.configuration_level) yield ("Profile", self.profile) yield ("Profile compatibility", self.profile_compatibility)