Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse paperSize in SceneInfo #39

Open
ricklupton opened this issue Dec 3, 2024 · 2 comments · May be fixed by #41
Open

Parse paperSize in SceneInfo #39

ricklupton opened this issue Dec 3, 2024 · 2 comments · May be fixed by #41

Comments

@ricklupton
Copy link
Owner

This commit (Seb-sti1@9505d1d) is the addition of paperSize in the SceneInfo class

On the files that had excess bytes, they were 92, 8, 0, 0, 0, 124, 5, 0, 0, 80, 7, 0, 0 which seems to correspond to :

  • 92 = 5 (index), 12 (TagType.Length4) as read and check by DataSteam.read_tag
  • 8, 0, 0, 0 the size 8 bytes here
  • 124, 5, 0, 0 = 124 + 5 << 4 = 1404 = first
  • 80, 7, 0, 0 = 80 + 7 << 4 = 1872 = second

The first implementation I tried was with the code below as it seemed to be closer to a simple value but given the existence of what appears to be a size I changed it and used TaggedBlockReader.read_subblock. Btw I don't know if it would be better to read size/4 uint32 instead of the hardcoded two.

def read_two_int(self, index: int) -> tuple[int, int]:
    """Read a tagged two 4-byte int."""
    self.data.read_tag(index, TagType.Length4)
    first = self.data.read_uint32()
    second = self.data.read_uint32()
    return first, second


def read_two_int_optional(
        self, index: int, default: tp.Optional[float] = None
) -> tp.Optional[tuple[int, int]]:
    """Read a tagged two 4-byte int."""
    return self._read_optional(self.read_two_int, index, default)

Originally posted by @Seb-sti1 in #34 (comment)

@ricklupton
Copy link
Owner Author

@Seb-sti1 yes please for opening a pull request to add this.

Based on your version here: Seb-sti1@9505d1d

I think the check for bytes_remaining_in_block should be in SceneInfo.from_stream rather than in read_two_int for consistency with the other methods.

And maybe read_int_pair would be a better name but I don't really mind.

@Seb-sti1
Copy link
Contributor

Seb-sti1 commented Dec 4, 2024

Got it, I'll do that as soon as possible (most likely by the end of the week)

Seb-sti1 added a commit to Seb-sti1/rmscene that referenced this issue Dec 5, 2024
@Seb-sti1 Seb-sti1 linked a pull request Dec 5, 2024 that will close this issue
Seb-sti1 added a commit to Seb-sti1/rmscene that referenced this issue Dec 5, 2024
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 a pull request may close this issue.

2 participants