1/* Copyright 2015 Google Inc. All Rights Reserved. 2 3 Distributed under MIT license. 4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5*/ 6 7package org.brotli.dec; 8 9/** 10 * Lookup tables to map prefix codes to value ranges. 11 * 12 * <p> This is used during decoding of the block lengths, literal insertion lengths and copy 13 * lengths. 14 * 15 * <p> Range represents values: [offset, offset + 2 ^ n_bits) 16 */ 17final class Prefix { 18 19 static final int[] BLOCK_LENGTH_OFFSET = { 20 1, 5, 9, 13, 17, 25, 33, 41, 49, 65, 81, 97, 113, 145, 177, 209, 241, 305, 369, 497, 21 753, 1265, 2289, 4337, 8433, 16625 22 }; 23 24 static final int[] BLOCK_LENGTH_N_BITS = { 25 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 24 26 }; 27 28 static final int[] INSERT_LENGTH_OFFSET = { 29 0, 1, 2, 3, 4, 5, 6, 8, 10, 14, 18, 26, 34, 50, 66, 98, 130, 194, 322, 578, 1090, 2114, 6210, 30 22594 31 }; 32 33 static final int[] INSERT_LENGTH_N_BITS = { 34 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10, 12, 14, 24 35 }; 36 37 static final int[] COPY_LENGTH_OFFSET = { 38 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 18, 22, 30, 38, 54, 70, 102, 134, 198, 326, 582, 1094, 39 2118 40 }; 41 42 static final int[] COPY_LENGTH_N_BITS = { 43 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10, 24 44 }; 45 46 static final int[] INSERT_RANGE_LUT = { 47 0, 0, 8, 8, 0, 16, 8, 16, 16 48 }; 49 50 static final int[] COPY_RANGE_LUT = { 51 0, 8, 0, 8, 16, 0, 16, 8, 16 52 }; 53} 54