• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

esaxx/H08-Dec-2020-

img/H03-May-2022-

libdivsufsort/H08-Dec-2020-

BUILDH A D08-Dec-2020788 4537

BUILD.libdivsufsortH A D08-Dec-20201.4 KiB5651

MakefileH A D08-Dec-2020300 1813

README.mdH A D08-Dec-20202.8 KiB6837

WORKSPACEH A D08-Dec-2020221 1310

brotli_decoder.cH A D08-Dec-20202.8 KiB9478

brotlidump.pyH A D08-Dec-202090.1 KiB2,3632,003

deorummolae.ccH A D08-Dec-20209.7 KiB303243

deorummolae.hH A D08-Dec-2020733 2711

dictionary_generator.ccH A D08-Dec-202010.7 KiB327300

draw_diff.ccH A D08-Dec-20203.2 KiB11891

draw_histogram.ccH A D08-Dec-20205.6 KiB198157

durchschlag.ccH A D08-Dec-202021.1 KiB727625

durchschlag.hH A D08-Dec-20203.5 KiB10038

find_opt_references.ccH A D08-Dec-20208.5 KiB268223

read_dist.hH A D08-Dec-20201.6 KiB5129

sieve.ccH A D08-Dec-20207.3 KiB260230

sieve.hH A D08-Dec-2020598 229

README.md

1## Introduction
2
3In this directory we publish simple tools to analyze backward reference distance distributions in LZ77 compression. We developed these tools to be able to make more efficient encoding of distances in large-window brotli. In large-window compression the average cost of a backward reference distance is higher, and this may allow for more advanced encoding strategies, such as delta coding or an increase in context size, to bring significant compression density improvements. Our tools visualize the backward references as histogram images, i.e., one pixel in the image shows how many distances of a certain range exist at a certain locality in the data. The human visual system is excellent at pattern detection, so we tried to roughly identify patterns visually before going into more quantitative analysis. These tools can turn out to be useful in development of  other LZ77-based compressors and we hope you try them out.
4
5
6## Tools
7### find\_opt\_references
8
9This tool generates optimal (match-length-wise) backward references for every position in the input files and stores them in `*.dist` file described below.
10
11Example usage:
12
13    find_opt_references input.txt output.dist
14
15### draw\_histogram
16
17This tool generates a visualization of the distribution of backward references stored in `*.dist` file. The original file size has to be specified as a second parameter. The output is a grayscale PGM (binary) image.
18
19Example usage:
20
21    draw_histogram input.dist 65536 output.pgm
22
23Here's an example of resulting image:
24
25![](img/enwik9_brotli.png)
26
27### draw\_diff
28
29This tool generates a diff PPM (binary) image between two input 8-bit PGM (binary) images. Input images must be of same size. Useful for comparing different backward references distributions for same input file. Normally used for comparison of output images from `draw_histogram` tool.
30
31Example usage:
32
33    draw_diff image1.pgm image2.pgm diff.ppm
34
35For example the diff of this image
36
37![](img/enwik9_brotli.png)
38
39and this image
40
41![](img/enwik9_opt.png)
42
43looks like this:
44
45![](img/enwik9_diff.png)
46
47
48## Backward distance file format
49
50The format of `*.dist` files is as follows:
51
52    [[     0| match length][     1|position|distance]...]
53     [1 byte|      4 bytes][1 byte| 4 bytes| 4 bytes]
54
55More verbose explanation: for each backward reference there is a position-distance pair, also a copy length may be specified. Copy length is prefixed with flag byte 0, position-distance pair is prefixed with flag byte 1. Each number is a 32-bit integer. Copy length always comes before position-distance pair. Standalone copy length is allowed, in this case it is ignored.
56
57Here's an example of how to read from `*.dist` file:
58
59```c++
60#include "read_dist.h"
61
62FILE* f;
63int copy, pos, dist;
64while (ReadBackwardReference(fin, &copy, &pos, &dist)) {
65   ...
66}
67```
68