Giter VIP home page Giter VIP logo

zstdunity's Introduction

ZstdUnity

simple zstandard decompress binding for unity

References

ZstdUnity is inspired by xLua[1] build sets.

Dependencies

  • cmake

QuickStart

  • make plugins
    • $ sh make_osx.sh
  • copy plugins
    • $ cp -ap plugin/Plugins your/unity/project/Assets/
  • copy C# bindings
    • $ cp -ap Assets/Uzstd your/unity/project/Assets/
//simple pattern
byte[] compressed;
byte[] dst = new byte[decompressedSize];
Uzstd.API.decompress(dst, dst.Length, compressed, compressed.Length);

//stream
using(var context = DecompressContext.CreateWithStream())
{
  byte[] work;
  int totalDecompressed = 0;
  do
  {
    var result = Uzstd.API.decompressStream(context, work, work.Length, compressed, compressed.Length);
    if( result == 0 ) {break;} //decompress done.
    if( result <  0 ) {throw new System.Exception("decompress error"); }
    System.Array.Copy(work, 0, dst, totalDecompressed, result);
    totalDecompressed += result;
  }while(totalDecompressed < dst.Length);
}

//with dictionary
using(var context = DecompressContext.CreateWithDictionary(dict))
{
  Uzstd.API.decompressDictionary(context, dst, dst.Length, compressed, compressed.Length); 
}

//stream with dictionary
using(var context = DecompressContext.CreateWithStreamDictionary(dit))
{
  byte[] work;
  int totalDecompressed = 0;
  do
  {
    var result = Uzstd.API.decompressStreamDictionary(context, work, work.Length, compressed, compressed.Length);
    if( result == 0 ) {break;} //decompress done.
    if( result <  0 ) {throw new System.Exception("decompress error"); }
    System.Array.Copy(work, 0, dst, totalDecompressed, result);
    totalDecompressed += result;
  }while(totalDecompressed < dst.Length);
}

TODO

  • test plugins android/ios/linux.

zstdunity's People

Contributors

bigoyayubi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.