<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Game_Engines_2021W_Lecture_20</id>
	<title>Game Engines 2021W Lecture 20 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Game_Engines_2021W_Lecture_20"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Game_Engines_2021W_Lecture_20&amp;action=history"/>
	<updated>2026-04-08T03:16:30Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Game_Engines_2021W_Lecture_20&amp;diff=23101&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;==Notes==  &lt;pre&gt; Compression in Game Engines ---------------------------  How much do you know about compression?  - lossy vs lossless?  * huffman encoding * perceptual coding...&quot;</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Game_Engines_2021W_Lecture_20&amp;diff=23101&amp;oldid=prev"/>
		<updated>2021-03-25T14:07:06Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Notes==  &amp;lt;pre&amp;gt; Compression in Game Engines ---------------------------  How much do you know about compression?  - lossy vs lossless?  * huffman encoding * perceptual coding...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Notes==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Compression in Game Engines&lt;br /&gt;
---------------------------&lt;br /&gt;
&lt;br /&gt;
How much do you know about compression?&lt;br /&gt;
 - lossy vs lossless?&lt;br /&gt;
&lt;br /&gt;
* huffman encoding&lt;br /&gt;
* perceptual coding&lt;br /&gt;
* lempel-ziv&lt;br /&gt;
&lt;br /&gt;
Why?&lt;br /&gt;
 - games care about performance, space and time&lt;br /&gt;
 - compression trades off time for space&lt;br /&gt;
   - but sometimes you effectively get both&lt;br /&gt;
&lt;br /&gt;
lossless compression&lt;br /&gt;
 - compressed version can be used to reproduce original bit-for-bit&lt;br /&gt;
 - zip files&lt;br /&gt;
&lt;br /&gt;
lossy compression&lt;br /&gt;
 - some information is thrown away during compression&lt;br /&gt;
&lt;br /&gt;
Information theory&lt;br /&gt;
 - information: number of bits needed to represent something&lt;br /&gt;
    - but, LEAST number of bits&lt;br /&gt;
 - so part of information theory is always compression&lt;br /&gt;
&lt;br /&gt;
Maximum information is from random processes&lt;br /&gt;
 - random bits can only be reproduced by copying them, no algorithm&lt;br /&gt;
   can do so without being equal or bigger than the bits&lt;br /&gt;
&lt;br /&gt;
Run length encoding&lt;br /&gt;
 - represent repeated runs explicitly&lt;br /&gt;
 - i.e., say 20 0&amp;#039;s instead of 00000000000000000000&lt;br /&gt;
   - only works if you expect to have many runs&lt;br /&gt;
   - if you have few, you can actually make the output bigger than the input&lt;br /&gt;
&lt;br /&gt;
All compression algorithms try to transform data into a representation equal to the amount of information in it&lt;br /&gt;
 - i.e., the theoretical amount of information = size of data&lt;br /&gt;
&lt;br /&gt;
An approximation of the amout of information in something...how big is it when you compress it!&lt;br /&gt;
&lt;br /&gt;
With lossy compression, we throw away information&lt;br /&gt;
 - output doesn&amp;#039;t have all the information of the input&lt;br /&gt;
&lt;br /&gt;
lossy compression seems like a bad idea&lt;br /&gt;
 - don&amp;#039;t do it with code!&lt;br /&gt;
&lt;br /&gt;
idea: throw away information that won&amp;#039;t be missed&lt;br /&gt;
 - patterns that are imperceptible&lt;br /&gt;
 - so, you have to have a model of what is perceptible!&lt;br /&gt;
&lt;br /&gt;
For audio, lossy compression is common because our ears can&amp;#039;t detect many&lt;br /&gt;
patterns in sound&lt;br /&gt;
&lt;br /&gt;
MP3 was developed by someone at the Fraunhoffer institute, listening to a song by Suzanne Vega&lt;br /&gt;
 - did it until he couldn&amp;#039;t hear any artifacts after compression, i.e.,&lt;br /&gt;
   the frequencies that were thrown away were imperceptible&lt;br /&gt;
&lt;br /&gt;
More recent codecs, i.e., AAC, use more sophisticated models of human perception&lt;br /&gt;
&lt;br /&gt;
Same thing for images and video&lt;br /&gt;
 - what patterns do people not notice?&lt;br /&gt;
&lt;br /&gt;
More sophisticated perceptual models allow for higher compression ratios but at the cost of more computation, especially during compression&lt;br /&gt;
 - typically compression is much more expensive than decompression&lt;br /&gt;
 - but the tradeoff varies&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Latest trend in compression is AI-assisted compression&lt;br /&gt;
 - e.g., feed data into a neural net, let it reproduce it&lt;br /&gt;
 - neural net identifies patterns that can later be reproduced&lt;br /&gt;
&lt;br /&gt;
most compression is based on some form of dictionary&lt;br /&gt;
 - identify the &amp;quot;words&amp;quot; that make up the document&lt;br /&gt;
 - then compress by storing the dictionary and then which words are used, with&lt;br /&gt;
   the words identified as indices in the dictionary&lt;br /&gt;
&lt;br /&gt;
Can lead to great compression if you use a pattern recognizer, but artifacts get very weird&lt;br /&gt;
 - instead of weird blocks, you get weird faces&lt;br /&gt;
 - you see this in image enhancement, which is really just reverse compression&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As a game developer, why do you care about all this?&lt;br /&gt;
 - need to choose the right compression for game assets&lt;br /&gt;
   - PNG vs JPEG (lossless vs lossy)&lt;br /&gt;
   - wav vs ogg/mpg/aac&lt;br /&gt;
&lt;br /&gt;
You&amp;#039;re making a space vs time tradeoff&lt;br /&gt;
 - bigger files for faster processing&lt;br /&gt;
 - but the cost of bigger files can be more of a cost than the processing&lt;br /&gt;
&lt;br /&gt;
PS5, XBox Series X&lt;br /&gt;
 - part of performance gain is hardware decompression&lt;br /&gt;
   - so you actually get better performance with compressed assets&lt;br /&gt;
   - particularly important for textures&lt;br /&gt;
&lt;br /&gt;
Why do games get so big?&lt;br /&gt;
 - a large part is using uncompressed assets, duplicated assets for performance&lt;br /&gt;
   - duplication is for slow seek times of spinning hard drives, optical media&lt;br /&gt;
&lt;br /&gt;
But new consoles have SSDs and hardware decompression&lt;br /&gt;
 - so can get smaller games that perform better&lt;br /&gt;
&lt;br /&gt;
compression has big future as perception really is compression&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>