1 /* lzo1b_cr.ch -- implementation of the LZO1B compression 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 library and is subject
36 /***********************************************************************
37 // store the current literal run
38 ************************************************************************/
43 lzo_uint t = pd(ip,ii);
45 #if defined(LZO_HAVE_R1)
48 /* Code a context sensitive R1 match. */
49 LZO_STATS(lzo_stats->literals += t);
50 LZO_STATS(lzo_stats->r1_matches++);
52 /* modify marker byte */
53 assert((op[-2] >> M2O_BITS) == (M2_MARKER >> M2O_BITS));
55 assert((op[-2] >> M2O_BITS) == 0);
58 r1 = ip + (M2_MIN_LEN + 1); /* set new R1 pointer */
64 /* inline the copying of a short run */
65 LZO_STATS(lzo_stats->literals += t);
66 LZO_STATS(lzo_stats->lit_runs++);
67 LZO_STATS(lzo_stats->lit_run[t]++);
68 #if defined(LZO_HAVE_M3)
69 if (t < LZO_SIZE(8-M3O_BITS) && op == m3)
71 /* Code a very short literal run into the low offset bits
72 * of the previous M3/M4 match.
74 LZO_STATS(lzo_stats->lit_runs_after_m3_match++);
75 LZO_STATS(lzo_stats->lit_run_after_m3_match[t]++);
76 assert((m3[-2] >> M3O_BITS) == 0);
77 m3[-2] = LZO_BYTE(m3[-2] | (t << M3O_BITS));
85 #if defined(LZO_HAVE_R1)
86 r1 = ip + (M2_MIN_LEN + 1); /* set new R1 pointer */
91 /* inline the copying of a short R0 run */
92 LZO_STATS(lzo_stats->literals += t);
93 LZO_STATS(lzo_stats->r0short_runs++);
94 *op++ = 0; *op++ = LZO_BYTE(t - R0MIN);
96 #if defined(LZO_HAVE_R1)
97 r1 = ip + (M2_MIN_LEN + 1); /* set new R1 pointer */
102 op = STORE_RUN(op,ii,t);
108 /* ii now points to the start of the current match */
112 /* vim:set ts=4 sw=4 et: */