Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Encoding of run-length sequences ensures that there is at least one subsegment per scan-line. The control byte described in section 2.2.2.5.1.2 contains all of the information necessary to decode the sequence bytes.
The process of decoding an encoded sequence of bytes for a color plane using RDP 6.0 RLE is best illustrated with a practical example. Assume that the following bytes are from a color plane in a bitmap that is 6 pixels wide by 3 pixels high.
-
0x13, 0xFF, 0x20, 0xFE, 0xFD, 0x60, 0x01, 0x7D, 0xF5, 0xC2, 0x9A, 0x38, 0x60, 0x01, 0x67, 0x8B, 0xA3, 0x78, 0xAF
The first byte is the control byte of the first segment from the first scan-line.
-
0x13 -> Control byte = 1 RAW value, 3-length RUN of the last raw value 0xFF -> Raw value
Hence, decoding the first segment according to the information in the control byte yields the following:
-
0xFF, 0xFF, 0xFF, 0xFF
Because these values are from the first scan-line, the values are absolute. Shown in unsigned decimal, the values are the following:
-
255, 255, 255, 255
The second segment control byte is the following:
-
0x20
This implies two raw values and a zero-length run, resulting in the following two unsigned decimal absolute values.
-
0xFE, 0xFD
This completes the first scan-line, and all values decoded from this point are deltas and MUST be specially decoded. Before decoding, the deltas MUST be interpreted as unsigned 1-byte values. If the encoded delta value is odd, then decrement it by 1, shift it 1 bit toward the lowest bit, and subtract it from 255. This yields the original absolute value. If the encoded delta value is even, shift it 1 bit toward the lowest bit. This yields the original absolute value.
Examining the third segment yields six raw values and a zero-length run.
-
0x01, 0x7D, 0xF5, 0xC2, 0x9A, 0x38
The deltas MUST be decoded. The unsigned decimal representation of the deltas is as follows.
-
1, 125, 245, 194, 154, 56
Applying the delta transformation to the deltas in the second scan-line yields the following 1-byte unsigned values.
-
255, 193, 133, 97, 77, 28
To compute the final absolute values for the second row, the unsigned, 8-bit delta values are added to the absolute values of the first scan-line using 1-byte arithmetic.
-
Column 1: 255 + 255 = 254 Column 2: 255 + 193 = 192 Column 3: 255 + 133 = 132 Column 4: 255 + 97 = 96 Column 5: 254 + 77 = 75 Column 6: 253 + 28 = 25
This completes the second scan-line, and the final absolute values are the following:
-
254, 192, 132, 96, 75, 25
The third segment has six raw values and a zero-length run.
-
0x01, 0x67, 0x8B, 0xA3, 0x78, 0xAF
The decoded unsigned 8-bit unsigned values representing the final deltas are as follows.
-
255, 204, 186, 174, 60, 168
To compute the final absolute values for the third row, the unsigned 8-bit delta values are added to the absolute values of the second scan-line using 1-byte arithmetic.
-
Column 1: 254 + 255 = 253 Column 2: 192 + 204 = 140 Column 3: 132 + 186 = 62 Column 4: 96 + 174 = 14 Column 5: 75 + 60 = 135 Column 6: 25 + 168 = 193
This completes the second scan-line, and the final absolute values are the following:
-
253, 140, 62, 14, 135, 193
The fully decoded plane is the following:
-
255, 255, 255, 255, 254, 253 254, 192, 132, 96, 75, 25 253, 140, 62, 14, 135, 193