예제 #1
0
        /// <summary>
        /// Compresses a span of bytes to Oodle Compressed bytes (Requires Oodle DLL)
        /// </summary>
        /// <param name="input">Input Decompressed Data</param>
        /// <param name="compressedSize">Actual Compressed Data size</param>
        /// <param name="format">Compression format to use</param>
        /// <param name="level">Compression setting to use</param>
        /// <returns>Span of compressed data with remainder aligned working bytes.</returns>
        public static Span <byte> Compress(ReadOnlySpan <byte> input, out int compressedSize,
                                           OodleFormat format = OodleFormat.Kraken, OodleCompressionLevel level = OodleCompressionLevel.Optimal2)
        {
            var maxSize = GetCompressedBufferSizeNeeded(input.Length);
            var result  = new byte[maxSize].AsSpan();

            return(Compress(input, result, out compressedSize, format, level));
        }
예제 #2
0
 private static extern int OodleLZ_Compress(
     OodleFormat A_0,
     byte[] A_1,
     long A_2,
     byte[] A_3,
     OodleCompressionLevel A_4,
     uint A_5,
     uint A_6,
     uint A_7,
     OodleVersion A_8);
예제 #3
0
        public static byte[] Compress(byte[] buffer, int size, OodleFormat format, OodleCompressionLevel level)
        {
            uint compressedBufferSize = GetCompressionBound((uint)size);

            byte[] compressedBuffer = new byte[compressedBufferSize];

            int compressedCount = OodleLZ_Compress(format, buffer, size, compressedBuffer, level, 0, 0, 0);

            byte[] outputBuffer = new byte[compressedCount];
            Buffer.BlockCopy(compressedBuffer, 0, outputBuffer, 0, compressedCount);

            return(outputBuffer);
        }
예제 #4
0
        /// <summary>
        /// Compresses a byte array to Oodle compressed data
        /// </summary>
        /// <param name="data">data to compress</param>
        /// <param name="format">Oodle format</param>
        /// <param name="compressionLevel">Oodle compression level</param>
        /// <returns></returns>
        public static byte[] Compress(byte[] data, OodleFormat format, OodleCompressionLevel compressionLevel)
        {
            uint compressedBufferSize = (uint)data.Length + 274 * (((uint)data.Length + 0x3FFFF) / 0x40000);

            byte[] compressedBuffer = new byte[compressedBufferSize];
            int    compressedSize   = OodleLZ_Compress(format, data, data.Length, compressedBuffer, compressionLevel, 0, 0, 0, 0, 0);

            if (compressedSize < 0)
            {
                return(null);
            }

            byte[] outputBuffer = new byte[compressedSize];
            Buffer.BlockCopy(compressedBuffer, 0, outputBuffer, 0, compressedSize);

            return(outputBuffer);
        }
예제 #5
0
    public static byte[] a(byte[] A_0, int A_1, OodleFormat A_2, OodleCompressionLevel A_3)
    {
        byte[] A_3_1     = new byte[(int)global::a.a((uint)A_1)];
        int    count     = global::a.OodleLZ_Compress(A_2, A_0, (long)A_1, A_3_1, A_3, 0U, 0U, 0U, (OodleVersion)0);
        int    dstOffset = 0;

        if (A_2 == OodleFormat.Kraken)
        {
            dstOffset = 24;
        }
        byte[] numArray = new byte[count + dstOffset];
        Buffer.BlockCopy((Array)A_3_1, 0, (Array)numArray, dstOffset, count);
        if (A_2 == OodleFormat.Kraken)
        {
            Buffer.BlockCopy((Array)global::a.a, 0, (Array)numArray, 0, 16);
            byte[] bytes1 = BitConverter.GetBytes(count);
            byte[] bytes2 = BitConverter.GetBytes(A_1);
            Buffer.BlockCopy((Array)bytes2, 0, (Array)numArray, 16, bytes2.Length);
            Buffer.BlockCopy((Array)bytes1, 0, (Array)numArray, 20, bytes1.Length);
        }
        return(numArray);
    }
예제 #6
0
 private static extern int OodleLZ_Compress(OodleFormat format, byte[] buffer, long bufferSize, byte[] outputBuffer, OodleCompressionLevel level, uint unused1, uint unused2, uint unused3);
