source: josm/trunk/src/org/tukaani/xz/lzma/Optimum.java@ 13472

Last change on this file since 13472 was 13350, checked in by stoecker, 6 years ago

see #15816 - add XZ support

File size: 1.6 KB
Line 
1/*
2 * Optimum
3 *
4 * Authors: Lasse Collin <lasse.collin@tukaani.org>
5 * Igor Pavlov <http://7-zip.org/>
6 *
7 * This file has been put into the public domain.
8 * You can do whatever you want with this file.
9 */
10
11package org.tukaani.xz.lzma;
12
13final class Optimum {
14 private static final int INFINITY_PRICE = 1 << 30;
15
16 final State state = new State();
17 final int[] reps = new int[LZMACoder.REPS];
18
19 /**
20 * Cumulative price of arriving to this byte.
21 */
22 int price;
23
24 int optPrev;
25 int backPrev;
26 boolean prev1IsLiteral;
27
28 boolean hasPrev2;
29 int optPrev2;
30 int backPrev2;
31
32 /**
33 * Resets the price.
34 */
35 void reset() {
36 price = INFINITY_PRICE;
37 }
38
39 /**
40 * Sets to indicate one LZMA symbol (literal, rep, or match).
41 */
42 void set1(int newPrice, int optCur, int back) {
43 price = newPrice;
44 optPrev = optCur;
45 backPrev = back;
46 prev1IsLiteral = false;
47 }
48
49 /**
50 * Sets to indicate two LZMA symbols of which the first one is a literal.
51 */
52 void set2(int newPrice, int optCur, int back) {
53 price = newPrice;
54 optPrev = optCur + 1;
55 backPrev = back;
56 prev1IsLiteral = true;
57 hasPrev2 = false;
58 }
59
60 /**
61 * Sets to indicate three LZMA symbols of which the second one
62 * is a literal.
63 */
64 void set3(int newPrice, int optCur, int back2, int len2, int back) {
65 price = newPrice;
66 optPrev = optCur + len2 + 1;
67 backPrev = back;
68 prev1IsLiteral = true;
69 hasPrev2 = true;
70 optPrev2 = optCur;
71 backPrev2 = back2;
72 }
73}
Note: See TracBrowser for help on using the repository browser.