1 /* lzo1b_r.ch -- literal run handling for the the LZO1B/LZO1C 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 /***********************************************************************
30 // store a literal run (internal)
31 ************************************************************************/
33 LZO_LOCAL_IMPL(lzo_bytep )
34 STORE_RUN ( lzo_bytep const oo, const lzo_bytep const ii, lzo_uint r_len)
40 LZO_STATS(lzo_stats->literals += r_len);
46 /* code a long R0 run */
49 unsigned r_bits = 6; /* 256 << 6 == 16384 */
52 while (r_len >= (t = tt))
55 *op++ = 0; *op++ = (R0FAST - R0MIN) + 7;
56 MEMCPY8_DS(op, ip, t);
57 LZO_STATS(lzo_stats->r0long_runs++);
61 if (r_len >= (t = tt))
64 *op++ = 0; *op++ = LZO_BYTE((R0FAST - R0MIN) + r_bits);
65 MEMCPY8_DS(op, ip, t);
66 LZO_STATS(lzo_stats->r0long_runs++);
69 } while (--r_bits > 0);
73 while (r_len >= (t = R0FAST))
76 *op++ = 0; *op++ = (R0FAST - R0MIN);
77 MEMCPY8_DS(op, ip, t);
78 LZO_STATS(lzo_stats->r0fast_runs++);
84 /* code a short R0 run */
85 *op++ = 0; *op++ = LZO_BYTE(t - R0MIN);
87 LZO_STATS(lzo_stats->r0short_runs++);
91 /* code a short literal run */
92 LZO_STATS(lzo_stats->lit_runs++);
93 LZO_STATS(lzo_stats->lit_run[t]++);
102 /* vim:set ts=4 sw=4 et: */