openMSX
lz4.hh
Go to the documentation of this file.
1/*
2 * LZ4 - Fast LZ compression algorithm
3 * Header File
4 * Copyright (C) 2011-present, Yann Collet.
5
6 BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
7
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are
10 met:
11
12 * Redistributions of source code must retain the above copyright
13 notice, this list of conditions and the following disclaimer.
14 * Redistributions in binary form must reproduce the above
15 copyright notice, this list of conditions and the following disclaimer
16 in the documentation and/or other materials provided with the
17 distribution.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31 You can contact the author at :
32 - LZ4 homepage : http://www.lz4.org
33 - LZ4 source repository : https://github.com/lz4/lz4
34*/
35
36// Heavily modified by Wouter Vermaelen for use in openMSX.
37//
38// The most important changes are:
39// - Stripped out all functions we don't use.
40// - Removed all safety checks. We only decompress data returned from the
41// compress function, and that data is never stored/reloaded from disk.
42// - Rewrite in C++ style.
43// - Use existing openMSX helper functions.
44
45#ifndef LZ4_HH
46#define LZ4_HH
47
48#include <cstdint>
49
50namespace LZ4 {
51 [[nodiscard]] inline int compressBound(int iSize)
52 {
53 return iSize + (iSize / 255) + 16;
54 }
55
56 [[nodiscard]] int compress(const uint8_t* src, uint8_t* dst, int srcSize);
57 int decompress(const uint8_t* src, uint8_t* dst, int compressedSize, int dstCapacity);
58}
59
60#endif
Definition lz4.cc:24
int compressBound(int iSize)
Definition lz4.hh:51
int decompress(const uint8_t *src, uint8_t *dst, int compressedSize, int dstCapacity)
Definition lz4.cc:479
int compress(const uint8_t *src, uint8_t *dst, int srcSize)
Definition lz4.cc:455