1 | /* lzo1x_d3.c -- LZO1X decompression with preset dictionary |
---|
2 | |
---|
3 | This file is part of the LZO real-time data compression library. |
---|
4 | |
---|
5 | Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer |
---|
6 | All Rights Reserved. |
---|
7 | |
---|
8 | The LZO library is free software; you can redistribute it and/or |
---|
9 | modify it under the terms of the GNU General Public License as |
---|
10 | published by the Free Software Foundation; either version 2 of |
---|
11 | the License, or (at your option) any later version. |
---|
12 | |
---|
13 | The LZO library is distributed in the hope that it will be useful, |
---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | GNU General Public License for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with the LZO library; see the file COPYING. |
---|
20 | If not, write to the Free Software Foundation, Inc., |
---|
21 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
22 | |
---|
23 | Markus F.X.J. Oberhumer |
---|
24 | <markus@oberhumer.com> |
---|
25 | http://www.oberhumer.com/opensource/lzo/ |
---|
26 | */ |
---|
27 | |
---|
28 | |
---|
29 | #include "config1x.h" |
---|
30 | |
---|
31 | #define LZO_TEST_OVERRUN 1 |
---|
32 | |
---|
33 | |
---|
34 | #define SLOW_MEMCPY(a,b,l) { do *a++ = *b++; while (--l > 0); } |
---|
35 | #define FAST_MEMCPY(a,b,l) { lzo_memcpy(a,b,l); a += l; } |
---|
36 | |
---|
37 | #if 1 && defined(FAST_MEMCPY) |
---|
38 | # define DICT_MEMMOVE(op,m_pos,m_len,m_off) \ |
---|
39 | if (m_off >= (m_len)) \ |
---|
40 | FAST_MEMCPY(op,m_pos,m_len) \ |
---|
41 | else \ |
---|
42 | SLOW_MEMCPY(op,m_pos,m_len) |
---|
43 | #else |
---|
44 | # define DICT_MEMMOVE(op,m_pos,m_len,m_off) \ |
---|
45 | SLOW_MEMCPY(op,m_pos,m_len) |
---|
46 | #endif |
---|
47 | |
---|
48 | #if !defined(FAST_MEMCPY) |
---|
49 | # define FAST_MEMCPY SLOW_MEMCPY |
---|
50 | #endif |
---|
51 | |
---|
52 | |
---|
53 | #define COPY_DICT_DICT(m_len,m_off) \ |
---|
54 | { \ |
---|
55 | const lzo_bytep m_pos; \ |
---|
56 | m_off -= pd(op, out); assert(m_off > 0); \ |
---|
57 | if (m_off > dict_len) goto lookbehind_overrun; \ |
---|
58 | m_pos = dict_end - m_off; \ |
---|
59 | if (m_len > m_off) \ |
---|
60 | { \ |
---|
61 | m_len -= m_off; \ |
---|
62 | FAST_MEMCPY(op,m_pos,m_off) \ |
---|
63 | m_pos = out; \ |
---|
64 | SLOW_MEMCPY(op,m_pos,m_len) \ |
---|
65 | } \ |
---|
66 | else \ |
---|
67 | FAST_MEMCPY(op,m_pos,m_len) \ |
---|
68 | } |
---|
69 | |
---|
70 | #define COPY_DICT(m_len,m_off) \ |
---|
71 | assert(m_len >= 2); assert(m_off > 0); assert(op > out); \ |
---|
72 | if (m_off <= pd(op, out)) \ |
---|
73 | { \ |
---|
74 | const lzo_bytep m_pos = op - m_off; \ |
---|
75 | DICT_MEMMOVE(op,m_pos,m_len,m_off) \ |
---|
76 | } \ |
---|
77 | else \ |
---|
78 | COPY_DICT_DICT(m_len,m_off) |
---|
79 | |
---|
80 | |
---|
81 | |
---|
82 | |
---|
83 | LZO_PUBLIC(int) |
---|
84 | lzo1x_decompress_dict_safe ( const lzo_bytep in, lzo_uint in_len, |
---|
85 | lzo_bytep out, lzo_uintp out_len, |
---|
86 | lzo_voidp wrkmem /* NOT USED */, |
---|
87 | const lzo_bytep dict, lzo_uint dict_len) |
---|
88 | |
---|
89 | |
---|
90 | #include "lzo1x_d.ch" |
---|
91 | |
---|
92 | |
---|
93 | /* |
---|
94 | vi:ts=4:et |
---|
95 | */ |
---|
96 | |
---|