[Declared in "../apps/kdu_server/kdu_serve.h"]
This object provides the functionality required to encode all information in a JPIP message header which is required to uniquely identify the data-bin to which the message refers. The object is generally passed to kdu_serve::generate_increments which uses these encoding rules to generate messages with correctly encoded headers.
The default implementation encodes data-bin identifiers using a variable number of bytes following the conventions of the JPIP standard (JPEG2000, Part 9, or IS 15444-9). To understand these rules, one must first appreciate the concept of a VBAS (Variable length Byte Aligned Segment). A VBAS is a string of bytes, all but the last of which has a most significant bit of 1. The least significant 7 bits from each of these bytes are concatenated in order to form a 7K bit code, where K is the number of bytes in the VBAS. A JPIP message header has the form:
where each of the 6 items is a VBAS and those items enclosed in square brackets might not always appear. The present object's encode_id function is used to encode the first 3 elements listed above. The Bin-ID is always encoded, and the most significant 2 bits of its 7K bit code identify whether or not each of the Class and CSn elements appear.
In addition to providing the encode_id function, the default implementation also remembers the class code and stream-id values of the most recently encoded message, so that the differential header encoding rules specified in the JPIP standard can be exploited for efficiency. The kdu_serve::generate_increments function calls the decouple member at appropriate points so as to ensure that the differential encoding rules are not applied across boundaries at which the message stream may be broken.
Note that the default implementation described above may be altered by overriding the encode_id or other member functions of the default implementation in an object supplied to kdu_serve::generate_increments.