Some formats store an absolute position in a header and place the actual data later in the file. Use offsetRef to point a field’s offset() to a previously decoded numeric field in the same class. The source field name must be prefixed with $.
offset() (booleans use byteOffset/bitOffset, not supported).offset and offsetRef are provided, offsetRef takes precedence (dynamic offset overrides static).offset or offsetRef must be specified; otherwise resolving fails.public class Packet {
@UInt16Type(offset = 0)
int payloadPos;
// Read 3 bytes starting at dynamic offset = payloadPos
@BinaryType(offsetRef = "$payloadPos", length = 3)
byte[] payload;
}