예제 #7
0
 public static int a(byte[] A_0, int A_1, OodleFormat A_2, OodleCompressionLevel A_3)
 {
     byte[] A_3_1 = new byte[(int)c.a((uint)A_1)];
     return(c.OodleLZ_Compress(A_2, A_0, (long)A_1, A_3_1, A_3, 0U, 0U, 0U, (OodleVersion)0));
 }
예제 #8
0
        private static Span <byte> Compress(ReadOnlySpan <byte> input, Span <byte> result, out int compressedSize, OodleFormat format, OodleCompressionLevel level)
        {
            var encodedSize = OodleLZ_Compress(format, ref MemoryMarshal.GetReference(input), input.Length, ref MemoryMarshal.GetReference(result), level);

            // Oodle's compressed result leaves data after the "compressed length" return index.
            // Return an aligned span (ensuring length is a multiple of 4).
            // Retaining these unused bytes matches the behavior observed in New Pokémon Snap DRPF files.
            compressedSize = (int)encodedSize;
            var align = (compressedSize + 3) & ~3;

            return(result[..align]);
예제 #9
0
 private static extern long OodleLZ_Compress(OodleFormat format, ref byte buffer, long bufferSize, ref byte result, OodleCompressionLevel level,
                                             long opts = 0, long context = 0, long unused = 0, long scratch = 0, long scratch_size = 0);
예제 #10
0
        public static extern int OodleLZ_Compress(OodleFormat format, byte[]?decompressedBuffer, long decompressedSize, byte[] compressedBuffer, OodleCompressionLevel compressionLevel, uint a, uint b, uint c, ThreadModule threadModule); // Oodle dll method

        public static byte[] OodleCompress(byte[]?decompressedBuffer, int decompressedSize, OodleFormat format, OodleCompressionLevel compressionLevel, uint a)
        {
            var array           = new byte[(uint)decompressedSize + 274U * (((uint)decompressedSize + 262143U) / 262144U)]; // Initializes array with compressed array size
            var compressedBytes = new byte[a + (uint)OodleLZ_Compress(format, decompressedBuffer,                           // Initializes the array we will be returning
                                                                      decompressedSize, array, compressionLevel, 0U, 0U,
                                                                      0U, 0U) - (int)a];

            Buffer.BlockCopy(array, 0, compressedBytes, 0, OodleLZ_Compress(format, decompressedBuffer, decompressedSize,
                                                                            array, compressionLevel, 0U, 0U,
                                                                            0U, 0U)); // Combines the two arrays
            return(compressedBytes);
        }
예제 #11
0
 public static extern int OodleLZ_Compress(OodleFormat format, byte[]?decompressedBuffer, long decompressedSize, byte[] compressedBuffer, OodleCompressionLevel compressionLevel, uint a, uint b, uint c, ThreadModule threadModule); // Oodle dll method
예제 #12
0
 private static extern int OodleLZ_Compress(OodleFormat format, byte[] decompressedBuffer, long decompressedSize,
                                            byte[] compressedBuffer, OodleCompressionLevel compressionLevel, uint uint0, uint uint1, uint uint2,
                                            BaseEnum genum);
예제 #13
0
        public static uint GetCompressedLength(byte[]?decompressedBuffer, int decompressedSize, OodleFormat format,
                                               OodleCompressionLevel compression)
        {
            var temp = new byte[(int)GetCompressedBuffer((uint)decompressedSize)];

            return((uint)OodleLZ_Compress(format, decompressedBuffer, decompressedSize, temp, compression, 0U, 0U, 0U,
                                          0));
        }
예제 #14
0
        public static byte[] OodleCompress(byte[]?decompressedBuffer, int decompressedSize, OodleFormat format,
                                           OodleCompressionLevel compressionLevel, uint uintHomie)
        {
            var array = new byte[GetCompressedBuffer((uint)decompressedSize)];
            var num   = OodleLZ_Compress(format, decompressedBuffer, decompressedSize, array, compressionLevel, 0U, 0U,
                                         0U, 0U);
            var num2           = num - (int)uintHomie;
            var num3           = 0;
            var compressedByte = new byte[uintHomie + (uint)num2 + (uint)num3];

            Buffer.BlockCopy(array, 0, compressedByte, num3, num);
            return(compressedByte);
        }
예제 #15
0
 private static extern int OodleLZ_Compress(OodleFormat codec, byte[] src, long srcLen, byte[] dst,
                                            OodleCompressionLevel level, long opts, long offs, long unused, long scratch, long scratchSize);