Debian Codegraph @

src/org/tukaani/xz/lzma/Optimum.java

raw symbols SCIP
1 // SPDX-License-Identifier: 0BSD
2 // SPDX-FileCopyrightText: The XZ for Java authors and contributors
3 // SPDX-FileContributor: Lasse Collin <[email protected]>
4 // SPDX-FileContributor: Igor Pavlov <https://7-zip.org/>
5
6 package org.tukaani.xz.lzma;
7
8 final class Optimum {
9 private static final int INFINITY_PRICE = 1 << 30;
10
11 final State state = new State();
12 final int[] reps = new int[LZMACoder.REPS];
13
14 /**
15 * Cumulative price of arriving to this byte.
16 */
17 int price;
18
19 int optPrev;
20 int backPrev;
21 boolean prev1IsLiteral;
22
23 boolean hasPrev2;
24 int optPrev2;
25 int backPrev2;
26
27 /**
28 * Resets the price.
29 */
30 void reset() {
31 price = INFINITY_PRICE;
32 }
33
34 /**
35 * Sets to indicate one LZMA symbol (literal, rep, or match).
36 */
37 void set1(int newPrice, int optCur, int back) {
38 price = newPrice;
39 optPrev = optCur;
40 backPrev = back;
41 prev1IsLiteral = false;
42 }
43
44 /**
45 * Sets to indicate two LZMA symbols of which the first one is a literal.
46 */
47 void set2(int newPrice, int optCur, int back) {
48 price = newPrice;
49 optPrev = optCur + 1;
50 backPrev = back;
51 prev1IsLiteral = true;
52 hasPrev2 = false;
53 }
54
55 /**
56 * Sets to indicate three LZMA symbols of which the second one
57 * is a literal.
58 */
59 void set3(int newPrice, int optCur, int back2, int len2, int back) {
60 price = newPrice;
61 optPrev = optCur + len2 + 1;
62 backPrev = back;
63 prev1IsLiteral = true;
64 hasPrev2 = true;
65 optPrev2 = optCur;
66 backPrev2 = back2;
67 }
68 }