Git Product home page Git Product logo

ironcompress's People

Contributors

aloneguid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

nodakai

ironcompress's Issues

Version 1.30 does not decompress Brotli codec whereas 1.28 does

X64 Windows 10 .NET 7, this LINQPad code:

var bytes = File.ReadAllBytes(@"...\bytes.bin");
var iron = new Iron();
using (var ironCompressResult = iron.Decompress(Codec.Brotli, bytes))
{
ironCompressResult.Dump();
Encoding.UTF8.GetString(ironCompressResult).Dump();
}

Then ironCompressResult.Length = 0 for 1.30 version, but ironCompressResult.Length > 0 for 1.28 (which works as expected).

I tried .NET 7, .NET 6 and netstandard 2.0, the same result.

The compressionLevel handling for LZ4 does not work

It seems that the LZ4 compressor only actually compresses if given the CompressionLevel.Fastest flag:

Iron iron = new Iron(ArrayPool<byte>.Shared);
using (IronCompressResult lz4 = iron.Compress(Codec.LZ4, uncompressed.AsSpan()))
    Console.WriteLine("LZ4 (optimal): {0} bytes ({1:0.00}%)", lz4.Length, lz4.Length * 100.0 / uncompressed.Length);
using (IronCompressResult lz4 = iron.Compress(Codec.LZ4, uncompressed.AsSpan(), compressionLevel: CompressionLevel.SmallestSize))
    Console.WriteLine("LZ4 (smallest): {0} bytes ({1:0.00}%)", lz4.Length, lz4.Length * 100.0 / uncompressed.Length);
using (IronCompressResult lz4 = iron.Compress(Codec.LZ4, uncompressed.AsSpan(), compressionLevel: CompressionLevel.Fastest))
    Console.WriteLine("LZ4 (fastest): {0} bytes ({1:0.00}%)", lz4.Length, lz4.Length * 100.0 / uncompressed.Length);

This results in the following output:

LZ4 (optimal): 206368 bytes (100,39%) native
LZ4 (smallest): 206368 bytes (100,39%) native
LZ4 (fastest): 109516 bytes (53,28%) native

That is, only CompressionLevel.Fastest actually does any compression.

The issue seems to be that ToNativeCompressionLevel() converts CompressionLevel.Optimal to the value 2, but then compress_lz4() in api.cpp converts the value 2 to level = 32768. This is passed to LZ4 as the acceleration_level where a higher number means less compression.

So looks like the compress_lz4() interprets the converted-to-native compression level in an incorrect fashion.

For reference, the Zstandard seems to handle the levels as expected:

Zstd (optimal): 64226 bytes (31,24%)
Zstd (smallest): 63076 bytes (30,68%)
Zstd (fastest): 73317 bytes (35,67%)

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.