This is an old revision of the document!
Version 2 of our RLE algorithm.
This time we will be encoding and decoding similar data focusing on more than one byte.
Run Length Encoding (RLE) Data Compression Algorithm
Run-length encoding (RLE) algorithm is a lossless compression of runs of data, where repeated sequences of data are stored as a representation of a single data value and its count (how many times it repeats consecutively). RLE encoding is commonly used in JPEG, TIFF, and PDF files, to name a few examples.
Please reference the image below to find the hexadecimal value of the ASCII symbols:
*Our task is to ask questions on Discord or in class and document our findings on this wiki page collaboratively, regarding the functionality of this project.
*For anybody interested in editing the wiki page, here is the dokuwiki user guide: https://www.dokuwiki.org/wiki:syntax#basic_text_formatting -Ash
The stride will determine the workings of the the encoding/decoding process. In rle0, the stride was always 1, thus we had ababcc→ 1a1b1a1b2c, where we compressed runs of a single byte. For rle1, the stride given will determine how many bytes are in each run, for example a stride of two will mean we check for runs of two, which conducts as ababcc→ 2ab1cc. Since the strides are chars, they will hold any value between 1-255, and so each of these values should be valid for run length.
Encode program will take two arguments:
./encode INFILE STRIDE argv[0] argv[1] argv[2] ./encode sample0.txt 2
For ENCODE, the second argument no longer indicates the destination file name, the destination file name is provided by byte 12 of the header ( the name of the original file), and appending .rle
at the end.
For ENCODE, the second argument is now a STRIDE indicator, with a min of 0 and max of 255. No default stride, if no stride is indicated, display error. Store stride on byte 10 of the header.
DECODE program will take only one argument, the encoded .rle
file:
./decode INFILE argv[0] argv[1] ./decode sample0.txt.rle
The decoder should be able to read the header and find out the original filename. Decode will output a file with the name of the original file, without the .rle
.
The decoder should be able to read the header and find out the version of the encoded file. Depending on the version it should decode the provided file accordingly, making it backward-compatible.
The decoder should be able to read the header and find out the stride and should decode the provided file accordingly.