Skip to content

Commit

Permalink
Include size, version, and flags in FullBox
Browse files Browse the repository at this point in the history
super().generate_fields() will not yield anything from the super
function; replace them with `yield from super().generate_fields()`.
  • Loading branch information
amarghosh committed Mar 25, 2024
1 parent d65b95f commit 7a31cd8
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "mp4viewer"
version = "0.1.1"
version = "0.1.2"
authors = [
{ name="Amarghosh Vadakkoot", email="myfirstname@gmail.com" },
]
Expand Down
6 changes: 3 additions & 3 deletions src/mp4viewer/isobmff/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, <optional display 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)

Expand All @@ -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}")

Expand All @@ -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))
Expand Down
8 changes: 4 additions & 4 deletions src/mp4viewer/isobmff/cenc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand All @@ -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)


Expand Down
8 changes: 4 additions & 4 deletions src/mp4viewer/isobmff/flv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 "<empty>")
Expand Down Expand Up @@ -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:
Expand Down
14 changes: 7 additions & 7 deletions src/mp4viewer/isobmff/fragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)


Expand Down Expand Up @@ -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)
Expand Down
46 changes: 23 additions & 23 deletions src/mp4viewer/isobmff/movie.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)

Expand All @@ -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)


Expand All @@ -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)
Expand All @@ -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 "<empty>")

Expand All @@ -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)


Expand Down Expand Up @@ -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}")
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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)


Expand All @@ -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)

Expand All @@ -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)


Expand All @@ -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)


Expand All @@ -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])
Expand All @@ -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 (
Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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:
Expand All @@ -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)
Expand All @@ -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)


Expand All @@ -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",
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 7a31cd8

Please sign in to comment.