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)
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:
aux_region_offset6 (2 bytes)aux_region_offset255 (3 bytes)aux_region_offset1028 (4 bytes)