<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://moddingwiki.shikadi.net/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Pixenal</id>
	<title>ModdingWiki - User contributions [en-gb]</title>
	<link rel="self" type="application/atom+xml" href="https://moddingwiki.shikadi.net/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Pixenal"/>
	<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/wiki/Special:Contributions/Pixenal"/>
	<updated>2026-05-14T05:48:30Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.11</generator>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=LZSS_compression&amp;diff=10039</id>
		<title>LZSS compression</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=LZSS_compression&amp;diff=10039"/>
		<updated>2021-09-07T14:34:45Z</updated>

		<summary type="html">&lt;p&gt;Pixenal: Fix typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Compression Infobox&lt;br /&gt;
 | Type = Stream&lt;br /&gt;
 | UnitSize = 1-bit&lt;br /&gt;
 | Games =&lt;br /&gt;
   {{Game|J.R.R. Tolkien&#039;s Riders of Rohan}}&lt;br /&gt;
   {{Game|Nomad}}&lt;br /&gt;
   {{Game|Prehistorik}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;LZSS&#039;&#039;&#039; (Lempel-Ziv-Storer-Szymanski) is a dictionary compression algorithm first proposed by James A. Storer and Thomas G. Szymanski in 1982. The method is lossless, and builds upon the existing &#039;&#039;&#039;LZ77&#039;&#039;&#039; technique.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;LZSS&#039;&#039;&#039; makes use of a sliding window just like its predecessor, however differs primarily in its more selective approach to substitution. Where &#039;&#039;&#039;LZ77&#039;&#039;&#039; simply replaces every string it processes, &#039;&#039;&#039;LZSS&#039;&#039;&#039; will only substitute a string with a &amp;quot;length-distance&amp;quot; pair if the size of the string, in bits, exceeds a preset minimum, leaving the string&#039;s symbols as literals if not. This prevents a pair from ever replacing a string whose size is less than its own, and thus avoids such a case from unnecessarily increasing the size of the final output (a problem which can occur in &#039;&#039;&#039;LZ77&#039;&#039;&#039;). As alluded to above, &#039;&#039;&#039;LZSS&#039;&#039;&#039; also does away with the codeword component of &#039;&#039;&#039;LZ77&#039;&#039;&#039;&#039;s &amp;quot;length-distance-codeword&amp;quot; triple, leaving only length and distance. The algorithm also introduces a 1-bit flag which prefixes each element in the code, in order to signify whether the succeeding element is a literal or a &amp;quot;length-distance&amp;quot; pair.&lt;br /&gt;
&lt;br /&gt;
Like &#039;&#039;&#039;LZ77&#039;&#039;&#039;, the length and distance in &#039;&#039;&#039;LZSS&#039;&#039;&#039;&#039;s &amp;quot;length-distance&amp;quot; pair describe the location, within the search buffer, of the string that a particular pair substitutes (with the buffer containing symbols that have already been processed, or decompressed (if decoding)). During the decompression process, the decoder, upon encountering one of these pairs, can, in an informal sense, determine the string to replace said pair with by looking back into the search buffer by the amount described by &amp;quot;distance&amp;quot;, and reading forward by the amount specified by &amp;quot;length&amp;quot;. The string that is read is the string in which to use. It should also be noted that it is sometimes possible, depending on the implementation, for the string being read to pass into the look ahead buffer, that is to say, it is possible for &amp;quot;length&amp;quot; to be longer than &amp;quot;distance&amp;quot;. The process for handling such cases is fairly straightforward however, once the string passes into the look ahead buffer, the decoder would just need to start reading from the symbols that have already been substituted as a part of processing the current pair (kind of like driving the train while placing the tracks).&lt;br /&gt;
&lt;br /&gt;
== Algorithm ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variables:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;size_length&amp;lt;/tt&amp;gt;: Size of length field, in bits&lt;br /&gt;
* &amp;lt;tt&amp;gt;size_distance&amp;lt;/tt&amp;gt;: Size of distance field, in bits&lt;br /&gt;
* &amp;lt;tt&amp;gt;min_len&amp;lt;/tt&amp;gt;: Minimum length of a backreference (at least 2 to break even; 3 is better as it represents a savings of 1 byte)&lt;br /&gt;
* Whether the flag bit is 0 for normal byte, 1 for length-distance pair, or the opposite&lt;br /&gt;
* Whether the length field comes before distance, or distance before length&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Decoding Procedure:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&lt;br /&gt;
    Read one bit as the flag&lt;br /&gt;
    &amp;lt;ul&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;&lt;br /&gt;
        If it&#039;s 1: (or 0 if flags are opposite)&lt;br /&gt;
        &amp;lt;ol style=&amp;quot;list-style-type: lower-alpha;&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;li&amp;gt;Read &amp;lt;tt&amp;gt;size_length&amp;lt;/tt&amp;gt; bits, add &amp;lt;tt&amp;gt;min_len&amp;lt;/tt&amp;gt; to the value, and use it as the LZSS &amp;lt;tt&amp;gt;length&amp;lt;/tt&amp;gt; value&amp;lt;/li&amp;gt;&lt;br /&gt;
          &amp;lt;li&amp;gt;Read &amp;lt;tt&amp;gt;size_distance&amp;lt;/tt&amp;gt; bits, add 1 to the value, and use it as the LZSS &amp;lt;tt&amp;gt;distance&amp;lt;/tt&amp;gt; value&amp;lt;/li&amp;gt;&lt;br /&gt;
          &amp;lt;li&amp;gt;Look back &amp;lt;tt&amp;gt;distance&amp;lt;/tt&amp;gt; bytes in the output data, and copy &amp;lt;tt&amp;gt;length&amp;lt;/tt&amp;gt; bytes to the end of the output data&amp;lt;/li&amp;gt;&lt;br /&gt;
        &amp;lt;/ol&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;&lt;br /&gt;
        Otherwise: (the flag is a 0, or 1 if flags are opposite)&lt;br /&gt;
        &amp;lt;ol style=&amp;quot;list-style-type: lower-roman;&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;li&amp;gt;Read 8 bits, and write them as a byte on the end of the output data&amp;lt;/li&amp;gt;&lt;br /&gt;
        &amp;lt;/ol&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;If there is more input data, go back to step 1&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
[[SkyRoads]] uses a variant of LZSS where the variables can be different for each file, and are stored at the start of the compressed data, as well as allowing two types of length-distance codes in the same file.&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
[[User:Malvineous|Malvineous]] discovered this compression algorithm was used by [[Prehistorik]]. If you find this information helpful in a project you&#039;re working on, please give credit where credit is due.  (A link back to this wiki would be nice too!)&lt;/div&gt;</summary>
		<author><name>Pixenal</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=LZSS_compression&amp;diff=10038</id>
		<title>LZSS compression</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=LZSS_compression&amp;diff=10038"/>
		<updated>2021-09-07T14:32:20Z</updated>

		<summary type="html">&lt;p&gt;Pixenal: Re-add (after some modification) information regarding the use of &amp;quot;length-distance&amp;quot; pairs&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Compression Infobox&lt;br /&gt;
 | Type = Stream&lt;br /&gt;
 | UnitSize = 1-bit&lt;br /&gt;
 | Games =&lt;br /&gt;
   {{Game|J.R.R. Tolkien&#039;s Riders of Rohan}}&lt;br /&gt;
   {{Game|Nomad}}&lt;br /&gt;
   {{Game|Prehistorik}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;LZSS&#039;&#039;&#039; (Lempel-Ziv-Storer-Szymanski) is a dictionary compression algorithm first proposed by James A. Storer and Thomas G. Szymanski in 1982. The method is lossless, and builds upon the existing &#039;&#039;&#039;LZ77&#039;&#039;&#039; technique.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;LZSS&#039;&#039;&#039; makes use of a sliding window just like its predecessor, however differs primarily in its more selective approach to substitution. Where &#039;&#039;&#039;LZ77&#039;&#039;&#039; simply replaces every string it processes, &#039;&#039;&#039;LZSS&#039;&#039;&#039; will only substitute a string with a &amp;quot;length-distance&amp;quot; pair if the size of the string, in bits, exceeds a preset minimum, leaving the string&#039;s symbols as literals if not. This prevents a pair from ever replacing a string whose size is less than its own, and thus avoids such a case from unnecessarily increasing the size of the final output (a problem which can occur in &#039;&#039;&#039;LZ77&#039;&#039;&#039;). As alluded to above, &#039;&#039;&#039;LZSS&#039;&#039;&#039; also does away with the codeword component of &#039;&#039;&#039;LZ77&#039;&#039;&#039;&#039;s &amp;quot;length-distance-codeword&amp;quot; triple, leaving only length and distance. The algorithm also introduces a 1-bit flag which prefixes each element in the code, in order to signify whether the succeeding element is a literal or a &amp;quot;length-distance&amp;quot; pair.&lt;br /&gt;
&lt;br /&gt;
Like &#039;&#039;&#039;LZ77&#039;&#039;&#039;, the length and distance in &#039;&#039;&#039;LZSS&#039;&#039;&#039;&#039;s &amp;quot;length-distance&amp;quot; pair describe the location, within the search buffer, of the string that a particular pair substitutes (with the buffer containing symbols that have already been processed, or decompressed (if decoding)). During the decompression process, the decoder, upon encountering one of these pairs, can, in an informal sense, determine the string to replace said pair with by looking back into the search buffer by the amount described by &amp;quot;distance, and reading forward by the amount specified by &amp;quot;length&amp;quot;. The string that is read is the string in which to use. It should also be noted that it is sometimes possible, depending on the implementation, for the string being read to pass into the look ahead buffer, that is to say, it is possible for &amp;quot;length&amp;quot; to be longer than &amp;quot;distance&amp;quot;. The process for handling such cases is fairly straightforward however, once the string passes into the look ahead buffer, the decoder would just need to start reading from the symbols that have already been substituted as a part of processing the current pair (kind of like driving the train while placing the tracks).&lt;br /&gt;
&lt;br /&gt;
== Algorithm ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variables:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;size_length&amp;lt;/tt&amp;gt;: Size of length field, in bits&lt;br /&gt;
* &amp;lt;tt&amp;gt;size_distance&amp;lt;/tt&amp;gt;: Size of distance field, in bits&lt;br /&gt;
* &amp;lt;tt&amp;gt;min_len&amp;lt;/tt&amp;gt;: Minimum length of a backreference (at least 2 to break even; 3 is better as it represents a savings of 1 byte)&lt;br /&gt;
* Whether the flag bit is 0 for normal byte, 1 for length-distance pair, or the opposite&lt;br /&gt;
* Whether the length field comes before distance, or distance before length&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Decoding Procedure:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&lt;br /&gt;
    Read one bit as the flag&lt;br /&gt;
    &amp;lt;ul&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;&lt;br /&gt;
        If it&#039;s 1: (or 0 if flags are opposite)&lt;br /&gt;
        &amp;lt;ol style=&amp;quot;list-style-type: lower-alpha;&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;li&amp;gt;Read &amp;lt;tt&amp;gt;size_length&amp;lt;/tt&amp;gt; bits, add &amp;lt;tt&amp;gt;min_len&amp;lt;/tt&amp;gt; to the value, and use it as the LZSS &amp;lt;tt&amp;gt;length&amp;lt;/tt&amp;gt; value&amp;lt;/li&amp;gt;&lt;br /&gt;
          &amp;lt;li&amp;gt;Read &amp;lt;tt&amp;gt;size_distance&amp;lt;/tt&amp;gt; bits, add 1 to the value, and use it as the LZSS &amp;lt;tt&amp;gt;distance&amp;lt;/tt&amp;gt; value&amp;lt;/li&amp;gt;&lt;br /&gt;
          &amp;lt;li&amp;gt;Look back &amp;lt;tt&amp;gt;distance&amp;lt;/tt&amp;gt; bytes in the output data, and copy &amp;lt;tt&amp;gt;length&amp;lt;/tt&amp;gt; bytes to the end of the output data&amp;lt;/li&amp;gt;&lt;br /&gt;
        &amp;lt;/ol&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;&lt;br /&gt;
        Otherwise: (the flag is a 0, or 1 if flags are opposite)&lt;br /&gt;
        &amp;lt;ol style=&amp;quot;list-style-type: lower-roman;&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;li&amp;gt;Read 8 bits, and write them as a byte on the end of the output data&amp;lt;/li&amp;gt;&lt;br /&gt;
        &amp;lt;/ol&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;If there is more input data, go back to step 1&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
[[SkyRoads]] uses a variant of LZSS where the variables can be different for each file, and are stored at the start of the compressed data, as well as allowing two types of length-distance codes in the same file.&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
[[User:Malvineous|Malvineous]] discovered this compression algorithm was used by [[Prehistorik]]. If you find this information helpful in a project you&#039;re working on, please give credit where credit is due.  (A link back to this wiki would be nice too!)&lt;/div&gt;</summary>
		<author><name>Pixenal</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=LZSS_compression&amp;diff=10037</id>
		<title>LZSS compression</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=LZSS_compression&amp;diff=10037"/>
		<updated>2021-09-07T14:00:39Z</updated>

		<summary type="html">&lt;p&gt;Pixenal: Change high level description to address inaccurate information and qualify &amp;quot;Procedure&amp;quot; with &amp;quot;Decoding&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Compression Infobox&lt;br /&gt;
 | Type = Stream&lt;br /&gt;
 | UnitSize = 1-bit&lt;br /&gt;
 | Games =&lt;br /&gt;
   {{Game|J.R.R. Tolkien&#039;s Riders of Rohan}}&lt;br /&gt;
   {{Game|Nomad}}&lt;br /&gt;
   {{Game|Prehistorik}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;LZSS&#039;&#039;&#039; (Lempel-Ziv-Storer-Szymanski) is a dictionary compression algorithm first proposed by James A. Storer and Thomas G. Szymanski in 1982. The method is lossless, and builds upon the existing &#039;&#039;&#039;LZ77&#039;&#039;&#039; technique.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;LZSS&#039;&#039;&#039; makes use of a sliding window just like its predecessor, however differs primarily in its more selective approach to substitution. Where &#039;&#039;&#039;LZ77&#039;&#039;&#039; simply replaces every string it processes, &#039;&#039;&#039;LZSS&#039;&#039;&#039; will only substitute a string with a &amp;quot;length-distance&amp;quot; pair if the size of the string, in bits, exceeds a preset minimum, leaving the string&#039;s symbols as literals if not. This prevents a pair from ever replacing a string whose size is less than its own, and thus avoids such a case from unnecessarily increasing the size of the final output (a problem which can occur in &#039;&#039;&#039;LZ77&#039;&#039;&#039;). As alluded to above, &#039;&#039;&#039;LZSS&#039;&#039;&#039; also does away with the codeword component of &#039;&#039;&#039;LZ77&#039;&#039;&#039;&#039;s &amp;quot;length-distance-codeword&amp;quot; triple, leaving only length and distance. The algorithm also introduces a 1-bit flag which prefixes each element in the code, in order to signify whether the succeeding element is a literal or a &amp;quot;length-distance&amp;quot; pair.&lt;br /&gt;
&lt;br /&gt;
== Algorithm ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variables:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;size_length&amp;lt;/tt&amp;gt;: Size of length field, in bits&lt;br /&gt;
* &amp;lt;tt&amp;gt;size_distance&amp;lt;/tt&amp;gt;: Size of distance field, in bits&lt;br /&gt;
* &amp;lt;tt&amp;gt;min_len&amp;lt;/tt&amp;gt;: Minimum length of a backreference (at least 2 to break even; 3 is better as it represents a savings of 1 byte)&lt;br /&gt;
* Whether the flag bit is 0 for normal byte, 1 for length-distance pair, or the opposite&lt;br /&gt;
* Whether the length field comes before distance, or distance before length&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Decoding Procedure:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&lt;br /&gt;
    Read one bit as the flag&lt;br /&gt;
    &amp;lt;ul&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;&lt;br /&gt;
        If it&#039;s 1: (or 0 if flags are opposite)&lt;br /&gt;
        &amp;lt;ol style=&amp;quot;list-style-type: lower-alpha;&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;li&amp;gt;Read &amp;lt;tt&amp;gt;size_length&amp;lt;/tt&amp;gt; bits, add &amp;lt;tt&amp;gt;min_len&amp;lt;/tt&amp;gt; to the value, and use it as the LZSS &amp;lt;tt&amp;gt;length&amp;lt;/tt&amp;gt; value&amp;lt;/li&amp;gt;&lt;br /&gt;
          &amp;lt;li&amp;gt;Read &amp;lt;tt&amp;gt;size_distance&amp;lt;/tt&amp;gt; bits, add 1 to the value, and use it as the LZSS &amp;lt;tt&amp;gt;distance&amp;lt;/tt&amp;gt; value&amp;lt;/li&amp;gt;&lt;br /&gt;
          &amp;lt;li&amp;gt;Look back &amp;lt;tt&amp;gt;distance&amp;lt;/tt&amp;gt; bytes in the output data, and copy &amp;lt;tt&amp;gt;length&amp;lt;/tt&amp;gt; bytes to the end of the output data&amp;lt;/li&amp;gt;&lt;br /&gt;
        &amp;lt;/ol&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;&lt;br /&gt;
        Otherwise: (the flag is a 0, or 1 if flags are opposite)&lt;br /&gt;
        &amp;lt;ol style=&amp;quot;list-style-type: lower-roman;&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;li&amp;gt;Read 8 bits, and write them as a byte on the end of the output data&amp;lt;/li&amp;gt;&lt;br /&gt;
        &amp;lt;/ol&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;If there is more input data, go back to step 1&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
[[SkyRoads]] uses a variant of LZSS where the variables can be different for each file, and are stored at the start of the compressed data, as well as allowing two types of length-distance codes in the same file.&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
[[User:Malvineous|Malvineous]] discovered this compression algorithm was used by [[Prehistorik]]. If you find this information helpful in a project you&#039;re working on, please give credit where credit is due.  (A link back to this wiki would be nice too!)&lt;/div&gt;</summary>
		<author><name>Pixenal</name></author>
	</entry>
</feed>