openMSX
snappy.hh
Go to the documentation of this file.
1 //
3 // Copyright 2005 and onwards Google Inc.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
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 // A light-weight compression algorithm. It is designed for speed of
32 // compression and decompression, rather than for the utmost in space
33 // savings.
34 //
35 // For getting better compression ratios when you are compressing data
36 // with long repeated sequences or compressing data that is similar to
37 // other data, while still compressing fast, you might look at first
38 // using BMDiff and then compressing the output of BMDiff with
39 // Snappy.
40 //
42 //
43 // The snappy code is modified quite a bit for openMSX. The original
44 // verion can be obtained here:
45 // http://code.google.com/p/snappy/
46 //
47 // The main difference are:
48 // - Rewritten to reuse existing openMSX helper functions and style.
49 // - Removed possibility to operate on chunks of data, the current code
50 // requires the full to-be-(de)compressed memory block in one go.
51 // - Removed all safety checks during decompression. The original code
52 // would return an error on invalid input, this code will crash on
53 // such input (but that shouldn't happen because we only feed input
54 // that was previously produced by the compression routine (and always
55 // keeping that compressed block in memory).
56 // The motivation for this rewrite is to:
57 // - Reduce code duplication between the snappy code and the rest of
58 // openMSX.
59 // - Gain some extra speed at the expense of flexibility (which we don't
60 // need in openMSX).
61 //
63 
64 #ifndef SNAPPY_HH
65 #define SNAPPY_HH
66 
67 #include <cstddef>
68 
69 namespace snappy {
70  void compress(const char* input, size_t inLen,
71  char* output, size_t& outLen);
72  void uncompress(const char* input, size_t inLen,
73  char* output, size_t outLen);
74  size_t maxCompressedLength(size_t inLen);
75 }
76 
77 #endif
Definition: snappy.cc:13
size_t maxCompressedLength(size_t inLen)
Definition: snappy.cc:616
void compress(const char *input, size_t inLen, char *output, size_t &outLen)
Definition: snappy.cc:603
void uncompress(const char *input, size_t inLen, char *output, size_t outLen)
Definition: snappy.cc:166