Git Product home page Git Product logo

lz4.frame's Introduction

LZ4.Frame

NuGet version

LZ4 Frame compress & decompress for .NET based on lz4net.

Alternative

This lib is a simple, pure managed implementation. You should choose K4os.Compression.LZ4 for a more reliable implementation with dictionary support.

Install

PM > Install-Package LZ4.Frame

Why not...

lz4net is great, but lacking LZ4 Frame support. This project is based on lz4net and enables LZ4 Frame support. (use K4os.Compression.LZ4 instead)

lz4.net is a C++/CLI wrapper for native LZ4. I love C++/CLI solutions but that means it only works on Windows platforms. This project is fully managed, therefore it's easier to compile, modify, and go cross-platform.

TODO

These features are not implemented:

  • Linked Block (when Block Independence flag = 0)
  • Dictionary (when Dictionary ID != 0)
  • Skippable Frame
  • Legacy frame

If you get Unhandled ArgumentException: LZ4 block is corrupted, or invalid length has been given., your lz4 file is most likely using Linked Block and Dictionary. I currently couldn't find a workaround (please switch to lz4.net) for this because lz4net does not have any Dictionary support.

I'd appreciate it if someone could add Dictionary support for this.

LICENSE

MIT

Reference

Rune Henriksen's lz4 frame formatter (LICENSE: MIT) is the main reference of this project.

LZ4 Frame Format Description

Thanks

Thanks @vpenades for helping me improve this lib.


by Ulysses

lz4.frame's People

Contributors

ulysseswu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

lz4.frame's Issues

Lz4frame fails to detect uncompressed blocks

While decompressing several Lz4 blocks, I stumbled upon an uncompressed block, but lz4frame threw an exception.

Tracing the problem I found that this line of code:

if ((blockSize >> 31) == 1)

Is not working correctly. It seems that if blockSize is a SIGNED integer, shifting the bit down always produces zero, the result is that it neves enters inside the if block.

By replacing the line with:

if (blockSize < 0)

the decompressor works correctly.

On a side note, I was having issues with lz4net not being able to load the assembly due to net.standard / net.framework version mismatch. After some review I found lz4net.netcore.signed which solves that problem (but your lz4frame still points to lz4net, which is a problem, I had to include your code directly)

Finally, I found why Milosz Krajewski is not updating the lz4net repository anymore... the reason seems to be he is starting from scratch a new Lz4 library here.

Decompress option to NOT close underlaying stream

Hi

I am using your LZ4 library to decompress Lz4 blocks within a larger file stream.

The problem is that when I call Decompress, it closes the underlaying stream and I cannot continue reading it.

Could it be possible for you to add an aditional argument?

public static byte[] Decompress(Stream input, Boolean doNotCloseInputStream);

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.