I need to use run length encoding for compressing data. For a given input byte stream, I need to compute the output by tagging each byte with the number of time the particular byte appears consecutively in the intput stream modulo 255. Examples:
a(repeated 500 times) 255a245a
Note that in the examples above, the number preceding the character is a byte, not multiple bytes. For example, when we write the output for the second input above, we will write four bytes to the output: the first byte with the value 255, the second byte with the value ord(a), the third byte with the value 245, and finally the fourth byte with the value ord(a). That is four bytes, and not 8 bytes like what it appears in the text representation.