Skip to content

Conversation

@benelgiac
Copy link

Hi,

despite being new to pymp4 and construct, I've decided to give a shot to upgrading to 2.10.60.

It was a useful learning exercise for me but before I spend any more effort on it, I wanted to get in touch with you. I'm sure you have considered this upgrade in the past and you probably have useful pointers or reason to do/not do it.

In this merge request, I've just focused on introducing as few modifications as possible to pymp4 struct definitions, and have all the included tests pass. I've made no efforts to refactor the struct definitions or to investigate new features available in Construct 2.10, nor in making sure the tests cover all changes, nor I have attempted to parse any "real" mp4. For the moment, I just wanted to understand the impacts of such an upgrade.

The removal of "Embedded" (surely done for good reasons) in particular is in my opinion a bit detrimental to the overall usability of the "Box" and "ContainerBox" structs, with the introduction of unnecessary fields whose presence is only needed to handle the struct nesting. You can immediately spot that just from the changes in the tests source code... unless there is a better way to replace it that I did not understand.

As the author, I'm sure you'll immediately know if this is something worth working on or not.

Thanks, let me know if you can


def _parse(self, stream, context, path):
return stream.tell() - self.subcon.sizeof(context)
import pdb;pdb.set_trace()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left in debugging code?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely left it by mistake

Const(Int16ub, 0),
Const(Int32ub, 0),
Const(Int32ub, 0),
Padding(10),
Copy link
Collaborator

@rlaphoenix rlaphoenix Apr 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary change. It is more correct to go with the previous approach if its specific offsets/lengths are reserved. You also shouldn't keep the comment if you make this change.

FileTypeBox = Struct(
"type" / Const(b"ftyp"),
"major_brand" / PaddedString(4, "utf8"),
"major_brand" / PaddedString(4, "ascii"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why replace explicitly "utf8" encodings with ascii? This is done various times in this commit and likely shouldn't be.

Box = Prefixed(Int32ub, Struct(
"offset" / Tell,
"type" / Peek(PaddedString(4, "ascii")),
"box_body" / Switch(this.type, {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why "box_body"? Just leave as-is instead

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After 2 years I can´t remember much of this :) but I remember this being one of the main point. Construct having removed "embedded", it seemed to me the only way to do that would be to create a named "box_body" but of course it's very annoying to use and unnecessary. What would you suggest to avoid this exactly?


class BoxTests(unittest.TestCase):
def test_ftyp_parse(self):
import pdb;pdb.set_trace()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another left-in debug statement?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surely :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants