The data following the 16-bit index is compressed using run length encoded (RLE) format. The C28x uses a simple run length encoding that can be decompressed using the following algorithm:
- Read the first 16 bits and assign it as the delimiter (D).
- Read the next 16 bits (B).
- If B != D, copy B to the output buffer and go to step 2.
- Read the next 16 bits (L).
- If L > 0 and L < 4 copy D to the output buffer L times. Go to step 2.
- If L = 4 read the next 16 bits (B'). Copy B' to the output buffer L times. Go to step 2.
- If L == 0, then read the next 16 bits (L):
- If L == 0, then we've reached the end of the data, so go to step 10.
- If L is the most significant 16 bits of the 32-bit run length, save it as L.hi and read the next 16 bits, which are the least significant 16 bits of the 32-bit run length, L.lo. Concatenate L.hi with L.lo to form the 32-bit run length L.
- Read the next 16-bits, the repeat character (C).
- Copy C to the output buffer L times. Go to step 2.
- End of processing.
The RLE handler function in the TI toolchain is called _ _TI_decompress_rle.