Skip to content

Commit

Permalink
Merge pull request #65 from DenizUgur/fix-construct-boxes
Browse files Browse the repository at this point in the history
Fixes for `boxes.py` checks
  • Loading branch information
podborski authored Sep 1, 2023
2 parents 5ef2d49 + 021c230 commit d452d31
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions src/construct/boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,20 @@ def main():
for container in _box.containers:
if isinstance(container, dict):
if "type" in container:
if container["type"] not in [_box.type for _box in all_boxes]:
# Ignore '*'
if container["type"] == "*":
continue
buffer.append(f"{container['type']}")
# If type is already in all_boxes, skip
if container["type"] in [_box.type for _box in all_boxes]:
continue

# If type is in TYPE_HIERARCHY, skip
if container["type"] in TYPE_HIERARCHY:
continue

# If type is *, skip
if container["type"] == "*":
continue

# Could not find the type
buffer.append(f"{container['type']}")

if len(buffer) > 0:
logger.error(f"Unknown types ({len(set(buffer))}): {set(sorted(buffer))}")
Expand Down Expand Up @@ -260,12 +269,22 @@ def main():
if _box.type == "":
buffer.append(f"{_box.fourcc} ({_box.type})")

# FIXME: This should be an error
if len(buffer) > 0:
logger.warning(
logger.error(
f"Boxes with empty type ({len(set(buffer))}): {set(sorted(buffer))}"
)

# Show boxes with empty fourcc
buffer = []
for _box in all_boxes:
if _box.incomplete:
continue
if _box.fourcc == "":
buffer.append(f"{_box.fourcc} ({_box.type})")

if len(buffer) > 0:
logger.error(f"There are {len(set(buffer))} box(es) with empty fourcc")

# Show duplicates (same fourcc)
buffer = []
for _box in all_boxes:
Expand Down

0 comments on commit d452d31

Please sign in to comment.