This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
notes:discrete:fall2022:projects:rle1 [2022/09/29 15:17] – abarbcal | notes:discrete:fall2022:projects:rle1 [2022/10/06 15:38] (current) – Added info about compression ratio. bolsen1 | ||
---|---|---|---|
Line 4: | Line 4: | ||
This time we will be encoding and decoding similar data focusing on more than one byte. | 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) Data Compression Algorithm | ||
Line 15: | Line 13: | ||
=====SPECIFICATIONS===== | =====SPECIFICATIONS===== | ||
+ | |||
+ | |||
+ | 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, | *Our task is to ask questions on Discord or in class and document our findings on this wiki page collaboratively, | ||
*For anybody interested in editing the wiki page, here is the dokuwiki user guide: https:// | *For anybody interested in editing the wiki page, here is the dokuwiki user guide: https:// | ||
- | ====CUSTOMIZATION: variable stride==== | + | |
+ | |||
+ | |||
+ | =====DATA HEADER SPECIFICATIONS===== | ||
+ | (mostly the same as rle0) | ||
+ | |||
+ | Header Format: | ||
+ | |||
+ | byte 0: 0x72\\ | ||
+ | byte 1: 0x6c\\ | ||
+ | byte 2: 0x65\\ | ||
+ | byte 3: 0x58\\ | ||
+ | byte 4: 0x20\\ | ||
+ | byte 5: 0x52\\ | ||
+ | byte 6: 0x4c\\ | ||
+ | byte 7: 0x45\\ | ||
+ | byte 8: 0x00 (reserved)\\ | ||
+ | byte 9: 0x02 (version)\\ | ||
+ | byte 10: 0x(stride value) -- changes depending on input\\ | ||
+ | byte 11: 0xArgv The length of the source file name, not including NULL terminator\\ | ||
+ | (how many characters in Argv - 1)\\ | ||
+ | byte 12: The name of the source file, not including the NULL terminator\\ | ||
+ | ====CUSTOMISATION: variable stride==== | ||
+ | The stride will determine the workings of the the encoding/ | ||
=====PROGRAM===== | =====PROGRAM===== | ||
+ | |||
+ | Encode program will take two arguments: | ||
+ | <cli> | ||
+ | ./encode INFILE | ||
+ | | ||
+ | |||
+ | ./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 '' | ||
+ | |||
+ | 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 '' | ||
+ | <cli> | ||
+ | ./decode INFILE | ||
+ | | ||
+ | |||
+ | ./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 '' | ||
+ | |||
+ | 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, | ||
+ | |||
+ | The decoder should be able to read the header and find out the stride and should decode the provided file accordingly. | ||
=====OUTPUT SPECIFICATIONS===== | =====OUTPUT SPECIFICATIONS===== | ||
+ | |||
+ | Just like what we did in rle0, the rle1's encoder should output the original file's length, the encoded file length, followed by the compression ratio. The output is not strict, as long as you have the correct input file length, output file length, and compression ratio. The compression ratio can be calculated by the following equation: ' | ||
+ | |||
+ | Example: | ||
+ | Input File length: 100 | ||
+ | | ||
+ | | ||
=====VERIFICATION===== | =====VERIFICATION===== | ||
+ | **NOTE** Verification using ./check may not work. If this is the case, then run manual checks. To do this, run the sample and use the stride that is in the header of the sample output you are comparing to (Byte 10). The stride used is also in the file name. | ||
+ | |||
+ | To run the check file provided to you when you grabbed the project, run ./check (linux-based system, may vary on different OS). | ||
+ | |||
+ | You can also manually verify by encoding/ |