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

RIFX, nested structs and endianness #1022

Open
rvanlaar opened this issue Mar 24, 2023 · 4 comments
Open

RIFX, nested structs and endianness #1022

rvanlaar opened this issue Mar 24, 2023 · 4 comments
Labels

Comments

@rvanlaar
Copy link

Hello,

I'm working with construct to parse RIFX files for director.
My goal is to create file format documentation and code side by side and browse-able inspection of files, in the same vein as the construct editor.

In short, RIFX is a container format, a header with a count of the assets in the file, followed by a count times repeating struct with the asset type, size, offset in the file. Followed by the actual assets. See [1] for an overview of the format.

First of, is there a way to specify endianness for the whole structure?
RIFX files for windows and classic mac have the same file structure, they differ in endianness,
i.e. XFIR instead of RIFX.

The documentation mentions that nested structs are not supported, only inlines.
I would like to leverage the parsing in construct as much as possible.
Since nested structs aren't available, what is the recommended way to deal with
nested structs?

Are there examples of parsing container formats like these?

[1] https://nosamu.medium.com/a-tour-of-the-adobe-director-file-format-e375d1e063c0

@arekbulski
Copy link
Member

The documentation mentions that nested structs are not supported, only inlines.

Incorrect. Embedding was removed, nesting was never an issue.

You have to make a more precise question for me to be able to answer it.

@rvanlaar
Copy link
Author

You have to make a more precise question for me to be able to answer it.

Can Consts have endianness?

I.e. the FourCC is either RIFX or XFIR. I would like to create one struct that can handle both.

@arekbulski
Copy link
Member

@rvanlaar
Copy link
Author

I'm currently checking out old Quicktime files and I'm having the same issue.
Quicktimes uses a concept called atoms which are arranged in a tree structure.
Every atom has a header which is the following:

size / Int16ub,
type / PaddedString(4, "ascii")

Each type has specific documented fields.
For example an atom with type 'moov' can have subatoms.

size / Int16ub, # 1613
type / PaddedString(4, "ascii"), # moov (contains a list of atoms)
size / Int16ub, # 108
type / PaddedString(4, "ascii"), # mvhd (contains data)
version / Byte(), # the first field
...
preferred_volume  / int16_ub
...
# more fields till 108 bytes are read
size / Int16ub, # 1417
type / PaddingString(4, "ascii") # trak  (contains list of atoms)
size / Int16ub, # 92
type / PaddedString(4, "ascii") # tkhd (contains data)
version / Byte(),  # version fields
...
track_id / Int16ub, 
... 
#etc etc

It looks to me construct works best when the data is known in advance.
Here I need to dynamically read, either a list type atom, or a specific atom struct based on the type.
What's the solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants