mono/MonoGame — pull request #2775 by KonajuGames (2014-07-02 15:38:19+00:00)
Title: Content compression support

Adds support for content compression using LZMA from the 7-Zip SDK that handily comes with a C# version.

LZMA content compression is flagged using one of the unused bits in the flags field (0x40). The flag for XNA's LZX compression remains unchanged.

Added a /compress option to MGCB along with documentation in mgcb.md.

A sample 1024x768 texture using SurfaceFormat.Color is 3073KB uncompressed and 1006KB compressed. It took 6.4 seconds to build and compress the asset. The compressed texture loaded in 0.423s (in WindowsGL test project) while the uncompressed texture loaded in 0.011s, so on desktop platforms. On Android (Nexus 5), the compressed asset loaded in 1.422s and the uncompressed asset loaded in 0.072s.

The 7-Zip SDK is split between MonoGame.Framework and MonoGame.Framework.Content.Pipeline. Decoding and common classes are in MonoGame.Framework and encoding classes are in MonoGame.Framework.Content.Pipeline.

We could also try compiling and using the C version of the 7-Zip SDK to see what improvement it gives to encoding and decoding performance.