Debian Codegraph @

snappy/snappy.go

raw symbols SCIP
1 // Copyright 2011 The Snappy-Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // Package snappy implements the snappy block-based compression format.
6 // It aims for very high speeds and reasonable compression.
7 //
8 // The C++ snappy implementation is at http://code.google.com/p/snappy/
9 package snappy
10
11 /*
12 Each encoded block begins with the varint-encoded length of the decoded data,
13 followed by a sequence of chunks. Chunks begin and end on byte boundaries. The
14 first byte of each chunk is broken into its 2 least and 6 most significant bits
15 called l and m: l ranges in [0, 4) and m ranges in [0, 64). l is the chunk tag.
16 Zero means a literal tag. All other values mean a copy tag.
17
18 For literal tags:
19 - If m < 60, the next 1 + m bytes are literal bytes.
20 - Otherwise, let n be the little-endian unsigned integer denoted by the next
21 m - 59 bytes. The next 1 + n bytes after that are literal bytes.
22
23 For copy tags, length bytes are copied from offset bytes ago, in the style of
24 Lempel-Ziv compression algorithms. In particular:
25 - For l == 1, the offset ranges in [0, 1<<11) and the length in [4, 12).
26 The length is 4 + the low 3 bits of m. The high 3 bits of m form bits 8-10
27 of the offset. The next byte is bits 0-7 of the offset.
28 - For l == 2, the offset ranges in [0, 1<<16) and the length in [1, 65).
29 The length is 1 + m. The offset is the little-endian unsigned integer
30 denoted by the next 2 bytes.
31 - For l == 3, this tag is a legacy format that is no longer supported.
32 */
33 const (
34 tagLiteral = 0x00
35 tagCopy1 = 0x01
36 tagCopy2 = 0x02
37 tagCopy4 = 0x03
38 )