1 package net.jpountz.lz4;
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 import static net.jpountz.lz4.LZ4Constants.HASH_LOG;
18 import static net.jpountz.lz4.LZ4Constants.HASH_LOG_64K;
19 import static net.jpountz.lz4.LZ4Constants.HASH_LOG_HC;
20 import static net.jpountz.lz4.LZ4Constants.MIN_MATCH;
25 private static final int MAX_INPUT_SIZE = 0x7E000000;
27 static int maxCompressedLength(int length) {
29 throw new IllegalArgumentException("length must be >= 0, got " + length);
30 } else if (length >= MAX_INPUT_SIZE) {
31 throw new IllegalArgumentException("length must be < " + MAX_INPUT_SIZE);
33 return length + length / 255 + 16;
36 static int hash(int i) {
37 return (i * -1640531535) >>> ((MIN_MATCH * 8) - HASH_LOG);
40 static int hash64k(int i) {
41 return (i * -1640531535) >>> ((MIN_MATCH * 8) - HASH_LOG_64K);
44 static int hashHC(int i) {
45 return (i * -1640531535) >>> ((MIN_MATCH * 8) - HASH_LOG_HC);
51 void fix(int correction) {
62 static void copyTo(Match m1, Match m2) {