2.2.4.1.1.3.1.1.2 CLEARCODEC_SUBCODEC_RLEX_SEGMENT
The CLEARCODEC_SUBCODEC_RLEX_SEGMENT structure contains a collection of encoded palette indexes. This encoding exploits the fact that a collection of palette indexes can consist of the following:
Repeated values
Sequences of values that monotonically increase by 1
A palette index that repeats N times is called a "run of length N" (for example, 0x03, 0x03 is a run of length 2), while a sequence of palette indexes that monotonically increase by 1 is called a "suite" (0x04, 0x05, 0x06 is a suite with a stopping value of 0x06 and a depth of 3). In the specification for the CLEARCODEC_SUBCODEC_RLEX_SEGMENT structure, the run length factor fields (runLengthFactor1, runLengthFactor2, and runLengthFactor3) represent the number of times a starting color (defined by the stopIndex and suiteDepth fields) repeats before a suite (also defined by the stopIndex and suiteDepth fields) begins.
|
|
|
|
|
|
|
|
|
|
1 |
|
|
|
|
|
|
|
|
|
2 |
|
|
|
|
|
|
|
|
|
3 |
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
stopIndex (variable) |
|||||||||||||||||||||||||||||||
... |
|||||||||||||||||||||||||||||||
... |
|||||||||||||||||||||||||||||||
suiteDepth (variable) |
|||||||||||||||||||||||||||||||
... |
|||||||||||||||||||||||||||||||
... |
|||||||||||||||||||||||||||||||
runLengthFactor1 |
runLengthFactor2 (optional) |
runLengthFactor3 (optional) |
|||||||||||||||||||||||||||||
... |
stopIndex (variable): A variable number of bits (maximum 7 bits) that defines an unsigned integer. The number of bits is determined by the paletteCount field of the encapsulating CLEARCODEC_SUBCODEC_RLEX (section 2.2.4.1.1.3.1.1) structure and the sum of the number of bits in this field and the suiteDepth field MUST equal 8 (the bits in the stopIndex field are present in the least significant bits of the containing byte). The stopIndex field specifies the position of an RLEX_RGB_TRIPLET (section 2.2.4.1.1.3.1.1.1) structure in the paletteEntries field of the encapsulating CLEARCODEC_SUBCODEC_RLEX structure. This RLEX_RGB_TRIPLET structure is referred to as stopColor.
suiteDepth (variable): A variable number of bits (maximum 8 bits) that defines an unsigned integer. The sum of the number of bits in this field and the stopIndex field MUST equal 8, and the bits in the suiteDepth field are present in the most significant bits of the containing byte. The suiteDepth field specifies the number of consecutive indexes encoded in the current suite. Each index represents one pixel preceding the stopIndex and starting from stopIndex – suiteDepth (referred to as startIndex). The startIndex value specifies the position of an RLEX_RGB_TRIPLET structure (referred to as startColor) in the paletteEntries field of the encapsulating CLEARCODEC_SUBCODEC_RLEX structure.
runLengthFactor1 (1 byte): An 8-bit unsigned integer. If the value of the runLengthFactor1 field is less than 255 (0xFF), the runLengthFactor2 and runLengthFactor3 fields MUST NOT be present and the startColor value MUST be applied to the next runLengthFactor1 pixels. If the value of the runLengthFactor1 field equals 255 (0xFF), the runLengthFactor2 field MUST be present, and the run length is calculated from the runLengthFactor2 field.
runLengthFactor2 (2 bytes, optional): An optional 16-bit unsigned integer. If the value of the runLengthFactor2 field is less than 65,535 (0xFFFF), the runLengthFactor3 field MUST NOT be present, and the startColor value MUST be applied to the next runLengthFactor2 pixels. If the value of the runLengthFactor2 field equals 65,535 (0xFFFF), the runLengthFactor3 field MUST be present, and the run length is calculated from the runLengthFactor3 field.
runLengthFactor3 (4 bytes, optional): An optional 32-bit unsigned integer. If this field is present, it contains the run length. The startColor value MUST be applied to the next runLengthFactor3 pixels. This field SHOULD NOT be used if the run length is smaller than 65,535 (0xFFFF).