Skip to content

Clarity Around Aux Offset Encoding #123

@XAMPPRocky

Description

@XAMPPRocky

Reading through the spec for encoding, I'm unsure how you would correctly calculate an offset for aux without specifying it manually or jumping through a number of hoops if you're assuming meta and main have no fixed size.

If you want to encode the aux section directly at the end of main and want to find what offset to put it in meta, you first need the encoded version of meta.

However since we have variable length integer encoding, the offset at which you encode meta is dependent on the length of the meta + main section + aux_region_offset, which would also change the length of the encoding, which would affect aux_region_offset. Adding the offset could be between 2–4 bytes of extra encoding depending on the amount of data and figuring out when it would cross that threshold is challenging.

I feel like there could be something in the spec that makes this process easier.

Example:

section length (bytes)
Meta (without aux_region_offset) 1
Main 3
Total 4

aux_region_offset 6 (2 bytes)

section length (bytes)
Meta (without aux_region_offset) 32
Main 220
Total 252

aux_region_offset 255 (3 bytes)

section length (bytes)
Meta (without aux_region_offset) 508
Main 512
Total 1024

aux_region_offset 1028 (4 bytes)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions