<html xmlns="http://www.w3.org/1999/xhtml"><head><meta charset="utf-8"><meta name="generator" content="pdf2htmlEX"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><link rel="stylesheet" href="https://csdnimg.cn/release/download_crawler_static/css/base.min.css"><link rel="stylesheet" href="https://csdnimg.cn/release/download_crawler_static/css/fancy.min.css"><link rel="stylesheet" href="https://csdnimg.cn/release/download_crawler_static/881409/raw.css"><script src="https://csdnimg.cn/release/download_crawler_static/js/compatibility.min.js"></script><script src="https://csdnimg.cn/release/download_crawler_static/js/pdf2htmlEX.min.js"></script><script>try{pdf2htmlEX.defaultViewer = new pdf2htmlEX.Viewer({});}catch(e){}</script><title></title></head><body><div id="sidebar" style="display: none"><div id="outline"></div></div><div id="pf1" class="pf w0 h0" data-page-no="1"><div class="pc pc1 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://csdnimg.cn/release/download_crawler_static/881409/bg1.jpg"><div class="c x0 y1 w2 h2"><div class="t m0 x1 h3 y2 ff1 fs0 fc0 sc0 ls0 ws0">Run Length Encoding compressor program 16 bit header version</div><div class="t m0 x1 h3 y3 ff1 fs0 fc0 sc0 ls0 ws0">Written by Shaun Case 1991 in Borland C++ 2.0</div><div class="t m0 x1 h3 y4 ff1 fs0 fc0 sc0 ls0 ws0"> with sizeof (int) == 2</div><div class="t m0 x1 h3 y5 ff1 fs0 fc0 sc0 ls0 ws0">This program and its source code are Public Domain.</div><div class="t m0 x1 h3 y6 ff1 fs0 fc0 sc0 ls0 ws0">This program should be portable to any machine with</div><div class="t m0 x1 h3 y7 ff1 fs0 fc0 sc0 ls0 ws0">2 byte short ints and 8 bit bytes.</div><div class="t m0 x1 h3 y8 ff1 fs0 fc0 sc0 ls0 ws0">What is run length encoding?</div><div class="t m0 x1 h3 y9 ff1 fs0 fc0 sc0 ls0 ws0">Run Length Encoding, also known as RLE, is a method of compressing data</div><div class="t m0 x1 h3 ya ff1 fs0 fc0 sc0 ls0 ws0">that has a lot of "runs" of bytes (or bits) in it. A "run" is a series</div><div class="t m0 x1 h3 yb ff1 fs0 fc0 sc0 ls0 ws0">of bytes that are all the same. For instance, the string "THIS IS A</div><div class="t m0 x1 h3 yc ff1 fs0 fc0 sc0 ls0 ws0">VEEEEEEEEEEEEEEEEEEEEEEEERY INTERESTING SENTENCE" has a run of 23 'E's</div><div class="t m0 x1 h3 yd ff1 fs0 fc0 sc0 ls0 ws0">in it. This could be compressed in the following manner:</div><div class="t m0 x1 h3 ye ff1 fs0 fc0 sc0 ls0 ws0">THIS IS A V23ERY INTERESTING SENTENCE</div><div class="t m0 x1 h3 yf ff1 fs0 fc0 sc0 ls0 ws0">resulting in a savings of 20 characters. A further savings of one</div><div class="t m0 x1 h3 y10 ff1 fs0 fc0 sc0 ls0 ws0">character can be realized if the sequence "23" is replaced by a single</div><div class="t m0 x1 h3 y11 ff1 fs0 fc0 sc0 ls0 ws0">byte with the value 23.</div><div class="t m0 x1 h3 y12 ff1 fs0 fc0 sc0 ls0 ws0">However, if the text to be encoded is arbitrary, then it may contain</div><div class="t m0 x1 h3 y13 ff1 fs0 fc0 sc0 ls0 ws0">numbers as well as letters, and bytes of all possible values. For this</div><div class="t m0 x1 h3 y14 ff1 fs0 fc0 sc0 ls0 ws0">reason, there must be some way to let the decoder know when a compressed</div><div class="t m0 x1 h3 y15 ff1 fs0 fc0 sc0 ls0 ws0">run is encountered, and when a sequence to be passed straight through is</div><div class="t m0 x1 h3 y16 ff1 fs0 fc0 sc0 ls0 ws0">encountered. For this reason, the following file format was used:</div><div class="t m0 x1 h3 y17 ff1 fs0 fc0 sc0 ls0 ws0">========= tech info =========</div><div class="t m0 x1 h3 y18 ff1 fs0 fc0 sc0 ls0 ws0">16 bit header version.</div><div class="t m0 x1 h3 y19 ff1 fs0 fc0 sc0 ls0 ws0">File format:</div><div class="t m0 x1 h3 y1a ff1 fs0 fc0 sc0 ls0 ws0">13 bytes : original filename, followed by:</div><div class="t m0 x1 h3 y1b ff1 fs0 fc0 sc0 ls0 ws0">[ 16 bit header + data ][ 16 bit header + data ][16 bit header + data ]</div><div class="t m0 x1 h3 y1c ff1 fs0 fc0 sc0 ls0 ws0">etc..</div><div class="t m0 x1 h3 y1d ff1 fs0 fc0 sc0 ls0 ws0">header:</div><div class="t m0 x1 h3 y1e ff1 fs0 fc0 sc0 ls0 ws0">[lo byte][hi byte] ==> turn into 16 bit int ==></div><div class="t m0 x1 h3 y1f ff1 fs0 fc0 sc0 ls0 ws0"> bit 15 : 1 if following byte is a run</div><div class="t m0 x1 h3 y20 ff1 fs0 fc0 sc0 ls0 ws0"> bit 14 - 0 : length of run (max 32767, min 4)</div><div class="t m0 x1 h3 y21 ff1 fs0 fc0 sc0 ls0 ws0">data: 1 byte : which character run consists of</div><div class="t m0 x1 h3 y22 ff1 fs0 fc0 sc0 ls0 ws0">*** OR ***</div><div class="t m0 x1 h3 y23 ff1 fs0 fc0 sc0 ls0 ws0">header:</div><div class="t m0 x1 h3 y24 ff1 fs0 fc0 sc0 ls0 ws0">[lo byte][hi byte] ==> turn into 16 bit int ==></div><div class="t m0 x1 h3 y25 ff1 fs0 fc0 sc0 ls0 ws0"> bit 15 : 0 if following bytes are sequence</div><div class="t m0 x1 h3 y26 ff1 fs0 fc0 sc0 ls0 ws0"> bit 14 - 0 : length of sequence (max 32767)</div><div class="t m0 x1 h3 y27 ff1 fs0 fc0 sc0 ls0 ws0">data: (header & 0x7FFF) bytes of data</div><div class="t m0 x1 h3 y28 ff1 fs0 fc0 sc0 ls0 ws0"> : data bytes copied to output stream unchanged</div><div class="t m0 x1 h3 y29 ff1 fs0 fc0 sc0 ls0 ws0">===============================</div></div></div><div class="pi" data-data='{"ctm":[1.611850,0.000000,0.000000,1.611850,0.000000,0.000000]}'></div></div></body></html>