summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCompress
AgeCommit message (Collapse)Author
2022-11-26Everywhere: Add support for compilation under emscriptenAli Mohammad Pur
Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
2022-11-01Everywhere: Mark dependencies of most targets as PRIVATETim Schumacher
Otherwise, we end up propagating those dependencies into targets that link against that library, which creates unnecessary link-time dependencies. Also included are changes to readd now missing dependencies to tools that actually need them.
2022-11-01Everywhere: Explicitly link all binaries against the LibC targetTim Schumacher
Even though the toolchain implicitly links against -lc, it does not know where it should get LibC from except for the sysroot. In the case of Clang this causes it to pick up the LibC stub instead, which might be slightly outdated and feature missing symbols. This is currently not an issue that manifests because we pass through the dependency on LibC and other libraries by accident, which causes CMake to link against the LibC target (instead of just the library), and thus points the linker at the build output directory. Since we are looking to fix that in the upcoming commits, let's make sure that everything will still be able to find the proper LibC first.
2022-10-11LibCompress: Brotli support metadata of skip_length=0Tommy Murphy
The relevant RFC section from https://www.rfc-editor.org/rfc/rfc7932#section-9.2 MSKIPBYTES * 8 bits: MSKIPLEN - 1, where MSKIPLEN is the number of metadata bytes; this field is only present if MSKIPBYTES is positive; otherwise, MSKIPLEN is 0 (if MSKIPBYTES is greater than 1, and the last byte is all zeros, then the stream should be rejected as invalid) So when skip_bytes is zero we need to break and re-align bytes. Added the relevant test case that demonstrates this from: https://github.com/google/brotli/blob/master/tests/testdata/x.compressed
2022-10-10AK+Userland: Replace Linux, macOS, and *BSD macros with platform definesAndrew Kaster
We have such nice platform macros, let's clean up any remnants of manual __my_platform__ macros in LibCore, LibCompress and AK.
2022-09-17LibCompress+Tests: Demonstrate and fix faulty metadata lengthBen Wiederhake
The test-case is heavily inspired by: https://github.com/google/brotli/blob/master/tests/testdata/x.compressed.01 Or in words: A metadata meta-block containing `Y` (which should be ignored), and then the actual data (a single `Z`). The bug used to skip one metadata byte too few, and thus read garbage.
2022-07-10LibCompress: Write Deflate window size in the Zlib headerKarol Kosek
Previously we said that the window size was always 512 bytes, which caused errors during decompressing in apps outside of Serenity that actually use this information. Now, the value is always 7 (32 KiB). Fixes: #14503
2022-06-30LibCompress: Implement a Zlib compressorKarol Kosek
2022-06-30LibCompress: Use newly created Zlib header structure when decompressingKarol Kosek
This way we can get rid of some magic numbers.
2022-06-30LibCompress: Add Zlib header structureKarol Kosek
2022-05-21LibCompress: Implement Brotli decompressorMichiel Visser
This implements the BrotliDecompressionStream, which is a Core::Stream that can decompress another Core::Stream.
2022-04-03LibCompress: Change DeflateSpecialCodeLengths to constexpr variablesLenny Maiorani
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-10Libraries: Use default constructors/destructors in LibCompressLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
2022-01-28Userland: Remove a bunch of unnecessary Vector importskleines Filmröllchen
How silly :^)
2022-01-07Everywhere: Fix many spelling errorsmjz19910
2021-11-11Everywhere: Pass AK::ReadonlyBytes by valueAndreas Kling
2021-10-06LibCompress: Add missing header to DeflateTables.hBen Wiederhake
2021-05-18LibCompress: Discard GZip NAME & COMMENT optional stringsIdan Horowitz
We now discard these strings instead of copying them into a String which we immediately destruct. This should result in both a perf uplift and lower memory usage.
2021-05-16LibCompress: Add missing #includeGunnar Beutner
This previously worked because <AK/ByteBuffer.h> included <AK/Optional.h> - and now it doesn't anymore.
2021-05-16Userland: Add missing #includesGunnar Beutner
These two header files relied on transitive header includes.
2021-05-07LibCompress: Add a method that describes a Gzip HeaderIdan Horowitz
This can be used to display information about a gzip file that is stored in it's header.
2021-05-06Tests: Move LibCompress tests to Tests/LibCompressBrian Gianforcaro
2021-04-29Everywhere: Use "the SerenityOS developers." in copyright headersLinus Groh
We had some inconsistencies before: - Sometimes "The", sometimes "the" - Sometimes trailing ".", sometimes no trailing "." I picked the most common one (lowecase "the", trailing ".") and applied it to all copyright headers. By using the exact same string everywhere we can ensure nothing gets missed during a global search (and replace), and that these inconsistencies are not spread any further (as copyright headers are commonly copied to new files).
2021-04-25AK+Userland: Move AK/TestSuite.h into LibTest and rework Tests' CMakeAndrew Kaster
As many macros as possible are moved to Macros.h, while the macros to create a test case are moved to TestCase.h. TestCase is now the only user-facing header for creating a test case. TestSuite and its helpers have moved into a .cpp file. Instead of requiring a TEST_MAIN macro to be instantiated into the test file, a TestMain.cpp file is provided instead that will be linked against each test. This has the side effect that, if we wanted to have test cases split across multiple files, it's as simple as adding them all to the same executable. The test main should be portable to kernel mode as well, so if there's a set of tests that should be run in self-test mode in kernel space, we can accomodate that. A new serenity_test CMake function streamlines adding a new test with arguments for the test source file, subdirectory under /usr/Tests to install the test application and an optional list of libraries to link against the test application. To accomodate future test where the provided TestMain.cpp is not suitable (e.g. test-js), a CUSTOM_MAIN parameter can be passed to the function to not link against the boilerplate main function.
2021-04-22AK+Userland: Use idan.horowitz@serenityos.org for my copyright headersIdan Horowitz
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-21Tests: Reorganize LibCompress unit testsMarco Biscaro
Move LibCompress unit tests to LibCompress/Tests directory and register them with CMake's add_test. This allows us to run these tests with ninja test instead of running a separate executable. Also split the existing tests in 3 test files that better follow the source code structure (inspired by AK tests).
2021-04-18Everywhere: Fix a bunch of typosLinus Groh
2021-03-21LibCompress: Convert GzipDecompressor from recursive to iterativeIdan Horowitz
This way a gzip compressed file that contains a large amount of small blocks wont cause a stack overflow.
2021-03-19LibCompress: Convert DeflateDecompressor from recursive to iterativeIdan Horowitz
This way a deflate blob that contains a large amount of small blocks wont cause a stack overflow.
2021-03-17LibCompress: fail gracefuly on invalid symbols in DeflateDecompressorIdan Horowitz
2021-03-17LibCompress: Check for impossible back references in DeflateDecompressorIdan Horowitz
This commit makes sure that we fail if an encoded lz77 back reference references bytes that are outside our sliding window, instead of just silently failing, which triggers an assertion down the line.
2021-03-16LibCompress: Fail gracefuly on missing huffman codes in DeflateDecompressorIdan Horowitz
2021-03-16LibCompress: Check and fail for input stream errors in DeflateDecompressorIdan Horowitz
Since we were not checking for error flags set by read_bits we would just always read 0 as the bits' value, which in some edge cases could lead to an infinite loop.
2021-03-16LibCompress: Allow partial header reads in GzipDecompressorIdan Horowitz
We now read the header into a temporary header byte array that is used as the header once its filled up by the input stream, instead of just ending the stream if we are out of bytes mid header.
2021-03-16LibCompress: Handle and propagate stream errors in GzipDecompressorIdan Horowitz
This commit makes read short-circuit if its input stream errored, as well as propagate error handling to wrapped sub streams, similarly to DeflateDecompressor.
2021-03-16LibCompress+AK: Dont short-circuit error handling propagationIdan Horowitz
In the case that both the stream and the wrapped substream had errors to be handled only one of the two would be resolved due to boolean short circuiting. this commit ensures both are handled irregardless of one another.
2021-03-15LibCompress+AK: Propagate error handling to wrapped streamsIdan Horowitz
This ensures that when a DeflateCompressor stream is cleared of any errors its underlying wrapped streams (InputBitStream/InputMemoryStream) will be cleared as well and wont fail a VERIFY on destruction.
2021-03-15LibCompress: Make the Zlib decompressor fail gracefulyIdan Horowitz
This commit adds a verify-less try_create method to the Zlib decompressor to allow for graceful failures of parsing the Zlib headers.
2021-03-14LibCompress: Decrease CanonicalCode's size on stackIdan Horowitz
This commit stores the bit codes as u16s instead of u32s as the maximum code bit length in DEFLATE is 15.
2021-03-14LibCompress: Handle literal only lz77 streams in DeflateCompressorIdan Horowitz
Very incompressible data could sometimes produce no backreferences which would result in no distance huffman code being created (as it was not needed), so VERIFY the code exists only if it is actually needed for writing the stream.
2021-03-13LibCompress: Replace goto with simple recursion in DeflateCompressorIdan Horowitz
This is just a bit easier on the eyes :^)
2021-03-13LibCompress: Implement GZip compressionIdan Horowitz
This commit implements a stream compressor for the gzip specification (RFC 1952), which is essentially a thin wrapper around the DEFLATE compression format.
2021-03-13LibCompress: Implement DEFLATE compressionIdan Horowitz
This commit adds a fully functional DEFLATE compression implementation that can be used to implement compression for higher level formats like gzip, zlib or zip. A large part of this commit is based on Hans Wennborg's great article about the DEFLATE and zip specifications: https://www.hanshq.net/zip.html
2021-03-12Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)Andreas Kling
Good-bye LogStream. Long live AK::Format!
2021-03-07LibCompress: Rename libcompression.so to libcompress.soJelle Raaijmakers
2021-03-03LibCore+LibHTTP+LibGfx: Switch to LibCompressIdan Horowitz
This commit removes the only 3rd party library (and its usages) in serenity: puff, which is used for deflate decompression. and replaces it with the existing original serenity implementation in LibCompress. :^)
2021-02-26Everywhere: Remove a bunch of redundant 'AK::' namespace prefixesLinus Groh
This is basically just for consistency, it's quite strange to see multiple AK container types next to each other, some with and some without the namespace prefix - we're 'using AK::Foo;' a lot and should leverage that. :^)
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.