Compression - Falmouth-Games-Academy/comp350-research-journal GitHub Wiki

Compression

In the field of computer science, compression is the act of encoding data so that the data can still be represented in fewer bits than before 1(https://www.researchgate.net/publication/280493292_Implementing_a_Novel_Approach_an_Convert_Audio_Compression_to_Text_Coding_via_Hybrid_Technique). Compression usually comes in one of two flavours, Lossy or Lossless. Lossy compression reduces bits by the removal of information that is deemed "less important" 2(http://www.jatit.org/volumes/research-papers/Vol15No1/3Vol15No1.pdf). Lossless compression works by identifying statistically redundant data and removing it 1(https://www.researchgate.net/publication/280493292_Implementing_a_Novel_Approach_an_Convert_Audio_Compression_to_Text_Coding_via_Hybrid_Technique).

The Importance of Compression

File size affects how quickly a game can load and how much lag there is, which are two large components of what makes up a game's playability. It also determines how long a game will take to download 5(https://blog.100tb.com/image-compression-strategies-for-game-developers), and amount of space it will take up on physical media such as a disc. In the past, the main factor of game size was the physical amount of space that the physical media could hold, with SNES cartridges able to hold 6MB games 8(https://blogs.umass.edu/Techbytes/2014/02/10/history-of-gaming-storage/), 700MB on CD-ROMs, 4.7GB on DVDs and Blu-rays going up to 128GB for the quad layer variety 10(https://www.anandtech.com/show/13575/sony-releases-128-gb-bdr-xl-media). Although physical media remains popular amongst console gamers 7(https://www.techspot.com/community/topics/most-console-players-prefer-physical-games-over-digital-downloads.247423/) and remains a factor in game compression, there is a trend towards digital media 6(http://www.pushsquare.com/news/2018/04/sony_data_shows_digital_sales_continue_to_grow_on_ps4), making download time a larger concern. This is especially prevalent in the PC game market where a survey would suggest that 71% of the market opt for digital downloads over physical disks 7(https://www.techspot.com/community/topics/most-console-players-prefer-physical-games-over-digital-downloads.247423/).

Image Compression

One common area where compression is used widely is with image storage. More specifically images stored and shared on the web. J. H. Pujar and L. M. Kadlaskar 2(http://www.jatit.org/volumes/research-papers/Vol15No1/3Vol15No1.pdf) state compressing images can reduce the cost of storage and transmission. While compression may save money, using lossy compression methods on data such as images may create some backlash from users 3(https://lifehacker.com/why-facebook-makes-your-images-look-like-crap-and-how-1727836324).

Audio Compression

There are several reasons why compression is of importance when handling audio files. Firstly, audio files can be very large meaning they can greatly increase the required disk space for a project. Secondly, they often need to be played at a moments notice during gameplay. It is probably best that the larger background music files be compressed and shorter clips such as voice lines, be kept native. Doing it this way means that they don't have to be decompressed at runtime thus reducing negative hits to performance. Games created within Unity on mobile devices can only decompress one audio stream at a time, and trying to decompress multiple files at one time can be extremely taxing, which can be spotted while profiling your game or application by seeing strange memory usage or CPU spikes. Unity luckily has the option to decompress on load, which means longer files will be stored in memory so that they can be loaded at a moments notice, and take load off of the CPU. 4(https://paladinstudios.com/2012/07/30/4-ways-to-increase-performance-of-your-unity-game/).[18](/Falmouth-Games-Academy/comp350-research-journal/wiki/18)(https://docs.unity3d.com/Manual/class-AudioClip.html)

With regards to audio, lossy files can reduce the bitrate and frequency range, the recording 17(https://www.maketecheasier.com/audio-compression-and-lossless-audio/), which will reduce the quality of the audio with the benefit of smaller files. While this is not recommended for professional settings, if the quality of the audio is not important, it is a good way of greatly reducing the file size 12(https://www.tomsguide.com/us/what-are-audio-codecs,review-4469.html). Lossy files tend to remove the high frequencies first since they are out of the general human range of hearing of around 15 - 20,000 Hz 14(https://hypertextbook.com/facts/2003/ChrisDAmbrose.shtml). This removal of details that most human ears won't miss is known as psychoacoustics 17(https://www.maketecheasier.com/audio-compression-and-lossless-audio/). Despite the goal being to remove details which can't be perceived, there is an argument that the removal of these frequencies reduces the overtones from the audio 13(https://www.uaudio.com/blog/understanding-audio-data-compression/), this is more apparent in music tracks rather than games, where audio isn't the only focus of the user. Artefacts of compression for audio is considered to be found at bitrates lower than 128kbps, although rates lower than this may be acceptable for spoken words. Lower rates than this are not recommended for music 13(https://www.uaudio.com/blog/understanding-audio-data-compression/).

Lossless files for audio allow for smaller files, where the files can be returned to their original size. These formats include FLAC, ALAC and WMA lossless 12(https://www.tomsguide.com/us/what-are-audio-codecs,review-4469.html) 16(https://www.lifewire.com/what-makes-an-audio-format-lossy-2438561). Converting a lossy compressed audio file to a lossless file does not garner any benefit since the compression has already been done and the lost artefacts cannot be retrieved once removed, and this will just result in a higher file size 15(https://www.lifewire.com/what-makes-an-audio-format-lossless-2438560).

PCM, AIFF and WAV are the uncompressed form of audio files 12(https://www.tomsguide.com/us/what-are-audio-codecs,review-4469.html), and so will take up a lot of space, which is not good for space optimisation. However, since artefacts are lost once they have been removed 15(https://www.lifewire.com/what-makes-an-audio-format-lossless-2438560), it could be worth storing an uncompressed version of audio files in the project repository so that the quality can be improved if necessary, provided repository space isn't at a premium.

Texture Compression in Unreal Engine

Unreal engine uses lossy compression for textures. In fact, it already has a fixed number of texture compression settings built in. AppCombat if turned on (it can only be used for PC) gathers system information of the computer it's being run on and compresses the textures as best to fit the PCs system.

You can also do this manually through [your_game]\Config\DefaultDeviceProfiles.ini and then go into the Engine\Config\ folder. Here you can change MinLODSize, MaxLODSize, LODBias, MinMagFilter, MipFilter and MipGenSettings 11(https://docs.unrealengine.com/en-us/Engine/Content/Types/Textures/SupportAndSettings).

  • MinLODSize = The minimum mip (maximum intensity projection) size that will be rendered
  • MaxLODSize = The opposite of MinLODSize
  • LODBias = This is the allowed offset within MinLODSize and MaxLODSize

References

[1] O. A. Mahdi, M. A. Mohammed, and A. J. Mohamed, “Implementing a novel approach an convert audio compression to text coding via hybrid technique”, International Journal of Computer Science Issues (IJCSI), vol. 9, no. 6, p. 53, 2012.

[2] J. H. Pujar and L. M. Kadlaskar, “A new lossless method of image compression and decompression using huffman coding techniques.” Journal of Theoretical & Applied Information Technology, vol. 15, 2010.

[3]https://lifehacker.com/why-facebook-makes-your-images-look-like-crap-and-how-1727836324

[4]https://paladinstudios.com/2012/07/30/4-ways-to-increase-performance-of-your-unity-game/

[5] Image Compression Strategies For Game Developers

[6] Sony Data Shows Digital Sales Continue to Grow on PS4`

[7] Most console players prefer physical games over digital downloads

[8] A Brief and Abbreviated History of Gaming Storage

[9] CD Vs. DVD Storage Capacity

[10] Sony Releases Quad-Layer 128 GB BD-R XL Media

[11] UE4 texture support and settings

[12] Audio Codecs: What They Are and Why They Matter

[13] Understanding Audio Data Compression

[14] Frequency Range Of Human Hearing

[15] What Makes an Audio Format Lossless?

[16] What Makes an Audio Format Lossy?

[17] How Does Audio Compression Work, and What Is “Lossless” Audio?

[18] Audio Clip