15025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov/* Copyright 2015 Google Inc. All Rights Reserved. 25025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov 35025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov Distributed under MIT license. 45025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 55025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov*/ 65025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov 75025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikovpackage org.brotli.dec; 85025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov 95025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov/** 105025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov * Lookup tables to map prefix codes to value ranges. 115025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov * 125025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov * <p> This is used during decoding of the block lengths, literal insertion lengths and copy 135025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov * lengths. 145025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov * 155025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov * <p> Range represents values: [offset, offset + 2 ^ n_bits) 165025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov */ 175025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikovfinal class Prefix { 185025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov 195025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov static final int[] BLOCK_LENGTH_OFFSET = { 205025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov 1, 5, 9, 13, 17, 25, 33, 41, 49, 65, 81, 97, 113, 145, 177, 209, 241, 305, 369, 497, 215025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov 753, 1265, 2289, 4337, 8433, 16625 225025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov }; 235025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov 245025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov static final int[] BLOCK_LENGTH_N_BITS = { 255025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov 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 265025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov }; 275025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov 285025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov static final int[] INSERT_LENGTH_OFFSET = { 295025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov 0, 1, 2, 3, 4, 5, 6, 8, 10, 14, 18, 26, 34, 50, 66, 98, 130, 194, 322, 578, 1090, 2114, 6210, 305025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov 22594 315025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov }; 325025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov 335025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov static final int[] INSERT_LENGTH_N_BITS = { 345025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10, 12, 14, 24 355025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov }; 365025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov 375025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov static final int[] COPY_LENGTH_OFFSET = { 385025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 18, 22, 30, 38, 54, 70, 102, 134, 198, 326, 582, 1094, 395025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov 2118 405025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov }; 415025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov 425025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov static final int[] COPY_LENGTH_N_BITS = { 435025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10, 24 445025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov }; 455025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov 465025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov static final int[] INSERT_RANGE_LUT = { 475025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov 0, 0, 8, 8, 0, 16, 8, 16, 16 485025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov }; 495025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov 505025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov static final int[] COPY_RANGE_LUT = { 515025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov 0, 8, 0, 8, 16, 0, 16, 8, 16 525025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov }; 535025365d0fe5a5ca874574b952ef53cfa98ca5c1Eugene Kliuchnikov} 54