1 /* lzo1a_cr.ch -- literal run handling for the the LZO1A algorithm
3 This file is part of the LZO real-time data compression library.
5 Copyright (C) 1996-2015 Markus Franz Xaver Johannes Oberhumer
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.
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.
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.
23 Markus F.X.J. Oberhumer
24 <markus@oberhumer.com>
25 http://www.oberhumer.com/opensource/lzo/
29 /* WARNING: this file should *not* be used by applications. It is
30 part of the implementation of the LZO package and is subject
36 #define __LZO1A_CR_H 1
39 /***********************************************************************
41 ************************************************************************/
44 store_run(lzo_bytep const oo, const lzo_bytep const ii, lzo_uint r_len)
54 /* code a long R0 run */
57 unsigned r_bits = 6; /* 256 << 6 == 16384 */
60 while (r_len >= (t = tt))
63 *op++ = 0; *op++ = (R0MAX - R0MIN);
64 MEMCPY8_DS(op, ip, t);
65 LZO_STATS(lzo_stats->r0long_runs++);
69 if (r_len >= (t = tt))
72 *op++ = 0; *op++ = LZO_BYTE((R0FAST - R0MIN) + r_bits);
73 MEMCPY8_DS(op, ip, t);
74 LZO_STATS(lzo_stats->r0long_runs++);
77 } while (--r_bits > 0);
81 while (r_len >= (t = R0FAST))
84 *op++ = 0; *op++ = (R0FAST - R0MIN);
85 MEMCPY8_DS(op, ip, t);
86 LZO_STATS(lzo_stats->r0fast_runs++);
92 /* code a short R0 run */
93 *op++ = 0; *op++ = LZO_BYTE(t - R0MIN);
95 LZO_STATS(lzo_stats->r0short_runs++);
99 /* code a short literal run */
100 LZO_STATS(lzo_stats->lit_runs++);
101 LZO_STATS(lzo_stats->lit_run[t]++);
103 MEMCPY_DS(op, ip, t);
111 #endif /* already included */
114 /* vim:set ts=4 sw=4 et: */