diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /contrib/libs/brotli | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) | |
download | ydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/brotli')
33 files changed, 2336 insertions, 2336 deletions
diff --git a/contrib/libs/brotli/LICENSE b/contrib/libs/brotli/LICENSE index 981ec3b4f3..33b7cdd2db 100644 --- a/contrib/libs/brotli/LICENSE +++ b/contrib/libs/brotli/LICENSE @@ -1,15 +1,15 @@ Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors. - + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE diff --git a/contrib/libs/brotli/README.md b/contrib/libs/brotli/README.md index 3874ddfa0f..6b9b0cf0e1 100644 --- a/contrib/libs/brotli/README.md +++ b/contrib/libs/brotli/README.md @@ -1,19 +1,19 @@ <p align="center"><img src="https://brotli.org/brotli.svg" alt="Brotli" width="64"></p> - + ### Introduction -Brotli is a generic-purpose lossless compression algorithm that compresses data -using a combination of a modern variant of the LZ77 algorithm, Huffman coding -and 2nd order context modeling, with a compression ratio comparable to the best -currently available general-purpose compression methods. It is similar in speed -with deflate but offers more dense compression. - +Brotli is a generic-purpose lossless compression algorithm that compresses data +using a combination of a modern variant of the LZ77 algorithm, Huffman coding +and 2nd order context modeling, with a compression ratio comparable to the best +currently available general-purpose compression methods. It is similar in speed +with deflate but offers more dense compression. + The specification of the Brotli Compressed Data Format is defined in [RFC 7932](https://tools.ietf.org/html/rfc7932). - + Brotli is open-sourced under the MIT License, see the LICENSE file. - -Brotli mailing list: -https://groups.google.com/forum/#!forum/brotli + +Brotli mailing list: +https://groups.google.com/forum/#!forum/brotli [![TravisCI Build Status](https://travis-ci.org/google/brotli.svg?branch=master)](https://travis-ci.org/google/brotli) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/google/brotli?branch=master&svg=true)](https://ci.appveyor.com/project/szabadka/brotli) diff --git a/contrib/libs/brotli/common/ya.make b/contrib/libs/brotli/common/ya.make index 7419a29f5a..6c4157831c 100644 --- a/contrib/libs/brotli/common/ya.make +++ b/contrib/libs/brotli/common/ya.make @@ -1,6 +1,6 @@ LIBRARY() -LICENSE(MIT) +LICENSE(MIT) LICENSE_TEXTS(.yandex_meta/licenses.list.txt) diff --git a/contrib/libs/brotli/dec/bit_reader.c b/contrib/libs/brotli/dec/bit_reader.c index a685fca6c2..722fd906dd 100644 --- a/contrib/libs/brotli/dec/bit_reader.c +++ b/contrib/libs/brotli/dec/bit_reader.c @@ -1,25 +1,25 @@ -/* Copyright 2013 Google Inc. All Rights Reserved. - +/* Copyright 2013 Google Inc. All Rights Reserved. + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT -*/ - -/* Bit reading helpers */ - +*/ + +/* Bit reading helpers */ + #include "./bit_reader.h" - + #include "../common/platform.h" #include <brotli/types.h> - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - + +#if defined(__cplusplus) || defined(c_plusplus) +extern "C" { +#endif + void BrotliInitBitReader(BrotliBitReader* const br) { - br->val_ = 0; - br->bit_pos_ = sizeof(br->val_) << 3; -} - + br->val_ = 0; + br->bit_pos_ = sizeof(br->val_) << 3; +} + BROTLI_BOOL BrotliWarmupBitReader(BrotliBitReader* const br) { size_t aligned_read_mask = (sizeof(br->val_) >> 1) - 1; /* Fixing alignment after unaligned BrotliFillWindow would result accumulator @@ -31,8 +31,8 @@ BROTLI_BOOL BrotliWarmupBitReader(BrotliBitReader* const br) { if (BrotliGetAvailableBits(br) == 0) { if (!BrotliPullByte(br)) { return BROTLI_FALSE; - } - } + } + } while ((((size_t)br->next_in) & aligned_read_mask) != 0) { if (!BrotliPullByte(br)) { @@ -41,8 +41,8 @@ BROTLI_BOOL BrotliWarmupBitReader(BrotliBitReader* const br) { } } return BROTLI_TRUE; -} - -#if defined(__cplusplus) || defined(c_plusplus) +} + +#if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ -#endif +#endif diff --git a/contrib/libs/brotli/dec/bit_reader.h b/contrib/libs/brotli/dec/bit_reader.h index 732072bfdd..c06e91419f 100644 --- a/contrib/libs/brotli/dec/bit_reader.h +++ b/contrib/libs/brotli/dec/bit_reader.h @@ -1,25 +1,25 @@ -/* Copyright 2013 Google Inc. All Rights Reserved. - +/* Copyright 2013 Google Inc. All Rights Reserved. + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT -*/ - -/* Bit reading helpers */ - -#ifndef BROTLI_DEC_BIT_READER_H_ -#define BROTLI_DEC_BIT_READER_H_ - +*/ + +/* Bit reading helpers */ + +#ifndef BROTLI_DEC_BIT_READER_H_ +#define BROTLI_DEC_BIT_READER_H_ + #include <string.h> /* memcpy */ - + #include "../common/platform.h" #include <brotli/types.h> - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - + +#if defined(__cplusplus) || defined(c_plusplus) +extern "C" { +#endif + #define BROTLI_SHORT_FILL_BIT_WINDOW_READ (sizeof(brotli_reg_t) >> 1) - + static const uint32_t kBitMask[33] = { 0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000F, 0x0000001F, 0x0000003F, 0x0000007F, 0x000000FF, @@ -30,7 +30,7 @@ static const uint32_t kBitMask[33] = { 0x00000000, 0x01FFFFFF, 0x03FFFFFF, 0x07FFFFFF, 0x0FFFFFFF, 0x1FFFFFFF, 0x3FFFFFFF, 0x7FFFFFFF, 0xFFFFFFFF }; - + static BROTLI_INLINE uint32_t BitMask(uint32_t n) { if (BROTLI_IS_CONSTANT(n) || BROTLI_HAS_UBFX) { /* Masking with this expression turns to a single @@ -41,20 +41,20 @@ static BROTLI_INLINE uint32_t BitMask(uint32_t n) { } } -typedef struct { +typedef struct { brotli_reg_t val_; /* pre-fetched bits */ uint32_t bit_pos_; /* current bit-reading position in val_ */ const uint8_t* next_in; /* the byte we're reading from */ size_t avail_in; -} BrotliBitReader; - +} BrotliBitReader; + typedef struct { brotli_reg_t val_; uint32_t bit_pos_; const uint8_t* next_in; size_t avail_in; } BrotliBitReaderState; - + /* Initializes the BrotliBitReader fields. */ BROTLI_INTERNAL void BrotliInitBitReader(BrotliBitReader* const br); @@ -64,7 +64,7 @@ BROTLI_INTERNAL void BrotliInitBitReader(BrotliBitReader* const br); For BROTLI_ALIGNED_READ this function also prepares bit reader for aligned reading. */ BROTLI_INTERNAL BROTLI_BOOL BrotliWarmupBitReader(BrotliBitReader* const br); - + static BROTLI_INLINE void BrotliBitReaderSaveState( BrotliBitReader* const from, BrotliBitReaderState* to) { to->val_ = from->val_; @@ -72,7 +72,7 @@ static BROTLI_INLINE void BrotliBitReaderSaveState( to->next_in = from->next_in; to->avail_in = from->avail_in; } - + static BROTLI_INLINE void BrotliBitReaderRestoreState( BrotliBitReader* const to, BrotliBitReaderState* from) { to->val_ = from->val_; @@ -80,15 +80,15 @@ static BROTLI_INLINE void BrotliBitReaderRestoreState( to->next_in = from->next_in; to->avail_in = from->avail_in; } - + static BROTLI_INLINE uint32_t BrotliGetAvailableBits( const BrotliBitReader* br) { return (BROTLI_64_BITS ? 64 : 32) - br->bit_pos_; -} - -/* Returns amount of unread bytes the bit reader still has buffered from the - BrotliInput, including whole bytes in br->val_. */ -static BROTLI_INLINE size_t BrotliGetRemainingBytes(BrotliBitReader* br) { +} + +/* Returns amount of unread bytes the bit reader still has buffered from the + BrotliInput, including whole bytes in br->val_. */ +static BROTLI_INLINE size_t BrotliGetRemainingBytes(BrotliBitReader* br) { return br->avail_in + (BrotliGetAvailableBits(br) >> 3); } @@ -100,59 +100,59 @@ static BROTLI_INLINE BROTLI_BOOL BrotliCheckInputAmount( } /* Guarantees that there are at least |n_bits| + 1 bits in accumulator. - Precondition: accumulator contains at least 1 bit. + Precondition: accumulator contains at least 1 bit. |n_bits| should be in the range [1..24] for regular build. For portable non-64-bit little-endian build only 16 bits are safe to request. */ -static BROTLI_INLINE void BrotliFillBitWindow( +static BROTLI_INLINE void BrotliFillBitWindow( BrotliBitReader* const br, uint32_t n_bits) { #if (BROTLI_64_BITS) if (!BROTLI_ALIGNED_READ && BROTLI_IS_CONSTANT(n_bits) && (n_bits <= 8)) { - if (br->bit_pos_ >= 56) { - br->val_ >>= 56; - br->bit_pos_ ^= 56; /* here same as -= 56 because of the if condition */ + if (br->bit_pos_ >= 56) { + br->val_ >>= 56; + br->bit_pos_ ^= 56; /* here same as -= 56 because of the if condition */ br->val_ |= BROTLI_UNALIGNED_LOAD64LE(br->next_in) << 8; - br->avail_in -= 7; - br->next_in += 7; - } + br->avail_in -= 7; + br->next_in += 7; + } } else if ( !BROTLI_ALIGNED_READ && BROTLI_IS_CONSTANT(n_bits) && (n_bits <= 16)) { - if (br->bit_pos_ >= 48) { - br->val_ >>= 48; - br->bit_pos_ ^= 48; /* here same as -= 48 because of the if condition */ + if (br->bit_pos_ >= 48) { + br->val_ >>= 48; + br->bit_pos_ ^= 48; /* here same as -= 48 because of the if condition */ br->val_ |= BROTLI_UNALIGNED_LOAD64LE(br->next_in) << 16; - br->avail_in -= 6; - br->next_in += 6; - } - } else { - if (br->bit_pos_ >= 32) { - br->val_ >>= 32; - br->bit_pos_ ^= 32; /* here same as -= 32 because of the if condition */ + br->avail_in -= 6; + br->next_in += 6; + } + } else { + if (br->bit_pos_ >= 32) { + br->val_ >>= 32; + br->bit_pos_ ^= 32; /* here same as -= 32 because of the if condition */ br->val_ |= ((uint64_t)BROTLI_UNALIGNED_LOAD32LE(br->next_in)) << 32; br->avail_in -= BROTLI_SHORT_FILL_BIT_WINDOW_READ; br->next_in += BROTLI_SHORT_FILL_BIT_WINDOW_READ; - } - } + } + } #else if (!BROTLI_ALIGNED_READ && BROTLI_IS_CONSTANT(n_bits) && (n_bits <= 8)) { - if (br->bit_pos_ >= 24) { - br->val_ >>= 24; - br->bit_pos_ ^= 24; /* here same as -= 24 because of the if condition */ + if (br->bit_pos_ >= 24) { + br->val_ >>= 24; + br->bit_pos_ ^= 24; /* here same as -= 24 because of the if condition */ br->val_ |= BROTLI_UNALIGNED_LOAD32LE(br->next_in) << 8; - br->avail_in -= 3; - br->next_in += 3; - } - } else { - if (br->bit_pos_ >= 16) { - br->val_ >>= 16; - br->bit_pos_ ^= 16; /* here same as -= 16 because of the if condition */ + br->avail_in -= 3; + br->next_in += 3; + } + } else { + if (br->bit_pos_ >= 16) { + br->val_ >>= 16; + br->bit_pos_ ^= 16; /* here same as -= 16 because of the if condition */ br->val_ |= ((uint32_t)BROTLI_UNALIGNED_LOAD16LE(br->next_in)) << 16; br->avail_in -= BROTLI_SHORT_FILL_BIT_WINDOW_READ; br->next_in += BROTLI_SHORT_FILL_BIT_WINDOW_READ; - } - } -#endif -} - + } + } +#endif +} + /* Mostly like BrotliFillBitWindow, but guarantees only 16 bits and reads no more than BROTLI_SHORT_FILL_BIT_WINDOW_READ bytes of input. */ static BROTLI_INLINE void BrotliFillBitWindow16(BrotliBitReader* const br) { @@ -165,25 +165,25 @@ static BROTLI_INLINE BROTLI_BOOL BrotliPullByte(BrotliBitReader* const br) { if (br->avail_in == 0) { return BROTLI_FALSE; } - br->val_ >>= 8; + br->val_ >>= 8; #if (BROTLI_64_BITS) br->val_ |= ((uint64_t)*br->next_in) << 56; -#else +#else br->val_ |= ((uint32_t)*br->next_in) << 24; -#endif - br->bit_pos_ -= 8; - --br->avail_in; - ++br->next_in; +#endif + br->bit_pos_ -= 8; + --br->avail_in; + ++br->next_in; return BROTLI_TRUE; -} - +} + /* Returns currently available bits. The number of valid bits could be calculated by BrotliGetAvailableBits. */ static BROTLI_INLINE brotli_reg_t BrotliGetBitsUnmasked( BrotliBitReader* const br) { return br->val_ >> br->bit_pos_; -} - +} + /* Like BrotliGetBits, but does not mask the result. The result contains at least 16 valid bits. */ static BROTLI_INLINE uint32_t BrotliGet16BitsUnmasked( @@ -194,12 +194,12 @@ static BROTLI_INLINE uint32_t BrotliGet16BitsUnmasked( /* Returns the specified number of bits from |br| without advancing bit position. */ -static BROTLI_INLINE uint32_t BrotliGetBits( +static BROTLI_INLINE uint32_t BrotliGetBits( BrotliBitReader* const br, uint32_t n_bits) { - BrotliFillBitWindow(br, n_bits); + BrotliFillBitWindow(br, n_bits); return (uint32_t)BrotliGetBitsUnmasked(br) & BitMask(n_bits); -} - +} + /* Tries to peek the specified amount of bits. Returns BROTLI_FALSE, if there is not enough input. */ static BROTLI_INLINE BROTLI_BOOL BrotliSafeGetBits( @@ -214,11 +214,11 @@ static BROTLI_INLINE BROTLI_BOOL BrotliSafeGetBits( } /* Advances the bit pos by |n_bits|. */ -static BROTLI_INLINE void BrotliDropBits( +static BROTLI_INLINE void BrotliDropBits( BrotliBitReader* const br, uint32_t n_bits) { br->bit_pos_ += n_bits; -} - +} + static BROTLI_INLINE void BrotliBitReaderUnload(BrotliBitReader* br) { uint32_t unused_bytes = BrotliGetAvailableBits(br) >> 3; uint32_t unused_bits = unused_bytes << 3; @@ -234,17 +234,17 @@ static BROTLI_INLINE void BrotliBitReaderUnload(BrotliBitReader* br) { /* Reads the specified number of bits from |br| and advances the bit pos. Precondition: accumulator MUST contain at least |n_bits|. */ -static BROTLI_INLINE void BrotliTakeBits( +static BROTLI_INLINE void BrotliTakeBits( BrotliBitReader* const br, uint32_t n_bits, uint32_t* val) { *val = (uint32_t)BrotliGetBitsUnmasked(br) & BitMask(n_bits); BROTLI_LOG(("[BrotliReadBits] %d %d %d val: %6x\n", (int)br->avail_in, (int)br->bit_pos_, (int)n_bits, (int)*val)); BrotliDropBits(br, n_bits); -} - +} + /* Reads the specified number of bits from |br| and advances the bit pos. - Assumes that there is enough input to perform BrotliFillBitWindow. */ -static BROTLI_INLINE uint32_t BrotliReadBits( + Assumes that there is enough input to perform BrotliFillBitWindow. */ +static BROTLI_INLINE uint32_t BrotliReadBits( BrotliBitReader* const br, uint32_t n_bits) { if (BROTLI_64_BITS || (n_bits <= 16)) { uint32_t val; @@ -260,8 +260,8 @@ static BROTLI_INLINE uint32_t BrotliReadBits( BrotliTakeBits(br, n_bits - 16, &high_val); return low_val | (high_val << 16); } -} - +} + /* Tries to read the specified amount of bits. Returns BROTLI_FALSE, if there is not enough input. |n_bits| MUST be positive. */ static BROTLI_INLINE BROTLI_BOOL BrotliSafeReadBits( @@ -269,41 +269,41 @@ static BROTLI_INLINE BROTLI_BOOL BrotliSafeReadBits( while (BrotliGetAvailableBits(br) < n_bits) { if (!BrotliPullByte(br)) { return BROTLI_FALSE; - } - } - BrotliTakeBits(br, n_bits, val); + } + } + BrotliTakeBits(br, n_bits, val); return BROTLI_TRUE; -} - -/* Advances the bit reader position to the next byte boundary and verifies - that any skipped bits are set to zero. */ +} + +/* Advances the bit reader position to the next byte boundary and verifies + that any skipped bits are set to zero. */ static BROTLI_INLINE BROTLI_BOOL BrotliJumpToByteBoundary(BrotliBitReader* br) { uint32_t pad_bits_count = BrotliGetAvailableBits(br) & 0x7; - uint32_t pad_bits = 0; - if (pad_bits_count != 0) { - BrotliTakeBits(br, pad_bits_count, &pad_bits); - } + uint32_t pad_bits = 0; + if (pad_bits_count != 0) { + BrotliTakeBits(br, pad_bits_count, &pad_bits); + } return TO_BROTLI_BOOL(pad_bits == 0); -} - -/* Copies remaining input bytes stored in the bit reader to the output. Value +} + +/* Copies remaining input bytes stored in the bit reader to the output. Value |num| may not be larger than BrotliGetRemainingBytes. The bit reader must be - warmed up again after this. */ -static BROTLI_INLINE void BrotliCopyBytes(uint8_t* dest, - BrotliBitReader* br, size_t num) { + warmed up again after this. */ +static BROTLI_INLINE void BrotliCopyBytes(uint8_t* dest, + BrotliBitReader* br, size_t num) { while (BrotliGetAvailableBits(br) >= 8 && num > 0) { *dest = (uint8_t)BrotliGetBitsUnmasked(br); BrotliDropBits(br, 8); - ++dest; - --num; - } - memcpy(dest, br->next_in, num); + ++dest; + --num; + } + memcpy(dest, br->next_in, num); br->avail_in -= num; - br->next_in += num; -} - -#if defined(__cplusplus) || defined(c_plusplus) + br->next_in += num; +} + +#if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ -#endif - -#endif /* BROTLI_DEC_BIT_READER_H_ */ +#endif + +#endif /* BROTLI_DEC_BIT_READER_H_ */ diff --git a/contrib/libs/brotli/dec/decode.c b/contrib/libs/brotli/dec/decode.c index ee898d4372..08bd76ca16 100644 --- a/contrib/libs/brotli/dec/decode.c +++ b/contrib/libs/brotli/dec/decode.c @@ -1,11 +1,11 @@ -/* Copyright 2013 Google Inc. All Rights Reserved. - +/* Copyright 2013 Google Inc. All Rights Reserved. + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ - + #include <brotli/decode.h> - + #include <stdlib.h> /* free, malloc */ #include <string.h> /* memcpy, memset */ @@ -15,48 +15,48 @@ #include "../common/platform.h" #include "../common/transform.h" #include "../common/version.h" -#include "./bit_reader.h" +#include "./bit_reader.h" #include "./huffman.h" #include "./prefix.h" #include "./state.h" - + #if defined(BROTLI_TARGET_NEON) #include <arm_neon.h> #endif -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - +#if defined(__cplusplus) || defined(c_plusplus) +extern "C" { +#endif + #define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE) - + #define BROTLI_LOG_UINT(name) \ BROTLI_LOG(("[%s] %s = %lu\n", __func__, #name, (unsigned long)(name))) #define BROTLI_LOG_ARRAY_INDEX(array_name, idx) \ BROTLI_LOG(("[%s] %s[%lu] = %lu\n", __func__, #array_name, \ (unsigned long)(idx), (unsigned long)array_name[idx])) - + #define HUFFMAN_TABLE_BITS 8U #define HUFFMAN_TABLE_MASK 0xFF - + /* We need the slack region for the following reasons: - doing up to two 16-byte copies for fast backward copying - inserting transformed dictionary word (5 prefix + 24 base + 8 suffix) */ static const uint32_t kRingBufferWriteAheadSlack = 42; static const uint8_t kCodeLengthCodeOrder[BROTLI_CODE_LENGTH_CODES] = { - 1, 2, 3, 4, 0, 5, 17, 6, 16, 7, 8, 9, 10, 11, 12, 13, 14, 15, -}; - -/* Static prefix code for the complex code length code lengths. */ -static const uint8_t kCodeLengthPrefixLength[16] = { - 2, 2, 2, 3, 2, 2, 2, 4, 2, 2, 2, 3, 2, 2, 2, 4, -}; - -static const uint8_t kCodeLengthPrefixValue[16] = { - 0, 4, 3, 2, 0, 4, 3, 1, 0, 4, 3, 2, 0, 4, 3, 5, -}; - + 1, 2, 3, 4, 0, 5, 17, 6, 16, 7, 8, 9, 10, 11, 12, 13, 14, 15, +}; + +/* Static prefix code for the complex code length code lengths. */ +static const uint8_t kCodeLengthPrefixLength[16] = { + 2, 2, 2, 3, 2, 2, 2, 4, 2, 2, 2, 3, 2, 2, 2, 4, +}; + +static const uint8_t kCodeLengthPrefixValue[16] = { + 0, 4, 3, 2, 0, 4, 3, 1, 0, 4, 3, 2, 0, 4, 3, 5, +}; + BROTLI_BOOL BrotliDecoderSetParameter( BrotliDecoderState* state, BrotliDecoderParameter p, uint32_t value) { if (state->state != BROTLI_STATE_UNINITED) return BROTLI_FALSE; @@ -64,7 +64,7 @@ BROTLI_BOOL BrotliDecoderSetParameter( case BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION: state->canny_ringbuffer_allocation = !!value ? 0 : 1; return BROTLI_TRUE; - + case BROTLI_DECODER_PARAM_LARGE_WINDOW: state->large_window = TO_BROTLI_BOOL(!!value); return BROTLI_TRUE; @@ -132,20 +132,20 @@ static BROTLI_NOINLINE BrotliDecoderResult SaveErrorCode( Precondition: bit-reader accumulator has at least 8 bits. */ static BrotliDecoderErrorCode DecodeWindowBits(BrotliDecoderState* s, BrotliBitReader* br) { - uint32_t n; + uint32_t n; BROTLI_BOOL large_window = s->large_window; s->large_window = BROTLI_FALSE; - BrotliTakeBits(br, 1, &n); - if (n == 0) { + BrotliTakeBits(br, 1, &n); + if (n == 0) { s->window_bits = 16; return BROTLI_DECODER_SUCCESS; - } - BrotliTakeBits(br, 3, &n); - if (n != 0) { + } + BrotliTakeBits(br, 3, &n); + if (n != 0) { s->window_bits = 17 + n; return BROTLI_DECODER_SUCCESS; - } - BrotliTakeBits(br, 3, &n); + } + BrotliTakeBits(br, 3, &n); if (n == 1) { if (large_window) { BrotliTakeBits(br, 1, &n); @@ -158,188 +158,188 @@ static BrotliDecoderErrorCode DecodeWindowBits(BrotliDecoderState* s, return BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS); } } - if (n != 0) { + if (n != 0) { s->window_bits = 8 + n; return BROTLI_DECODER_SUCCESS; - } + } s->window_bits = 17; return BROTLI_DECODER_SUCCESS; -} - +} + static BROTLI_INLINE void memmove16(uint8_t* dst, uint8_t* src) { #if defined(BROTLI_TARGET_NEON) - vst1q_u8(dst, vld1q_u8(src)); -#else + vst1q_u8(dst, vld1q_u8(src)); +#else uint32_t buffer[4]; memcpy(buffer, src, 16); memcpy(dst, buffer, 16); -#endif -} - -/* Decodes a number in the range [0..255], by reading 1 - 11 bits. */ +#endif +} + +/* Decodes a number in the range [0..255], by reading 1 - 11 bits. */ static BROTLI_NOINLINE BrotliDecoderErrorCode DecodeVarLenUint8( BrotliDecoderState* s, BrotliBitReader* br, uint32_t* value) { - uint32_t bits; - switch (s->substate_decode_uint8) { - case BROTLI_STATE_DECODE_UINT8_NONE: + uint32_t bits; + switch (s->substate_decode_uint8) { + case BROTLI_STATE_DECODE_UINT8_NONE: if (BROTLI_PREDICT_FALSE(!BrotliSafeReadBits(br, 1, &bits))) { return BROTLI_DECODER_NEEDS_MORE_INPUT; - } - if (bits == 0) { - *value = 0; + } + if (bits == 0) { + *value = 0; return BROTLI_DECODER_SUCCESS; - } + } /* Fall through. */ - - case BROTLI_STATE_DECODE_UINT8_SHORT: + + case BROTLI_STATE_DECODE_UINT8_SHORT: if (BROTLI_PREDICT_FALSE(!BrotliSafeReadBits(br, 3, &bits))) { - s->substate_decode_uint8 = BROTLI_STATE_DECODE_UINT8_SHORT; + s->substate_decode_uint8 = BROTLI_STATE_DECODE_UINT8_SHORT; return BROTLI_DECODER_NEEDS_MORE_INPUT; - } - if (bits == 0) { - *value = 1; - s->substate_decode_uint8 = BROTLI_STATE_DECODE_UINT8_NONE; + } + if (bits == 0) { + *value = 1; + s->substate_decode_uint8 = BROTLI_STATE_DECODE_UINT8_NONE; return BROTLI_DECODER_SUCCESS; - } - /* Use output value as a temporary storage. It MUST be persisted. */ + } + /* Use output value as a temporary storage. It MUST be persisted. */ *value = bits; /* Fall through. */ - - case BROTLI_STATE_DECODE_UINT8_LONG: + + case BROTLI_STATE_DECODE_UINT8_LONG: if (BROTLI_PREDICT_FALSE(!BrotliSafeReadBits(br, *value, &bits))) { - s->substate_decode_uint8 = BROTLI_STATE_DECODE_UINT8_LONG; + s->substate_decode_uint8 = BROTLI_STATE_DECODE_UINT8_LONG; return BROTLI_DECODER_NEEDS_MORE_INPUT; - } + } *value = (1U << *value) + bits; - s->substate_decode_uint8 = BROTLI_STATE_DECODE_UINT8_NONE; + s->substate_decode_uint8 = BROTLI_STATE_DECODE_UINT8_NONE; return BROTLI_DECODER_SUCCESS; - - default: + + default: return BROTLI_FAILURE(BROTLI_DECODER_ERROR_UNREACHABLE); - } -} - -/* Decodes a metablock length and flags by reading 2 - 31 bits. */ + } +} + +/* Decodes a metablock length and flags by reading 2 - 31 bits. */ static BrotliDecoderErrorCode BROTLI_NOINLINE DecodeMetaBlockLength( BrotliDecoderState* s, BrotliBitReader* br) { - uint32_t bits; - int i; - for (;;) { - switch (s->substate_metablock_header) { - case BROTLI_STATE_METABLOCK_HEADER_NONE: - if (!BrotliSafeReadBits(br, 1, &bits)) { + uint32_t bits; + int i; + for (;;) { + switch (s->substate_metablock_header) { + case BROTLI_STATE_METABLOCK_HEADER_NONE: + if (!BrotliSafeReadBits(br, 1, &bits)) { return BROTLI_DECODER_NEEDS_MORE_INPUT; - } + } s->is_last_metablock = bits ? 1 : 0; - s->meta_block_remaining_len = 0; - s->is_uncompressed = 0; - s->is_metadata = 0; - if (!s->is_last_metablock) { - s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_NIBBLES; - break; - } - s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_EMPTY; + s->meta_block_remaining_len = 0; + s->is_uncompressed = 0; + s->is_metadata = 0; + if (!s->is_last_metablock) { + s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_NIBBLES; + break; + } + s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_EMPTY; /* Fall through. */ - - case BROTLI_STATE_METABLOCK_HEADER_EMPTY: - if (!BrotliSafeReadBits(br, 1, &bits)) { + + case BROTLI_STATE_METABLOCK_HEADER_EMPTY: + if (!BrotliSafeReadBits(br, 1, &bits)) { return BROTLI_DECODER_NEEDS_MORE_INPUT; - } - if (bits) { - s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_NONE; + } + if (bits) { + s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_NONE; return BROTLI_DECODER_SUCCESS; - } - s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_NIBBLES; + } + s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_NIBBLES; /* Fall through. */ - - case BROTLI_STATE_METABLOCK_HEADER_NIBBLES: - if (!BrotliSafeReadBits(br, 2, &bits)) { + + case BROTLI_STATE_METABLOCK_HEADER_NIBBLES: + if (!BrotliSafeReadBits(br, 2, &bits)) { return BROTLI_DECODER_NEEDS_MORE_INPUT; - } - s->size_nibbles = (uint8_t)(bits + 4); - s->loop_counter = 0; - if (bits == 3) { - s->is_metadata = 1; - s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_RESERVED; - break; - } - s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_SIZE; + } + s->size_nibbles = (uint8_t)(bits + 4); + s->loop_counter = 0; + if (bits == 3) { + s->is_metadata = 1; + s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_RESERVED; + break; + } + s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_SIZE; /* Fall through. */ - - case BROTLI_STATE_METABLOCK_HEADER_SIZE: - i = s->loop_counter; + + case BROTLI_STATE_METABLOCK_HEADER_SIZE: + i = s->loop_counter; for (; i < (int)s->size_nibbles; ++i) { - if (!BrotliSafeReadBits(br, 4, &bits)) { - s->loop_counter = i; + if (!BrotliSafeReadBits(br, 4, &bits)) { + s->loop_counter = i; return BROTLI_DECODER_NEEDS_MORE_INPUT; - } - if (i + 1 == s->size_nibbles && s->size_nibbles > 4 && bits == 0) { + } + if (i + 1 == s->size_nibbles && s->size_nibbles > 4 && bits == 0) { return BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE); - } - s->meta_block_remaining_len |= (int)(bits << (i * 4)); - } - s->substate_metablock_header = - BROTLI_STATE_METABLOCK_HEADER_UNCOMPRESSED; + } + s->meta_block_remaining_len |= (int)(bits << (i * 4)); + } + s->substate_metablock_header = + BROTLI_STATE_METABLOCK_HEADER_UNCOMPRESSED; /* Fall through. */ - - case BROTLI_STATE_METABLOCK_HEADER_UNCOMPRESSED: + + case BROTLI_STATE_METABLOCK_HEADER_UNCOMPRESSED: if (!s->is_last_metablock) { - if (!BrotliSafeReadBits(br, 1, &bits)) { + if (!BrotliSafeReadBits(br, 1, &bits)) { return BROTLI_DECODER_NEEDS_MORE_INPUT; - } + } s->is_uncompressed = bits ? 1 : 0; - } - ++s->meta_block_remaining_len; - s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_NONE; + } + ++s->meta_block_remaining_len; + s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_NONE; return BROTLI_DECODER_SUCCESS; - - case BROTLI_STATE_METABLOCK_HEADER_RESERVED: - if (!BrotliSafeReadBits(br, 1, &bits)) { + + case BROTLI_STATE_METABLOCK_HEADER_RESERVED: + if (!BrotliSafeReadBits(br, 1, &bits)) { return BROTLI_DECODER_NEEDS_MORE_INPUT; - } - if (bits != 0) { + } + if (bits != 0) { return BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_RESERVED); - } - s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_BYTES; + } + s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_BYTES; /* Fall through. */ - - case BROTLI_STATE_METABLOCK_HEADER_BYTES: - if (!BrotliSafeReadBits(br, 2, &bits)) { + + case BROTLI_STATE_METABLOCK_HEADER_BYTES: + if (!BrotliSafeReadBits(br, 2, &bits)) { return BROTLI_DECODER_NEEDS_MORE_INPUT; - } - if (bits == 0) { - s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_NONE; + } + if (bits == 0) { + s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_NONE; return BROTLI_DECODER_SUCCESS; - } - s->size_nibbles = (uint8_t)bits; - s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_METADATA; + } + s->size_nibbles = (uint8_t)bits; + s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_METADATA; /* Fall through. */ - - case BROTLI_STATE_METABLOCK_HEADER_METADATA: - i = s->loop_counter; + + case BROTLI_STATE_METABLOCK_HEADER_METADATA: + i = s->loop_counter; for (; i < (int)s->size_nibbles; ++i) { - if (!BrotliSafeReadBits(br, 8, &bits)) { - s->loop_counter = i; + if (!BrotliSafeReadBits(br, 8, &bits)) { + s->loop_counter = i; return BROTLI_DECODER_NEEDS_MORE_INPUT; - } - if (i + 1 == s->size_nibbles && s->size_nibbles > 1 && bits == 0) { + } + if (i + 1 == s->size_nibbles && s->size_nibbles > 1 && bits == 0) { return BROTLI_FAILURE( BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE); - } - s->meta_block_remaining_len |= (int)(bits << (i * 8)); - } + } + s->meta_block_remaining_len |= (int)(bits << (i * 8)); + } ++s->meta_block_remaining_len; s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_NONE; return BROTLI_DECODER_SUCCESS; - - default: + + default: return BROTLI_FAILURE(BROTLI_DECODER_ERROR_UNREACHABLE); - } - } -} - + } + } +} + /* Decodes the Huffman code. This method doesn't read data from the bit reader, BUT drops the amount of bits that correspond to the decoded symbol. @@ -351,15 +351,15 @@ static BROTLI_INLINE uint32_t DecodeSymbol(uint32_t bits, BROTLI_HC_ADJUST_TABLE_INDEX(table, bits & HUFFMAN_TABLE_MASK); if (BROTLI_HC_FAST_LOAD_BITS(table) > HUFFMAN_TABLE_BITS) { uint32_t nbits = BROTLI_HC_FAST_LOAD_BITS(table) - HUFFMAN_TABLE_BITS; - BrotliDropBits(br, HUFFMAN_TABLE_BITS); + BrotliDropBits(br, HUFFMAN_TABLE_BITS); BROTLI_HC_ADJUST_TABLE_INDEX(table, BROTLI_HC_FAST_LOAD_VALUE(table) + ((bits >> HUFFMAN_TABLE_BITS) & BitMask(nbits))); - } + } BrotliDropBits(br, BROTLI_HC_FAST_LOAD_BITS(table)); return BROTLI_HC_FAST_LOAD_VALUE(table); -} - +} + /* Reads and decodes the next Huffman code from bit-stream. This method peeks 16 bits of input and drops 0 - 15 of them. */ static BROTLI_INLINE uint32_t ReadSymbol(const HuffmanCode* table, @@ -419,10 +419,10 @@ static BROTLI_INLINE BROTLI_BOOL SafeReadSymbol( return SafeDecodeSymbol(table, br, result); } -/* Makes a look-up in first level Huffman table. Peeks 8 bits. */ +/* Makes a look-up in first level Huffman table. Peeks 8 bits. */ static BROTLI_INLINE void PreloadSymbol(int safe, const HuffmanCode* table, - BrotliBitReader* br, + BrotliBitReader* br, uint32_t* bits, uint32_t* value) { if (safe) { @@ -432,40 +432,40 @@ static BROTLI_INLINE void PreloadSymbol(int safe, BROTLI_HC_ADJUST_TABLE_INDEX(table, BrotliGetBits(br, HUFFMAN_TABLE_BITS)); *bits = BROTLI_HC_FAST_LOAD_BITS(table); *value = BROTLI_HC_FAST_LOAD_VALUE(table); -} - -/* Decodes the next Huffman code using data prepared by PreloadSymbol. - Reads 0 - 15 bits. Also peeks 8 following bits. */ +} + +/* Decodes the next Huffman code using data prepared by PreloadSymbol. + Reads 0 - 15 bits. Also peeks 8 following bits. */ static BROTLI_INLINE uint32_t ReadPreloadedSymbol(const HuffmanCode* table, - BrotliBitReader* br, + BrotliBitReader* br, uint32_t* bits, uint32_t* value) { uint32_t result = *value; if (BROTLI_PREDICT_FALSE(*bits > HUFFMAN_TABLE_BITS)) { uint32_t val = BrotliGet16BitsUnmasked(br); - const HuffmanCode* ext = table + (val & HUFFMAN_TABLE_MASK) + *value; + const HuffmanCode* ext = table + (val & HUFFMAN_TABLE_MASK) + *value; uint32_t mask = BitMask((*bits - HUFFMAN_TABLE_BITS)); BROTLI_HC_MARK_TABLE_FOR_FAST_LOAD(ext); - BrotliDropBits(br, HUFFMAN_TABLE_BITS); + BrotliDropBits(br, HUFFMAN_TABLE_BITS); BROTLI_HC_ADJUST_TABLE_INDEX(ext, (val >> HUFFMAN_TABLE_BITS) & mask); BrotliDropBits(br, BROTLI_HC_FAST_LOAD_BITS(ext)); result = BROTLI_HC_FAST_LOAD_VALUE(ext); - } else { + } else { BrotliDropBits(br, *bits); - } + } PreloadSymbol(0, table, br, bits, value); - return result; -} - + return result; +} + static BROTLI_INLINE uint32_t Log2Floor(uint32_t x) { uint32_t result = 0; - while (x) { - x >>= 1; - ++result; - } - return result; -} - + while (x) { + x >>= 1; + ++result; + } + return result; +} + /* Reads (s->symbol + 1) symbols. Totally 1..4 symbols are read, 1..11 bits each. The list of symbols MUST NOT contain duplicates. */ @@ -726,24 +726,24 @@ static BrotliDecoderErrorCode ReadCodeLengthCodeLengths(BrotliDecoderState* s) { return BROTLI_DECODER_SUCCESS; } -/* Decodes the Huffman tables. - There are 2 scenarios: - A) Huffman code contains only few symbols (1..4). Those symbols are read - directly; their code lengths are defined by the number of symbols. +/* Decodes the Huffman tables. + There are 2 scenarios: + A) Huffman code contains only few symbols (1..4). Those symbols are read + directly; their code lengths are defined by the number of symbols. For this scenario 4 - 49 bits will be read. - - B) 2-phase decoding: - B.1) Small Huffman table is decoded; it is specified with code lengths - encoded with predefined entropy code. 32 - 74 bits are used. - B.2) Decoded table is used to decode code lengths of symbols in resulting + + B) 2-phase decoding: + B.1) Small Huffman table is decoded; it is specified with code lengths + encoded with predefined entropy code. 32 - 74 bits are used. + B.2) Decoded table is used to decode code lengths of symbols in resulting Huffman table. In worst case 3520 bits are read. */ static BrotliDecoderErrorCode ReadHuffmanCode(uint32_t alphabet_size, uint32_t max_symbol, HuffmanCode* table, uint32_t* opt_table_size, BrotliDecoderState* s) { - BrotliBitReader* br = &s->br; - /* Unnecessary masking, but might be good for safety. */ + BrotliBitReader* br = &s->br; + /* Unnecessary masking, but might be good for safety. */ alphabet_size &= 0x7FF; /* State machine. */ for (;;) { @@ -769,11 +769,11 @@ static BrotliDecoderErrorCode ReadHuffmanCode(uint32_t alphabet_size, /* Fall through. */ case BROTLI_STATE_HUFFMAN_SIMPLE_SIZE: - /* Read symbols, codes & code lengths directly. */ + /* Read symbols, codes & code lengths directly. */ if (!BrotliSafeReadBits(br, 2, &s->symbol)) { /* num_symbols */ s->substate_huffman = BROTLI_STATE_HUFFMAN_SIMPLE_SIZE; return BROTLI_DECODER_NEEDS_MORE_INPUT; - } + } s->sub_loop_counter = 0; /* Fall through. */ @@ -793,16 +793,16 @@ static BrotliDecoderErrorCode ReadHuffmanCode(uint32_t alphabet_size, if (!BrotliSafeReadBits(br, 1, &bits)) { s->substate_huffman = BROTLI_STATE_HUFFMAN_SIMPLE_BUILD; return BROTLI_DECODER_NEEDS_MORE_INPUT; - } + } s->symbol += bits; - } + } BROTLI_LOG_UINT(s->symbol); table_size = BrotliBuildSimpleHuffmanTable( table, HUFFMAN_TABLE_BITS, s->symbols_lists_array, s->symbol); - if (opt_table_size) { + if (opt_table_size) { *opt_table_size = table_size; - } - s->substate_huffman = BROTLI_STATE_HUFFMAN_NONE; + } + s->substate_huffman = BROTLI_STATE_HUFFMAN_NONE; return BROTLI_DECODER_SUCCESS; } @@ -812,7 +812,7 @@ static BrotliDecoderErrorCode ReadHuffmanCode(uint32_t alphabet_size, BrotliDecoderErrorCode result = ReadCodeLengthCodeLengths(s); if (result != BROTLI_DECODER_SUCCESS) { return result; - } + } BrotliBuildCodeLengthsHuffmanTable(s->table, s->code_length_code_lengths, s->code_length_histo); @@ -820,7 +820,7 @@ static BrotliDecoderErrorCode ReadHuffmanCode(uint32_t alphabet_size, for (i = 0; i <= BROTLI_HUFFMAN_MAX_CODE_LENGTH; ++i) { s->next_symbol[i] = (int)i - (BROTLI_HUFFMAN_MAX_CODE_LENGTH + 1); s->symbol_lists[s->next_symbol[i]] = 0xFFFF; - } + } s->symbol = 0; s->prev_code_len = BROTLI_INITIAL_REPEATED_CODE_LENGTH; @@ -828,7 +828,7 @@ static BrotliDecoderErrorCode ReadHuffmanCode(uint32_t alphabet_size, s->repeat_code_len = 0; s->space = 32768; s->substate_huffman = BROTLI_STATE_HUFFMAN_LENGTH_SYMBOLS; - } + } /* Fall through. */ case BROTLI_STATE_HUFFMAN_LENGTH_SYMBOLS: { @@ -840,37 +840,37 @@ static BrotliDecoderErrorCode ReadHuffmanCode(uint32_t alphabet_size, if (result != BROTLI_DECODER_SUCCESS) { return result; } - + if (s->space != 0) { BROTLI_LOG(("[ReadHuffmanCode] space = %d\n", (int)s->space)); return BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE); - } + } table_size = BrotliBuildHuffmanTable( table, HUFFMAN_TABLE_BITS, s->symbol_lists, s->code_length_histo); - if (opt_table_size) { - *opt_table_size = table_size; - } + if (opt_table_size) { + *opt_table_size = table_size; + } s->substate_huffman = BROTLI_STATE_HUFFMAN_NONE; return BROTLI_DECODER_SUCCESS; - } + } default: return BROTLI_FAILURE(BROTLI_DECODER_ERROR_UNREACHABLE); - } - } -} - -/* Decodes a block length by reading 3..39 bits. */ + } + } +} + +/* Decodes a block length by reading 3..39 bits. */ static BROTLI_INLINE uint32_t ReadBlockLength(const HuffmanCode* table, BrotliBitReader* br) { uint32_t code; uint32_t nbits; - code = ReadSymbol(table, br); + code = ReadSymbol(table, br); nbits = kBlockLengthPrefixCode[code].nbits; /* nbits == 2..24 */ return kBlockLengthPrefixCode[code].offset + BrotliReadBits(br, nbits); -} - +} + /* WARNING: if state is not BROTLI_STATE_READ_BLOCK_LENGTH_NONE, then reading can't be continued with ReadBlockLength. */ static BROTLI_INLINE BROTLI_BOOL SafeReadBlockLength( @@ -898,114 +898,114 @@ static BROTLI_INLINE BROTLI_BOOL SafeReadBlockLength( } } -/* Transform: - 1) initialize list L with values 0, 1,... 255 - 2) For each input element X: - 2.1) let Y = L[X] - 2.2) remove X-th element from L - 2.3) prepend Y to L - 2.4) append Y to output - - In most cases max(Y) <= 7, so most of L remains intact. - To reduce the cost of initialization, we reuse L, remember the upper bound - of Y values, and reinitialize only first elements in L. - - Most of input values are 0 and 1. To reduce number of branches, we replace +/* Transform: + 1) initialize list L with values 0, 1,... 255 + 2) For each input element X: + 2.1) let Y = L[X] + 2.2) remove X-th element from L + 2.3) prepend Y to L + 2.4) append Y to output + + In most cases max(Y) <= 7, so most of L remains intact. + To reduce the cost of initialization, we reuse L, remember the upper bound + of Y values, and reinitialize only first elements in L. + + Most of input values are 0 and 1. To reduce number of branches, we replace inner for loop with do-while. */ static BROTLI_NOINLINE void InverseMoveToFrontTransform( uint8_t* v, uint32_t v_len, BrotliDecoderState* state) { - /* Reinitialize elements that could have been changed. */ + /* Reinitialize elements that could have been changed. */ uint32_t i = 1; uint32_t upper_bound = state->mtf_upper_bound; uint32_t* mtf = &state->mtf[1]; /* Make mtf[-1] addressable. */ uint8_t* mtf_u8 = (uint8_t*)mtf; - /* Load endian-aware constant. */ - const uint8_t b0123[4] = {0, 1, 2, 3}; - uint32_t pattern; - memcpy(&pattern, &b0123, 4); - - /* Initialize list using 4 consequent values pattern. */ + /* Load endian-aware constant. */ + const uint8_t b0123[4] = {0, 1, 2, 3}; + uint32_t pattern; + memcpy(&pattern, &b0123, 4); + + /* Initialize list using 4 consequent values pattern. */ mtf[0] = pattern; - do { + do { pattern += 0x04040404; /* Advance all 4 values by 4. */ mtf[i] = pattern; i++; - } while (i <= upper_bound); - - /* Transform the input. */ - upper_bound = 0; - for (i = 0; i < v_len; ++i) { - int index = v[i]; + } while (i <= upper_bound); + + /* Transform the input. */ + upper_bound = 0; + for (i = 0; i < v_len; ++i) { + int index = v[i]; uint8_t value = mtf_u8[index]; upper_bound |= v[i]; - v[i] = value; + v[i] = value; mtf_u8[-1] = value; - do { - index--; + do { + index--; mtf_u8[index + 1] = mtf_u8[index]; } while (index >= 0); - } - /* Remember amount of elements to be reinitialized. */ + } + /* Remember amount of elements to be reinitialized. */ state->mtf_upper_bound = upper_bound >> 2; -} - -/* Decodes a series of Huffman table using ReadHuffmanCode function. */ +} + +/* Decodes a series of Huffman table using ReadHuffmanCode function. */ static BrotliDecoderErrorCode HuffmanTreeGroupDecode( HuffmanTreeGroup* group, BrotliDecoderState* s) { - if (s->substate_tree_group != BROTLI_STATE_TREE_GROUP_LOOP) { - s->next = group->codes; - s->htree_index = 0; - s->substate_tree_group = BROTLI_STATE_TREE_GROUP_LOOP; - } - while (s->htree_index < group->num_htrees) { + if (s->substate_tree_group != BROTLI_STATE_TREE_GROUP_LOOP) { + s->next = group->codes; + s->htree_index = 0; + s->substate_tree_group = BROTLI_STATE_TREE_GROUP_LOOP; + } + while (s->htree_index < group->num_htrees) { uint32_t table_size; BrotliDecoderErrorCode result = ReadHuffmanCode(group->alphabet_size, group->max_symbol, s->next, &table_size, s); if (result != BROTLI_DECODER_SUCCESS) return result; - group->htrees[s->htree_index] = s->next; - s->next += table_size; - ++s->htree_index; - } - s->substate_tree_group = BROTLI_STATE_TREE_GROUP_NONE; + group->htrees[s->htree_index] = s->next; + s->next += table_size; + ++s->htree_index; + } + s->substate_tree_group = BROTLI_STATE_TREE_GROUP_NONE; return BROTLI_DECODER_SUCCESS; -} - -/* Decodes a context map. - Decoding is done in 4 phases: - 1) Read auxiliary information (6..16 bits) and allocate memory. - In case of trivial context map, decoding is finished at this phase. - 2) Decode Huffman table using ReadHuffmanCode function. - This table will be used for reading context map items. - 3) Read context map items; "0" values could be run-length encoded. +} + +/* Decodes a context map. + Decoding is done in 4 phases: + 1) Read auxiliary information (6..16 bits) and allocate memory. + In case of trivial context map, decoding is finished at this phase. + 2) Decode Huffman table using ReadHuffmanCode function. + This table will be used for reading context map items. + 3) Read context map items; "0" values could be run-length encoded. 4) Optionally, apply InverseMoveToFront transform to the resulting map. */ static BrotliDecoderErrorCode DecodeContextMap(uint32_t context_map_size, uint32_t* num_htrees, uint8_t** context_map_arg, BrotliDecoderState* s) { - BrotliBitReader* br = &s->br; + BrotliBitReader* br = &s->br; BrotliDecoderErrorCode result = BROTLI_DECODER_SUCCESS; - + switch ((int)s->substate_context_map) { - case BROTLI_STATE_CONTEXT_MAP_NONE: - result = DecodeVarLenUint8(s, br, num_htrees); + case BROTLI_STATE_CONTEXT_MAP_NONE: + result = DecodeVarLenUint8(s, br, num_htrees); if (result != BROTLI_DECODER_SUCCESS) { - return result; - } - (*num_htrees)++; - s->context_index = 0; - BROTLI_LOG_UINT(context_map_size); - BROTLI_LOG_UINT(*num_htrees); + return result; + } + (*num_htrees)++; + s->context_index = 0; + BROTLI_LOG_UINT(context_map_size); + BROTLI_LOG_UINT(*num_htrees); *context_map_arg = (uint8_t*)BROTLI_DECODER_ALLOC(s, (size_t)context_map_size); - if (*context_map_arg == 0) { + if (*context_map_arg == 0) { return BROTLI_FAILURE(BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP); - } - if (*num_htrees <= 1) { - memset(*context_map_arg, 0, (size_t)context_map_size); + } + if (*num_htrees <= 1) { + memset(*context_map_arg, 0, (size_t)context_map_size); return BROTLI_DECODER_SUCCESS; - } - s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_READ_PREFIX; + } + s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_READ_PREFIX; /* Fall through. */ case BROTLI_STATE_CONTEXT_MAP_READ_PREFIX: { @@ -1014,33 +1014,33 @@ static BrotliDecoderErrorCode DecodeContextMap(uint32_t context_map_size, to peek 4 bits ahead. */ if (!BrotliSafeGetBits(br, 5, &bits)) { return BROTLI_DECODER_NEEDS_MORE_INPUT; - } + } if ((bits & 1) != 0) { /* Use RLE for zeros. */ s->max_run_length_prefix = (bits >> 1) + 1; BrotliDropBits(br, 5); - } else { - s->max_run_length_prefix = 0; + } else { + s->max_run_length_prefix = 0; BrotliDropBits(br, 1); - } - BROTLI_LOG_UINT(s->max_run_length_prefix); - s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_HUFFMAN; + } + BROTLI_LOG_UINT(s->max_run_length_prefix); + s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_HUFFMAN; } /* Fall through. */ case BROTLI_STATE_CONTEXT_MAP_HUFFMAN: { uint32_t alphabet_size = *num_htrees + s->max_run_length_prefix; result = ReadHuffmanCode(alphabet_size, alphabet_size, - s->context_map_table, NULL, s); + s->context_map_table, NULL, s); if (result != BROTLI_DECODER_SUCCESS) return result; s->code = 0xFFFF; - s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_DECODE; + s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_DECODE; } /* Fall through. */ - case BROTLI_STATE_CONTEXT_MAP_DECODE: { + case BROTLI_STATE_CONTEXT_MAP_DECODE: { uint32_t context_index = s->context_index; uint32_t max_run_length_prefix = s->max_run_length_prefix; - uint8_t* context_map = *context_map_arg; + uint8_t* context_map = *context_map_arg; uint32_t code = s->code; BROTLI_BOOL skip_preamble = (code != 0xFFFF); while (context_index < context_map_size || skip_preamble) { @@ -1063,7 +1063,7 @@ static BrotliDecoderErrorCode DecodeContextMap(uint32_t context_map_size, } } else { skip_preamble = BROTLI_FALSE; - } + } /* RLE sub-stage. */ { uint32_t reps; @@ -1073,16 +1073,16 @@ static BrotliDecoderErrorCode DecodeContextMap(uint32_t context_map_size, return BROTLI_DECODER_NEEDS_MORE_INPUT; } reps += 1U << code; - BROTLI_LOG_UINT(reps); - if (context_index + reps > context_map_size) { + BROTLI_LOG_UINT(reps); + if (context_index + reps > context_map_size) { return BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT); - } - do { - context_map[context_index++] = 0; - } while (--reps); - } - } + } + do { + context_map[context_index++] = 0; + } while (--reps); + } + } } /* Fall through. */ @@ -1091,20 +1091,20 @@ static BrotliDecoderErrorCode DecodeContextMap(uint32_t context_map_size, if (!BrotliSafeReadBits(br, 1, &bits)) { s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_TRANSFORM; return BROTLI_DECODER_NEEDS_MORE_INPUT; - } + } if (bits != 0) { InverseMoveToFrontTransform(*context_map_arg, context_map_size, s); } - s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_NONE; + s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_NONE; return BROTLI_DECODER_SUCCESS; - } + } default: return BROTLI_FAILURE(BROTLI_DECODER_ERROR_UNREACHABLE); - } -} - + } +} + /* Decodes a command or literal and updates block type ring-buffer. Reads 3..54 bits. */ static BROTLI_INLINE BROTLI_BOOL DecodeBlockTypeAndLength( @@ -1137,20 +1137,20 @@ static BROTLI_INLINE BROTLI_BOOL DecodeBlockTypeAndLength( } if (block_type == 1) { - block_type = ringbuffer[1] + 1; + block_type = ringbuffer[1] + 1; } else if (block_type == 0) { - block_type = ringbuffer[0]; + block_type = ringbuffer[0]; } else { block_type -= 2; - } - if (block_type >= max_block_type) { - block_type -= max_block_type; - } - ringbuffer[0] = ringbuffer[1]; - ringbuffer[1] = block_type; + } + if (block_type >= max_block_type) { + block_type -= max_block_type; + } + ringbuffer[0] = ringbuffer[1]; + ringbuffer[1] = block_type; return BROTLI_TRUE; -} - +} + static BROTLI_INLINE void DetectTrivialLiteralBlockTypes( BrotliDecoderState* s) { size_t i; @@ -1170,18 +1170,18 @@ static BROTLI_INLINE void DetectTrivialLiteralBlockTypes( } static BROTLI_INLINE void PrepareLiteralDecoding(BrotliDecoderState* s) { - uint8_t context_mode; + uint8_t context_mode; size_t trivial; uint32_t block_type = s->block_type_rb[1]; uint32_t context_offset = block_type << BROTLI_LITERAL_CONTEXT_BITS; - s->context_map_slice = s->context_map + context_offset; + s->context_map_slice = s->context_map + context_offset; trivial = s->trivial_literal_contexts[block_type >> 5]; s->trivial_literal_context = (trivial >> (block_type & 31)) & 1; s->literal_htree = s->literal_hgroup.htrees[s->context_map_slice[0]]; context_mode = s->context_modes[block_type] & 3; s->context_lookup = BROTLI_CONTEXT_LUT(context_mode); -} - +} + /* Decodes the block type and updates the state for literal context. Reads 3..54 bits. */ static BROTLI_INLINE BROTLI_BOOL DecodeLiteralBlockSwitchInternal( @@ -1264,9 +1264,9 @@ static BrotliDecoderErrorCode BROTLI_NOINLINE WriteRingBuffer( if (num_written > to_write) { num_written = to_write; } - if (s->meta_block_remaining_len < 0) { + if (s->meta_block_remaining_len < 0) { return BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1); - } + } if (next_out && !*next_out) { *next_out = start; } else { @@ -1277,18 +1277,18 @@ static BrotliDecoderErrorCode BROTLI_NOINLINE WriteRingBuffer( } *available_out -= num_written; BROTLI_LOG_UINT(to_write); - BROTLI_LOG_UINT(num_written); + BROTLI_LOG_UINT(num_written); s->partial_pos_out += num_written; if (total_out) { *total_out = s->partial_pos_out; - } + } if (num_written < to_write) { if (s->ringbuffer_size == (1 << s->window_bits) || force) { return BROTLI_DECODER_NEEDS_MORE_OUTPUT; } else { return BROTLI_DECODER_SUCCESS; } - } + } /* Wrap ring buffer only if it has reached its maximal size. */ if (s->ringbuffer_size == (1 << s->window_bits) && s->pos >= s->ringbuffer_size) { @@ -1297,8 +1297,8 @@ static BrotliDecoderErrorCode BROTLI_NOINLINE WriteRingBuffer( s->should_wrap_ringbuffer = (size_t)s->pos != 0 ? 1 : 0; } return BROTLI_DECODER_SUCCESS; -} - +} + static void BROTLI_NOINLINE WrapRingBuffer(BrotliDecoderState* s) { if (s->should_wrap_ringbuffer) { memcpy(s->ringbuffer, s->ringbuffer_end, (size_t)s->pos); @@ -1350,17 +1350,17 @@ static BrotliDecoderErrorCode BROTLI_NOINLINE CopyUncompressedBlockToOutput( return BROTLI_FAILURE(BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1); } - /* State machine */ - for (;;) { + /* State machine */ + for (;;) { switch (s->substate_uncompressed) { case BROTLI_STATE_UNCOMPRESSED_NONE: { int nbytes = (int)BrotliGetRemainingBytes(&s->br); if (nbytes > s->meta_block_remaining_len) { nbytes = s->meta_block_remaining_len; - } + } if (s->pos + nbytes > s->ringbuffer_size) { nbytes = s->ringbuffer_size - s->pos; - } + } /* Copy remaining bytes from s->br.buf_ to ring-buffer. */ BrotliCopyBytes(&s->ringbuffer[s->pos], &s->br, (size_t)nbytes); s->pos += nbytes; @@ -1368,9 +1368,9 @@ static BrotliDecoderErrorCode BROTLI_NOINLINE CopyUncompressedBlockToOutput( if (s->pos < 1 << s->window_bits) { if (s->meta_block_remaining_len == 0) { return BROTLI_DECODER_SUCCESS; - } + } return BROTLI_DECODER_NEEDS_MORE_INPUT; - } + } s->substate_uncompressed = BROTLI_STATE_UNCOMPRESSED_WRITE; } /* Fall through. */ @@ -1380,19 +1380,19 @@ static BrotliDecoderErrorCode BROTLI_NOINLINE CopyUncompressedBlockToOutput( result = WriteRingBuffer( s, available_out, next_out, total_out, BROTLI_FALSE); if (result != BROTLI_DECODER_SUCCESS) { - return result; - } + return result; + } if (s->ringbuffer_size == 1 << s->window_bits) { s->max_distance = s->max_backward_distance; - } + } s->substate_uncompressed = BROTLI_STATE_UNCOMPRESSED_NONE; - break; + break; } - } - } + } + } BROTLI_DCHECK(0); /* Unreachable */ -} - +} + /* Calculates the smallest feasible ring buffer. If we know the data size is small, do not allocate more ring buffer @@ -1411,18 +1411,18 @@ static void BROTLI_NOINLINE BrotliCalculateRingBufferSize( /* If maximum is already reached, no further extension is retired. */ if (s->ringbuffer_size == window_size) { return; - } + } /* Metadata blocks does not touch ring buffer. */ if (s->is_metadata) { return; - } + } if (!s->ringbuffer) { output_size = 0; } else { output_size = s->pos; - } + } output_size += s->meta_block_remaining_len; min_size = min_size < output_size ? output_size : min_size; @@ -1433,16 +1433,16 @@ static void BROTLI_NOINLINE BrotliCalculateRingBufferSize( while ((new_ringbuffer_size >> 1) >= min_size) { new_ringbuffer_size >>= 1; } - } + } s->new_ringbuffer_size = new_ringbuffer_size; -} - +} + /* Reads 1..256 2-bit context modes. */ static BrotliDecoderErrorCode ReadContextModes(BrotliDecoderState* s) { BrotliBitReader* br = &s->br; int i = s->loop_counter; - + while (i < (int)s->num_block_types[0]) { uint32_t bits; if (!BrotliSafeReadBits(br, 2, &bits)) { @@ -1455,7 +1455,7 @@ static BrotliDecoderErrorCode ReadContextModes(BrotliDecoderState* s) { } return BROTLI_DECODER_SUCCESS; } - + static BROTLI_INLINE void TakeDistanceFromRingBuffer(BrotliDecoderState* s) { if (s->distance_code == 0) { --s->dist_rb_idx; @@ -1482,11 +1482,11 @@ static BROTLI_INLINE void TakeDistanceFromRingBuffer(BrotliDecoderState* s) { /* A huge distance will cause a BROTLI_FAILURE() soon. This is a little faster than failing here. */ s->distance_code = 0x7FFFFFFF; - } - } - } + } + } + } } - + static BROTLI_INLINE BROTLI_BOOL SafeReadBits( BrotliBitReader* const br, uint32_t n_bits, uint32_t* val) { if (n_bits != 0) { @@ -1494,9 +1494,9 @@ static BROTLI_INLINE BROTLI_BOOL SafeReadBits( } else { *val = 0; return BROTLI_TRUE; - } + } } - + /* Precondition: s->distance_code < 0. */ static BROTLI_INLINE BROTLI_BOOL ReadDistanceInternal( int safe, BrotliDecoderState* s, BrotliBitReader* br) { @@ -1512,7 +1512,7 @@ static BROTLI_INLINE BROTLI_BOOL ReadDistanceInternal( return BROTLI_FALSE; } s->distance_code = (int)code; - } + } /* Convert the distance code to the actual distance by possibly looking up past distances from the s->ringbuffer. */ s->distance_context = 0; @@ -1555,7 +1555,7 @@ static BROTLI_INLINE BROTLI_BOOL ReadDistanceInternal( --s->block_length[2]; return BROTLI_TRUE; } - + static BROTLI_INLINE void ReadDistance( BrotliDecoderState* s, BrotliBitReader* br) { ReadDistanceInternal(0, s, br); @@ -1580,7 +1580,7 @@ static BROTLI_INLINE BROTLI_BOOL ReadCommandInternal( if (!SafeReadSymbol(s->htree_command, br, &cmd_code)) { return BROTLI_FALSE; } - } + } v = kCmdLut[cmd_code]; s->distance_code = v.distance_code; s->distance_context = v.context; @@ -1597,28 +1597,28 @@ static BROTLI_INLINE BROTLI_BOOL ReadCommandInternal( BrotliBitReaderRestoreState(br, &memento); return BROTLI_FALSE; } - } + } s->copy_length = (int)copy_length + v.copy_len_offset; --s->block_length[1]; *insert_length += (int)insert_len_extra; return BROTLI_TRUE; } - + static BROTLI_INLINE void ReadCommand( BrotliDecoderState* s, BrotliBitReader* br, int* insert_length) { ReadCommandInternal(0, s, br, insert_length); -} - +} + static BROTLI_INLINE BROTLI_BOOL SafeReadCommand( BrotliDecoderState* s, BrotliBitReader* br, int* insert_length) { return ReadCommandInternal(1, s, br, insert_length); -} - +} + static BROTLI_INLINE BROTLI_BOOL CheckInputAmount( int safe, BrotliBitReader* const br, size_t num) { if (safe) { return BROTLI_TRUE; - } + } return BrotliCheckInputAmount(br, num); } @@ -1920,9 +1920,9 @@ CommandPostWrapCopy: saveStateAndReturn: s->pos = pos; s->loop_counter = i; - return result; -} - + return result; +} + #undef BROTLI_SAFE static BROTLI_NOINLINE BrotliDecoderErrorCode ProcessCommands( @@ -1970,9 +1970,9 @@ BrotliDecoderResult BrotliDecoderDecompress( if (result != BROTLI_DECODER_RESULT_SUCCESS) { result = BROTLI_DECODER_RESULT_ERROR; } - return result; -} - + return result; +} + /* Invariant: input stream is never overconsumed: - invalid input implies that the whole stream is invalid -> any amount of input could be read and discarded @@ -1988,7 +1988,7 @@ BrotliDecoderResult BrotliDecoderDecompressStream( BrotliDecoderState* s, size_t* available_in, const uint8_t** next_in, size_t* available_out, uint8_t** next_out, size_t* total_out) { BrotliDecoderErrorCode result = BROTLI_DECODER_SUCCESS; - BrotliBitReader* br = &s->br; + BrotliBitReader* br = &s->br; /* Ensure that |total_out| is set, even if no data will ever be pushed out. */ if (total_out) { *total_out = s->partial_pos_out; @@ -2012,8 +2012,8 @@ BrotliDecoderResult BrotliDecoderDecompressStream( result = BROTLI_DECODER_NEEDS_MORE_INPUT; br->next_in = &s->buffer.u8[0]; } - /* State machine */ - for (;;) { + /* State machine */ + for (;;) { if (result != BROTLI_DECODER_SUCCESS) { /* Error, needs more input/output. */ if (result == BROTLI_DECODER_NEEDS_MORE_INPUT) { @@ -2025,7 +2025,7 @@ BrotliDecoderResult BrotliDecoderDecompressStream( result = intermediate_result; break; } - } + } if (s->buffer_length != 0) { /* Used with internal buffer. */ if (br->avail_in == 0) { /* Successfully finished read transaction. @@ -2062,9 +2062,9 @@ BrotliDecoderResult BrotliDecoderDecompressStream( (*available_in)--; } break; - } + } /* Unreachable. */ - } + } /* Fail or needs more output. */ @@ -2081,15 +2081,15 @@ BrotliDecoderResult BrotliDecoderDecompressStream( *next_in = br->next_in; } break; - } - switch (s->state) { - case BROTLI_STATE_UNINITED: - /* Prepare to the first read. */ - if (!BrotliWarmupBitReader(br)) { + } + switch (s->state) { + case BROTLI_STATE_UNINITED: + /* Prepare to the first read. */ + if (!BrotliWarmupBitReader(br)) { result = BROTLI_DECODER_NEEDS_MORE_INPUT; - break; - } - /* Decode window size. */ + break; + } + /* Decode window size. */ result = DecodeWindowBits(s, br); /* Reads 1..8 bits. */ if (result != BROTLI_DECODER_SUCCESS) { break; @@ -2109,8 +2109,8 @@ BrotliDecoderResult BrotliDecoderDecompressStream( if (s->window_bits < BROTLI_LARGE_MIN_WBITS || s->window_bits > BROTLI_LARGE_MAX_WBITS) { result = BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS); - break; - } + break; + } s->state = BROTLI_STATE_INITIALIZE; /* Fall through. */ @@ -2118,99 +2118,99 @@ BrotliDecoderResult BrotliDecoderDecompressStream( BROTLI_LOG_UINT(s->window_bits); /* Maximum distance, see section 9.1. of the spec. */ s->max_backward_distance = (1 << s->window_bits) - BROTLI_WINDOW_GAP; - - /* Allocate memory for both block_type_trees and block_len_trees. */ + + /* Allocate memory for both block_type_trees and block_len_trees. */ s->block_type_trees = (HuffmanCode*)BROTLI_DECODER_ALLOC(s, sizeof(HuffmanCode) * 3 * (BROTLI_HUFFMAN_MAX_SIZE_258 + BROTLI_HUFFMAN_MAX_SIZE_26)); if (s->block_type_trees == 0) { result = BROTLI_FAILURE(BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES); - break; - } + break; + } s->block_len_trees = s->block_type_trees + 3 * BROTLI_HUFFMAN_MAX_SIZE_258; - - s->state = BROTLI_STATE_METABLOCK_BEGIN; + + s->state = BROTLI_STATE_METABLOCK_BEGIN; /* Fall through. */ - case BROTLI_STATE_METABLOCK_BEGIN: + case BROTLI_STATE_METABLOCK_BEGIN: BrotliDecoderStateMetablockBegin(s); BROTLI_LOG_UINT(s->pos); - s->state = BROTLI_STATE_METABLOCK_HEADER; + s->state = BROTLI_STATE_METABLOCK_HEADER; /* Fall through. */ - case BROTLI_STATE_METABLOCK_HEADER: + case BROTLI_STATE_METABLOCK_HEADER: result = DecodeMetaBlockLength(s, br); /* Reads 2 - 31 bits. */ if (result != BROTLI_DECODER_SUCCESS) { - break; - } - BROTLI_LOG_UINT(s->is_last_metablock); - BROTLI_LOG_UINT(s->meta_block_remaining_len); - BROTLI_LOG_UINT(s->is_metadata); - BROTLI_LOG_UINT(s->is_uncompressed); - if (s->is_metadata || s->is_uncompressed) { - if (!BrotliJumpToByteBoundary(br)) { + break; + } + BROTLI_LOG_UINT(s->is_last_metablock); + BROTLI_LOG_UINT(s->meta_block_remaining_len); + BROTLI_LOG_UINT(s->is_metadata); + BROTLI_LOG_UINT(s->is_uncompressed); + if (s->is_metadata || s->is_uncompressed) { + if (!BrotliJumpToByteBoundary(br)) { result = BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_PADDING_1); - break; - } - } - if (s->is_metadata) { - s->state = BROTLI_STATE_METADATA; - break; - } - if (s->meta_block_remaining_len == 0) { - s->state = BROTLI_STATE_METABLOCK_DONE; - break; - } + break; + } + } + if (s->is_metadata) { + s->state = BROTLI_STATE_METADATA; + break; + } + if (s->meta_block_remaining_len == 0) { + s->state = BROTLI_STATE_METABLOCK_DONE; + break; + } BrotliCalculateRingBufferSize(s); - if (s->is_uncompressed) { - s->state = BROTLI_STATE_UNCOMPRESSED; - break; - } + if (s->is_uncompressed) { + s->state = BROTLI_STATE_UNCOMPRESSED; + break; + } s->loop_counter = 0; - s->state = BROTLI_STATE_HUFFMAN_CODE_0; - break; + s->state = BROTLI_STATE_HUFFMAN_CODE_0; + break; case BROTLI_STATE_UNCOMPRESSED: { result = CopyUncompressedBlockToOutput( available_out, next_out, total_out, s); if (result != BROTLI_DECODER_SUCCESS) { - break; - } - s->state = BROTLI_STATE_METABLOCK_DONE; - break; + break; + } + s->state = BROTLI_STATE_METABLOCK_DONE; + break; } - case BROTLI_STATE_METADATA: - for (; s->meta_block_remaining_len > 0; --s->meta_block_remaining_len) { - uint32_t bits; - /* Read one byte and ignore it. */ - if (!BrotliSafeReadBits(br, 8, &bits)) { + case BROTLI_STATE_METADATA: + for (; s->meta_block_remaining_len > 0; --s->meta_block_remaining_len) { + uint32_t bits; + /* Read one byte and ignore it. */ + if (!BrotliSafeReadBits(br, 8, &bits)) { result = BROTLI_DECODER_NEEDS_MORE_INPUT; - break; - } - } + break; + } + } if (result == BROTLI_DECODER_SUCCESS) { - s->state = BROTLI_STATE_METABLOCK_DONE; - } - break; + s->state = BROTLI_STATE_METABLOCK_DONE; + } + break; - case BROTLI_STATE_HUFFMAN_CODE_0: + case BROTLI_STATE_HUFFMAN_CODE_0: if (s->loop_counter >= 3) { s->state = BROTLI_STATE_METABLOCK_HEADER_2; - break; - } - /* Reads 1..11 bits. */ + break; + } + /* Reads 1..11 bits. */ result = DecodeVarLenUint8(s, br, &s->num_block_types[s->loop_counter]); if (result != BROTLI_DECODER_SUCCESS) { - break; - } + break; + } s->num_block_types[s->loop_counter]++; BROTLI_LOG_UINT(s->num_block_types[s->loop_counter]); if (s->num_block_types[s->loop_counter] < 2) { s->loop_counter++; - break; - } + break; + } s->state = BROTLI_STATE_HUFFMAN_CODE_1; /* Fall through. */ @@ -2230,7 +2230,7 @@ BrotliDecoderResult BrotliDecoderDecompressStream( result = ReadHuffmanCode(alphabet_size, alphabet_size, &s->block_len_trees[tree_offset], NULL, s); if (result != BROTLI_DECODER_SUCCESS) break; - s->state = BROTLI_STATE_HUFFMAN_CODE_3; + s->state = BROTLI_STATE_HUFFMAN_CODE_3; } /* Fall through. */ @@ -2239,33 +2239,33 @@ BrotliDecoderResult BrotliDecoderDecompressStream( if (!SafeReadBlockLength(s, &s->block_length[s->loop_counter], &s->block_len_trees[tree_offset], br)) { result = BROTLI_DECODER_NEEDS_MORE_INPUT; - break; - } + break; + } BROTLI_LOG_UINT(s->block_length[s->loop_counter]); s->loop_counter++; - s->state = BROTLI_STATE_HUFFMAN_CODE_0; - break; + s->state = BROTLI_STATE_HUFFMAN_CODE_0; + break; } case BROTLI_STATE_METABLOCK_HEADER_2: { uint32_t bits; if (!BrotliSafeReadBits(br, 6, &bits)) { result = BROTLI_DECODER_NEEDS_MORE_INPUT; - break; - } + break; + } s->distance_postfix_bits = bits & BitMask(2); bits >>= 2; s->num_direct_distance_codes = BROTLI_NUM_DISTANCE_SHORT_CODES + (bits << s->distance_postfix_bits); - BROTLI_LOG_UINT(s->num_direct_distance_codes); - BROTLI_LOG_UINT(s->distance_postfix_bits); - s->distance_postfix_mask = (int)BitMask(s->distance_postfix_bits); + BROTLI_LOG_UINT(s->num_direct_distance_codes); + BROTLI_LOG_UINT(s->distance_postfix_bits); + s->distance_postfix_mask = (int)BitMask(s->distance_postfix_bits); s->context_modes = (uint8_t*)BROTLI_DECODER_ALLOC(s, (size_t)s->num_block_types[0]); - if (s->context_modes == 0) { + if (s->context_modes == 0) { result = BROTLI_FAILURE(BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES); - break; - } + break; + } s->loop_counter = 0; s->state = BROTLI_STATE_CONTEXT_MODES; } @@ -2275,19 +2275,19 @@ BrotliDecoderResult BrotliDecoderDecompressStream( result = ReadContextModes(s); if (result != BROTLI_DECODER_SUCCESS) { break; - } - s->state = BROTLI_STATE_CONTEXT_MAP_1; + } + s->state = BROTLI_STATE_CONTEXT_MAP_1; /* Fall through. */ - case BROTLI_STATE_CONTEXT_MAP_1: + case BROTLI_STATE_CONTEXT_MAP_1: result = DecodeContextMap( s->num_block_types[0] << BROTLI_LITERAL_CONTEXT_BITS, &s->num_literal_htrees, &s->context_map, s); if (result != BROTLI_DECODER_SUCCESS) { - break; - } + break; + } DetectTrivialLiteralBlockTypes(s); - s->state = BROTLI_STATE_CONTEXT_MAP_2; + s->state = BROTLI_STATE_CONTEXT_MAP_2; /* Fall through. */ case BROTLI_STATE_CONTEXT_MAP_2: { @@ -2307,7 +2307,7 @@ BrotliDecoderResult BrotliDecoderDecompressStream( &s->num_dist_htrees, &s->dist_context_map, s); if (result != BROTLI_DECODER_SUCCESS) { break; - } + } allocation_success &= BrotliDecoderHuffmanTreeGroupInit( s, &s->literal_hgroup, BROTLI_NUM_LITERAL_SYMBOLS, BROTLI_NUM_LITERAL_SYMBOLS, s->num_literal_htrees); @@ -2322,7 +2322,7 @@ BrotliDecoderResult BrotliDecoderDecompressStream( BROTLI_FAILURE(BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS)); } s->loop_counter = 0; - s->state = BROTLI_STATE_TREE_GROUP; + s->state = BROTLI_STATE_TREE_GROUP; } /* Fall through. */ @@ -2334,83 +2334,83 @@ BrotliDecoderResult BrotliDecoderDecompressStream( case 2: hgroup = &s->distance_hgroup; break; default: return SaveErrorCode(s, BROTLI_FAILURE( BROTLI_DECODER_ERROR_UNREACHABLE)); - } + } result = HuffmanTreeGroupDecode(hgroup, s); if (result != BROTLI_DECODER_SUCCESS) break; s->loop_counter++; if (s->loop_counter >= 3) { PrepareLiteralDecoding(s); - s->dist_context_map_slice = s->dist_context_map; - s->htree_command = s->insert_copy_hgroup.htrees[0]; + s->dist_context_map_slice = s->dist_context_map; + s->htree_command = s->insert_copy_hgroup.htrees[0]; if (!BrotliEnsureRingBuffer(s)) { result = BROTLI_FAILURE(BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2); break; } - s->state = BROTLI_STATE_COMMAND_BEGIN; - } - break; + s->state = BROTLI_STATE_COMMAND_BEGIN; + } + break; } - case BROTLI_STATE_COMMAND_BEGIN: + case BROTLI_STATE_COMMAND_BEGIN: /* Fall through. */ - case BROTLI_STATE_COMMAND_INNER: + case BROTLI_STATE_COMMAND_INNER: /* Fall through. */ case BROTLI_STATE_COMMAND_POST_DECODE_LITERALS: /* Fall through. */ - case BROTLI_STATE_COMMAND_POST_WRAP_COPY: + case BROTLI_STATE_COMMAND_POST_WRAP_COPY: result = ProcessCommands(s); if (result == BROTLI_DECODER_NEEDS_MORE_INPUT) { result = SafeProcessCommands(s); - } - break; + } + break; - case BROTLI_STATE_COMMAND_INNER_WRITE: + case BROTLI_STATE_COMMAND_INNER_WRITE: /* Fall through. */ - case BROTLI_STATE_COMMAND_POST_WRITE_1: + case BROTLI_STATE_COMMAND_POST_WRITE_1: /* Fall through. */ - case BROTLI_STATE_COMMAND_POST_WRITE_2: + case BROTLI_STATE_COMMAND_POST_WRITE_2: result = WriteRingBuffer( s, available_out, next_out, total_out, BROTLI_FALSE); if (result != BROTLI_DECODER_SUCCESS) { - break; - } + break; + } WrapRingBuffer(s); if (s->ringbuffer_size == 1 << s->window_bits) { s->max_distance = s->max_backward_distance; } - if (s->state == BROTLI_STATE_COMMAND_POST_WRITE_1) { + if (s->state == BROTLI_STATE_COMMAND_POST_WRITE_1) { if (s->meta_block_remaining_len == 0) { /* Next metablock, if any. */ - s->state = BROTLI_STATE_METABLOCK_DONE; - } else { + s->state = BROTLI_STATE_METABLOCK_DONE; + } else { s->state = BROTLI_STATE_COMMAND_BEGIN; - } + } break; - } else if (s->state == BROTLI_STATE_COMMAND_POST_WRITE_2) { - s->state = BROTLI_STATE_COMMAND_POST_WRAP_COPY; - } else { /* BROTLI_STATE_COMMAND_INNER_WRITE */ + } else if (s->state == BROTLI_STATE_COMMAND_POST_WRITE_2) { + s->state = BROTLI_STATE_COMMAND_POST_WRAP_COPY; + } else { /* BROTLI_STATE_COMMAND_INNER_WRITE */ if (s->loop_counter == 0) { if (s->meta_block_remaining_len == 0) { - s->state = BROTLI_STATE_METABLOCK_DONE; + s->state = BROTLI_STATE_METABLOCK_DONE; } else { s->state = BROTLI_STATE_COMMAND_POST_DECODE_LITERALS; - } + } break; - } - s->state = BROTLI_STATE_COMMAND_INNER; - } - break; + } + s->state = BROTLI_STATE_COMMAND_INNER; + } + break; - case BROTLI_STATE_METABLOCK_DONE: + case BROTLI_STATE_METABLOCK_DONE: if (s->meta_block_remaining_len < 0) { result = BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2); break; } BrotliDecoderStateCleanupAfterMetablock(s); - if (!s->is_last_metablock) { - s->state = BROTLI_STATE_METABLOCK_BEGIN; - break; - } + if (!s->is_last_metablock) { + s->state = BROTLI_STATE_METABLOCK_BEGIN; + break; + } if (!BrotliJumpToByteBoundary(br)) { result = BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_PADDING_2); break; @@ -2420,20 +2420,20 @@ BrotliDecoderResult BrotliDecoderDecompressStream( *available_in = br->avail_in; *next_in = br->next_in; } - s->state = BROTLI_STATE_DONE; + s->state = BROTLI_STATE_DONE; /* Fall through. */ - case BROTLI_STATE_DONE: - if (s->ringbuffer != 0) { + case BROTLI_STATE_DONE: + if (s->ringbuffer != 0) { result = WriteRingBuffer( s, available_out, next_out, total_out, BROTLI_TRUE); if (result != BROTLI_DECODER_SUCCESS) { - break; - } - } + break; + } + } return SaveErrorCode(s, result); - } - } + } + } return SaveErrorCode(s, result); } @@ -2468,19 +2468,19 @@ const uint8_t* BrotliDecoderTakeOutput(BrotliDecoderState* s, size_t* size) { *size = 0; result = 0; } - return result; -} - + return result; +} + BROTLI_BOOL BrotliDecoderIsUsed(const BrotliDecoderState* s) { return TO_BROTLI_BOOL(s->state != BROTLI_STATE_UNINITED || BrotliGetAvailableBits(&s->br) != 0); -} - +} + BROTLI_BOOL BrotliDecoderIsFinished(const BrotliDecoderState* s) { return TO_BROTLI_BOOL(s->state == BROTLI_STATE_DONE) && !BrotliDecoderHasMoreOutput(s); } - + BrotliDecoderErrorCode BrotliDecoderGetErrorCode(const BrotliDecoderState* s) { return (BrotliDecoderErrorCode)s->error_code; } @@ -2501,6 +2501,6 @@ uint32_t BrotliDecoderVersion() { return BROTLI_VERSION; } -#if defined(__cplusplus) || defined(c_plusplus) +#if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ -#endif +#endif diff --git a/contrib/libs/brotli/dec/huffman.c b/contrib/libs/brotli/dec/huffman.c index 02e5b15c22..30c40d33f2 100644 --- a/contrib/libs/brotli/dec/huffman.c +++ b/contrib/libs/brotli/dec/huffman.c @@ -1,29 +1,29 @@ -/* Copyright 2013 Google Inc. All Rights Reserved. - +/* Copyright 2013 Google Inc. All Rights Reserved. + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT -*/ - -/* Utilities for building Huffman decoding tables. */ - -#include "./huffman.h" +*/ + +/* Utilities for building Huffman decoding tables. */ + +#include "./huffman.h" #include <string.h> /* memcpy, memset */ #include "../common/constants.h" #include "../common/platform.h" #include <brotli/types.h> - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - + +#if defined(__cplusplus) || defined(c_plusplus) +extern "C" { +#endif + #define BROTLI_REVERSE_BITS_MAX 8 #if defined(BROTLI_RBIT) #define BROTLI_REVERSE_BITS_BASE \ ((sizeof(brotli_reg_t) << 3) - BROTLI_REVERSE_BITS_MAX) -#else +#else #define BROTLI_REVERSE_BITS_BASE 0 static uint8_t kReverseBits[1 << BROTLI_REVERSE_BITS_MAX] = { 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, @@ -72,37 +72,37 @@ static BROTLI_INLINE brotli_reg_t BrotliReverseBits(brotli_reg_t num) { return BROTLI_RBIT(num); #else return kReverseBits[num]; -#endif -} - -/* Stores code in table[0], table[step], table[2*step], ..., table[end] */ -/* Assumes that end is an integer multiple of step */ -static BROTLI_INLINE void ReplicateValue(HuffmanCode* table, - int step, int end, - HuffmanCode code) { - do { - end -= step; - table[end] = code; - } while (end > 0); -} - +#endif +} + +/* Stores code in table[0], table[step], table[2*step], ..., table[end] */ +/* Assumes that end is an integer multiple of step */ +static BROTLI_INLINE void ReplicateValue(HuffmanCode* table, + int step, int end, + HuffmanCode code) { + do { + end -= step; + table[end] = code; + } while (end > 0); +} + /* Returns the table width of the next 2nd level table. |count| is the histogram of bit lengths for the remaining symbols, |len| is the code length of the next processed symbol. */ -static BROTLI_INLINE int NextTableBitSize(const uint16_t* const count, - int len, int root_bits) { - int left = 1 << (len - root_bits); - while (len < BROTLI_HUFFMAN_MAX_CODE_LENGTH) { - left -= count[len]; - if (left <= 0) break; - ++len; - left <<= 1; - } - return len - root_bits; -} - -void BrotliBuildCodeLengthsHuffmanTable(HuffmanCode* table, - const uint8_t* const code_lengths, +static BROTLI_INLINE int NextTableBitSize(const uint16_t* const count, + int len, int root_bits) { + int left = 1 << (len - root_bits); + while (len < BROTLI_HUFFMAN_MAX_CODE_LENGTH) { + left -= count[len]; + if (left <= 0) break; + ++len; + left <<= 1; + } + return len - root_bits; +} + +void BrotliBuildCodeLengthsHuffmanTable(HuffmanCode* table, + const uint8_t* const code_lengths, uint16_t* count) { HuffmanCode code; /* current table entry */ int symbol; /* symbol index in original or sorted table */ @@ -111,61 +111,61 @@ void BrotliBuildCodeLengthsHuffmanTable(HuffmanCode* table, int step; /* step size to replicate values in current table */ int table_size; /* size of current table */ int sorted[BROTLI_CODE_LENGTH_CODES]; /* symbols sorted by code length */ - /* offsets in sorted table for each length */ - int offset[BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH + 1]; - int bits; - int bits_count; + /* offsets in sorted table for each length */ + int offset[BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH + 1]; + int bits; + int bits_count; BROTLI_DCHECK(BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH <= BROTLI_REVERSE_BITS_MAX); - + /* Generate offsets into sorted symbol table by code length. */ - symbol = -1; - bits = 1; - BROTLI_REPEAT(BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH, { - symbol += count[bits]; - offset[bits] = symbol; - bits++; - }); + symbol = -1; + bits = 1; + BROTLI_REPEAT(BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH, { + symbol += count[bits]; + offset[bits] = symbol; + bits++; + }); /* Symbols with code length 0 are placed after all other symbols. */ offset[0] = BROTLI_CODE_LENGTH_CODES - 1; - + /* Sort symbols by length, by symbol order within each length. */ symbol = BROTLI_CODE_LENGTH_CODES; - do { - BROTLI_REPEAT(6, { - symbol--; - sorted[offset[code_lengths[symbol]]--] = symbol; - }); - } while (symbol != 0); - - table_size = 1 << BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH; - + do { + BROTLI_REPEAT(6, { + symbol--; + sorted[offset[code_lengths[symbol]]--] = symbol; + }); + } while (symbol != 0); + + table_size = 1 << BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH; + /* Special case: all symbols but one have 0 code length. */ if (offset[0] == 0) { code = ConstructHuffmanCode(0, (uint16_t)sorted[0]); for (key = 0; key < (brotli_reg_t)table_size; ++key) { - table[key] = code; - } - return; - } - + table[key] = code; + } + return; + } + /* Fill in table. */ - key = 0; + key = 0; key_step = BROTLI_REVERSE_BITS_LOWEST; - symbol = 0; - bits = 1; - step = 2; - do { - for (bits_count = count[bits]; bits_count != 0; --bits_count) { + symbol = 0; + bits = 1; + step = 2; + do { + for (bits_count = count[bits]; bits_count != 0; --bits_count) { code = ConstructHuffmanCode((uint8_t)bits, (uint16_t)sorted[symbol++]); ReplicateValue(&table[BrotliReverseBits(key)], step, table_size, code); key += key_step; - } - step <<= 1; + } + step <<= 1; key_step >>= 1; - } while (++bits <= BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH); -} - + } while (++bits <= BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH); +} + uint32_t BrotliBuildHuffmanTable(HuffmanCode* root_table, int root_bits, const uint16_t* const symbol_lists, @@ -182,114 +182,114 @@ uint32_t BrotliBuildHuffmanTable(HuffmanCode* root_table, int table_bits; /* key length of current table */ int table_size; /* size of current table */ int total_size; /* sum of root table size and 2nd level table sizes */ - int max_length = -1; - int bits; - int bits_count; - + int max_length = -1; + int bits; + int bits_count; + BROTLI_DCHECK(root_bits <= BROTLI_REVERSE_BITS_MAX); BROTLI_DCHECK(BROTLI_HUFFMAN_MAX_CODE_LENGTH - root_bits <= BROTLI_REVERSE_BITS_MAX); - while (symbol_lists[max_length] == 0xFFFF) max_length--; - max_length += BROTLI_HUFFMAN_MAX_CODE_LENGTH + 1; - - table = root_table; - table_bits = root_bits; - table_size = 1 << table_bits; - total_size = table_size; - + while (symbol_lists[max_length] == 0xFFFF) max_length--; + max_length += BROTLI_HUFFMAN_MAX_CODE_LENGTH + 1; + + table = root_table; + table_bits = root_bits; + table_size = 1 << table_bits; + total_size = table_size; + /* Fill in the root table. Reduce the table size to if possible, and create the repetitions by memcpy. */ - if (table_bits > max_length) { - table_bits = max_length; - table_size = 1 << table_bits; - } - key = 0; + if (table_bits > max_length) { + table_bits = max_length; + table_size = 1 << table_bits; + } + key = 0; key_step = BROTLI_REVERSE_BITS_LOWEST; - bits = 1; - step = 2; - do { - symbol = bits - (BROTLI_HUFFMAN_MAX_CODE_LENGTH + 1); - for (bits_count = count[bits]; bits_count != 0; --bits_count) { - symbol = symbol_lists[symbol]; + bits = 1; + step = 2; + do { + symbol = bits - (BROTLI_HUFFMAN_MAX_CODE_LENGTH + 1); + for (bits_count = count[bits]; bits_count != 0; --bits_count) { + symbol = symbol_lists[symbol]; code = ConstructHuffmanCode((uint8_t)bits, (uint16_t)symbol); ReplicateValue(&table[BrotliReverseBits(key)], step, table_size, code); key += key_step; - } - step <<= 1; + } + step <<= 1; key_step >>= 1; - } while (++bits <= table_bits); - + } while (++bits <= table_bits); + /* If root_bits != table_bits then replicate to fill the remaining slots. */ - while (total_size != table_size) { - memcpy(&table[table_size], &table[0], - (size_t)table_size * sizeof(table[0])); - table_size <<= 1; - } - + while (total_size != table_size) { + memcpy(&table[table_size], &table[0], + (size_t)table_size * sizeof(table[0])); + table_size <<= 1; + } + /* Fill in 2nd level tables and add pointers to root table. */ key_step = BROTLI_REVERSE_BITS_LOWEST >> (root_bits - 1); sub_key = (BROTLI_REVERSE_BITS_LOWEST << 1); sub_key_step = BROTLI_REVERSE_BITS_LOWEST; for (len = root_bits + 1, step = 2; len <= max_length; ++len) { - symbol = len - (BROTLI_HUFFMAN_MAX_CODE_LENGTH + 1); - for (; count[len] != 0; --count[len]) { + symbol = len - (BROTLI_HUFFMAN_MAX_CODE_LENGTH + 1); + for (; count[len] != 0; --count[len]) { if (sub_key == (BROTLI_REVERSE_BITS_LOWEST << 1U)) { - table += table_size; - table_bits = NextTableBitSize(count, len, root_bits); - table_size = 1 << table_bits; - total_size += table_size; + table += table_size; + table_bits = NextTableBitSize(count, len, root_bits); + table_size = 1 << table_bits; + total_size += table_size; sub_key = BrotliReverseBits(key); key += key_step; root_table[sub_key] = ConstructHuffmanCode( (uint8_t)(table_bits + root_bits), (uint16_t)(((size_t)(table - root_table)) - sub_key)); sub_key = 0; - } - symbol = symbol_lists[symbol]; + } + symbol = symbol_lists[symbol]; code = ConstructHuffmanCode((uint8_t)(len - root_bits), (uint16_t)symbol); ReplicateValue( &table[BrotliReverseBits(sub_key)], step, table_size, code); sub_key += sub_key_step; - } + } step <<= 1; sub_key_step >>= 1; - } + } return (uint32_t)total_size; -} - +} + uint32_t BrotliBuildSimpleHuffmanTable(HuffmanCode* table, int root_bits, uint16_t* val, uint32_t num_symbols) { uint32_t table_size = 1; const uint32_t goal_size = 1U << root_bits; - switch (num_symbols) { - case 0: + switch (num_symbols) { + case 0: table[0] = ConstructHuffmanCode(0, val[0]); - break; - case 1: - if (val[1] > val[0]) { + break; + case 1: + if (val[1] > val[0]) { table[0] = ConstructHuffmanCode(1, val[0]); table[1] = ConstructHuffmanCode(1, val[1]); - } else { + } else { table[0] = ConstructHuffmanCode(1, val[1]); table[1] = ConstructHuffmanCode(1, val[0]); - } - table_size = 2; - break; - case 2: + } + table_size = 2; + break; + case 2: table[0] = ConstructHuffmanCode(1, val[0]); table[2] = ConstructHuffmanCode(1, val[0]); - if (val[2] > val[1]) { + if (val[2] > val[1]) { table[1] = ConstructHuffmanCode(2, val[1]); table[3] = ConstructHuffmanCode(2, val[2]); - } else { + } else { table[1] = ConstructHuffmanCode(2, val[2]); table[3] = ConstructHuffmanCode(2, val[1]); - } - table_size = 4; - break; + } + table_size = 4; + break; case 3: { int i, k; for (i = 0; i < 3; ++i) { @@ -298,22 +298,22 @@ uint32_t BrotliBuildSimpleHuffmanTable(HuffmanCode* table, uint16_t t = val[k]; val[k] = val[i]; val[i] = t; - } - } - } + } + } + } table[0] = ConstructHuffmanCode(2, val[0]); table[2] = ConstructHuffmanCode(2, val[1]); table[1] = ConstructHuffmanCode(2, val[2]); table[3] = ConstructHuffmanCode(2, val[3]); table_size = 4; - break; + break; } case 4: { if (val[3] < val[2]) { uint16_t t = val[3]; val[3] = val[2]; val[2] = t; - } + } table[0] = ConstructHuffmanCode(1, val[0]); table[1] = ConstructHuffmanCode(2, val[1]); table[2] = ConstructHuffmanCode(1, val[0]); @@ -323,17 +323,17 @@ uint32_t BrotliBuildSimpleHuffmanTable(HuffmanCode* table, table[6] = ConstructHuffmanCode(1, val[0]); table[7] = ConstructHuffmanCode(3, val[3]); table_size = 8; - break; + break; } - } - while (table_size != goal_size) { - memcpy(&table[table_size], &table[0], - (size_t)table_size * sizeof(table[0])); - table_size <<= 1; - } - return goal_size; -} - -#if defined(__cplusplus) || defined(c_plusplus) + } + while (table_size != goal_size) { + memcpy(&table[table_size], &table[0], + (size_t)table_size * sizeof(table[0])); + table_size <<= 1; + } + return goal_size; +} + +#if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ -#endif +#endif diff --git a/contrib/libs/brotli/dec/huffman.h b/contrib/libs/brotli/dec/huffman.h index 9951f8e15d..b9f0716c16 100644 --- a/contrib/libs/brotli/dec/huffman.h +++ b/contrib/libs/brotli/dec/huffman.h @@ -1,23 +1,23 @@ -/* Copyright 2013 Google Inc. All Rights Reserved. - +/* Copyright 2013 Google Inc. All Rights Reserved. + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT -*/ - -/* Utilities for building Huffman decoding tables. */ - -#ifndef BROTLI_DEC_HUFFMAN_H_ -#define BROTLI_DEC_HUFFMAN_H_ - +*/ + +/* Utilities for building Huffman decoding tables. */ + +#ifndef BROTLI_DEC_HUFFMAN_H_ +#define BROTLI_DEC_HUFFMAN_H_ + #include "../common/platform.h" #include <brotli/types.h> - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -#define BROTLI_HUFFMAN_MAX_CODE_LENGTH 15 - + +#if defined(__cplusplus) || defined(c_plusplus) +extern "C" { +#endif + +#define BROTLI_HUFFMAN_MAX_CODE_LENGTH 15 + /* Maximum possible Huffman table size for an alphabet size of (index * 32), max code length 15 and root table bits 8. */ static const uint16_t kMaxHuffmanTableSize[] = { @@ -30,9 +30,9 @@ static const uint16_t kMaxHuffmanTableSize[] = { #define BROTLI_HUFFMAN_MAX_SIZE_258 632 /* BROTLI_MAX_CONTEXT_MAP_SYMBOLS == 272 */ #define BROTLI_HUFFMAN_MAX_SIZE_272 646 - -#define BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH 5 - + +#define BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH 5 + #if ((defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8_32)) && \ BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0)) #define BROTLI_HUFFMAN_CODE_FAST_LOAD @@ -41,11 +41,11 @@ static const uint16_t kMaxHuffmanTableSize[] = { #if !defined(BROTLI_HUFFMAN_CODE_FAST_LOAD) /* Do not create this struct directly - use the ConstructHuffmanCode * constructor below! */ -typedef struct { +typedef struct { uint8_t bits; /* number of bits used for this symbol */ uint16_t value; /* symbol value or table offset */ -} HuffmanCode; - +} HuffmanCode; + static BROTLI_INLINE HuffmanCode ConstructHuffmanCode(const uint8_t bits, const uint16_t value) { HuffmanCode h; @@ -93,35 +93,35 @@ static BROTLI_INLINE HuffmanCode ConstructHuffmanCode(const uint8_t bits, #define BROTLI_HC_FAST_LOAD_VALUE(H) ((__fastload_##H) >> 16) #endif /* BROTLI_HUFFMAN_CODE_FAST_LOAD */ -/* Builds Huffman lookup table assuming code lengths are in symbol order. */ +/* Builds Huffman lookup table assuming code lengths are in symbol order. */ BROTLI_INTERNAL void BrotliBuildCodeLengthsHuffmanTable(HuffmanCode* root_table, const uint8_t* const code_lengths, uint16_t* count); - + /* Builds Huffman lookup table assuming code lengths are in symbol order. Returns size of resulting table. */ BROTLI_INTERNAL uint32_t BrotliBuildHuffmanTable(HuffmanCode* root_table, int root_bits, const uint16_t* const symbol_lists, uint16_t* count_arg); - + /* Builds a simple Huffman table. The |num_symbols| parameter is to be interpreted as follows: 0 means 1 symbol, 1 means 2 symbols, 2 means 3 symbols, 3 means 4 symbols with lengths [2, 2, 2, 2], 4 means 4 symbols with lengths [1, 2, 3, 3]. */ BROTLI_INTERNAL uint32_t BrotliBuildSimpleHuffmanTable(HuffmanCode* table, int root_bits, uint16_t* symbols, uint32_t num_symbols); - -/* Contains a collection of Huffman trees with the same alphabet size. */ + +/* Contains a collection of Huffman trees with the same alphabet size. */ /* max_symbol is needed due to simple codes since log2(alphabet_size) could be greater than log2(max_symbol). */ -typedef struct { - HuffmanCode** htrees; - HuffmanCode* codes; +typedef struct { + HuffmanCode** htrees; + HuffmanCode* codes; uint16_t alphabet_size; uint16_t max_symbol; uint16_t num_htrees; -} HuffmanTreeGroup; - -#if defined(__cplusplus) || defined(c_plusplus) +} HuffmanTreeGroup; + +#if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ -#endif - -#endif /* BROTLI_DEC_HUFFMAN_H_ */ +#endif + +#endif /* BROTLI_DEC_HUFFMAN_H_ */ diff --git a/contrib/libs/brotli/dec/prefix.h b/contrib/libs/brotli/dec/prefix.h index b4ceebfbd4..3ea062d84a 100644 --- a/contrib/libs/brotli/dec/prefix.h +++ b/contrib/libs/brotli/dec/prefix.h @@ -1,750 +1,750 @@ -/* Copyright 2013 Google Inc. All Rights Reserved. - +/* Copyright 2013 Google Inc. All Rights Reserved. + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT -*/ - -/* Lookup tables to map prefix codes to value ranges. This is used during +*/ + +/* Lookup tables to map prefix codes to value ranges. This is used during decoding of the block lengths, literal insertion lengths and copy lengths. */ - -#ifndef BROTLI_DEC_PREFIX_H_ -#define BROTLI_DEC_PREFIX_H_ - + +#ifndef BROTLI_DEC_PREFIX_H_ +#define BROTLI_DEC_PREFIX_H_ + #include "../common/constants.h" #include <brotli/types.h> /* Represents the range of values belonging to a prefix code: [offset, offset + 2^nbits) */ -struct PrefixCodeRange { +struct PrefixCodeRange { uint16_t offset; uint8_t nbits; -}; - +}; + static const struct PrefixCodeRange kBlockLengthPrefixCode[BROTLI_NUM_BLOCK_LEN_SYMBOLS] = { - { 1, 2}, { 5, 2}, { 9, 2}, { 13, 2}, - { 17, 3}, { 25, 3}, { 33, 3}, { 41, 3}, - { 49, 4}, { 65, 4}, { 81, 4}, { 97, 4}, - { 113, 5}, { 145, 5}, { 177, 5}, { 209, 5}, - { 241, 6}, { 305, 6}, { 369, 7}, { 497, 8}, - { 753, 9}, { 1265, 10}, {2289, 11}, {4337, 12}, - {8433, 13}, {16625, 24} -}; - -typedef struct CmdLutElement { - uint8_t insert_len_extra_bits; - uint8_t copy_len_extra_bits; - int8_t distance_code; - uint8_t context; - uint16_t insert_len_offset; - uint16_t copy_len_offset; -} CmdLutElement; - + { 1, 2}, { 5, 2}, { 9, 2}, { 13, 2}, + { 17, 3}, { 25, 3}, { 33, 3}, { 41, 3}, + { 49, 4}, { 65, 4}, { 81, 4}, { 97, 4}, + { 113, 5}, { 145, 5}, { 177, 5}, { 209, 5}, + { 241, 6}, { 305, 6}, { 369, 7}, { 497, 8}, + { 753, 9}, { 1265, 10}, {2289, 11}, {4337, 12}, + {8433, 13}, {16625, 24} +}; + +typedef struct CmdLutElement { + uint8_t insert_len_extra_bits; + uint8_t copy_len_extra_bits; + int8_t distance_code; + uint8_t context; + uint16_t insert_len_offset; + uint16_t copy_len_offset; +} CmdLutElement; + static const CmdLutElement kCmdLut[BROTLI_NUM_COMMAND_SYMBOLS] = { - { 0x00, 0x00, 0, 0x00, 0x0000, 0x0002 }, - { 0x00, 0x00, 0, 0x01, 0x0000, 0x0003 }, - { 0x00, 0x00, 0, 0x02, 0x0000, 0x0004 }, - { 0x00, 0x00, 0, 0x03, 0x0000, 0x0005 }, - { 0x00, 0x00, 0, 0x03, 0x0000, 0x0006 }, - { 0x00, 0x00, 0, 0x03, 0x0000, 0x0007 }, - { 0x00, 0x00, 0, 0x03, 0x0000, 0x0008 }, - { 0x00, 0x00, 0, 0x03, 0x0000, 0x0009 }, - { 0x00, 0x00, 0, 0x00, 0x0001, 0x0002 }, - { 0x00, 0x00, 0, 0x01, 0x0001, 0x0003 }, - { 0x00, 0x00, 0, 0x02, 0x0001, 0x0004 }, - { 0x00, 0x00, 0, 0x03, 0x0001, 0x0005 }, - { 0x00, 0x00, 0, 0x03, 0x0001, 0x0006 }, - { 0x00, 0x00, 0, 0x03, 0x0001, 0x0007 }, - { 0x00, 0x00, 0, 0x03, 0x0001, 0x0008 }, - { 0x00, 0x00, 0, 0x03, 0x0001, 0x0009 }, - { 0x00, 0x00, 0, 0x00, 0x0002, 0x0002 }, - { 0x00, 0x00, 0, 0x01, 0x0002, 0x0003 }, - { 0x00, 0x00, 0, 0x02, 0x0002, 0x0004 }, - { 0x00, 0x00, 0, 0x03, 0x0002, 0x0005 }, - { 0x00, 0x00, 0, 0x03, 0x0002, 0x0006 }, - { 0x00, 0x00, 0, 0x03, 0x0002, 0x0007 }, - { 0x00, 0x00, 0, 0x03, 0x0002, 0x0008 }, - { 0x00, 0x00, 0, 0x03, 0x0002, 0x0009 }, - { 0x00, 0x00, 0, 0x00, 0x0003, 0x0002 }, - { 0x00, 0x00, 0, 0x01, 0x0003, 0x0003 }, - { 0x00, 0x00, 0, 0x02, 0x0003, 0x0004 }, - { 0x00, 0x00, 0, 0x03, 0x0003, 0x0005 }, - { 0x00, 0x00, 0, 0x03, 0x0003, 0x0006 }, - { 0x00, 0x00, 0, 0x03, 0x0003, 0x0007 }, - { 0x00, 0x00, 0, 0x03, 0x0003, 0x0008 }, - { 0x00, 0x00, 0, 0x03, 0x0003, 0x0009 }, - { 0x00, 0x00, 0, 0x00, 0x0004, 0x0002 }, - { 0x00, 0x00, 0, 0x01, 0x0004, 0x0003 }, - { 0x00, 0x00, 0, 0x02, 0x0004, 0x0004 }, - { 0x00, 0x00, 0, 0x03, 0x0004, 0x0005 }, - { 0x00, 0x00, 0, 0x03, 0x0004, 0x0006 }, - { 0x00, 0x00, 0, 0x03, 0x0004, 0x0007 }, - { 0x00, 0x00, 0, 0x03, 0x0004, 0x0008 }, - { 0x00, 0x00, 0, 0x03, 0x0004, 0x0009 }, - { 0x00, 0x00, 0, 0x00, 0x0005, 0x0002 }, - { 0x00, 0x00, 0, 0x01, 0x0005, 0x0003 }, - { 0x00, 0x00, 0, 0x02, 0x0005, 0x0004 }, - { 0x00, 0x00, 0, 0x03, 0x0005, 0x0005 }, - { 0x00, 0x00, 0, 0x03, 0x0005, 0x0006 }, - { 0x00, 0x00, 0, 0x03, 0x0005, 0x0007 }, - { 0x00, 0x00, 0, 0x03, 0x0005, 0x0008 }, - { 0x00, 0x00, 0, 0x03, 0x0005, 0x0009 }, - { 0x01, 0x00, 0, 0x00, 0x0006, 0x0002 }, - { 0x01, 0x00, 0, 0x01, 0x0006, 0x0003 }, - { 0x01, 0x00, 0, 0x02, 0x0006, 0x0004 }, - { 0x01, 0x00, 0, 0x03, 0x0006, 0x0005 }, - { 0x01, 0x00, 0, 0x03, 0x0006, 0x0006 }, - { 0x01, 0x00, 0, 0x03, 0x0006, 0x0007 }, - { 0x01, 0x00, 0, 0x03, 0x0006, 0x0008 }, - { 0x01, 0x00, 0, 0x03, 0x0006, 0x0009 }, - { 0x01, 0x00, 0, 0x00, 0x0008, 0x0002 }, - { 0x01, 0x00, 0, 0x01, 0x0008, 0x0003 }, - { 0x01, 0x00, 0, 0x02, 0x0008, 0x0004 }, - { 0x01, 0x00, 0, 0x03, 0x0008, 0x0005 }, - { 0x01, 0x00, 0, 0x03, 0x0008, 0x0006 }, - { 0x01, 0x00, 0, 0x03, 0x0008, 0x0007 }, - { 0x01, 0x00, 0, 0x03, 0x0008, 0x0008 }, - { 0x01, 0x00, 0, 0x03, 0x0008, 0x0009 }, - { 0x00, 0x01, 0, 0x03, 0x0000, 0x000a }, - { 0x00, 0x01, 0, 0x03, 0x0000, 0x000c }, - { 0x00, 0x02, 0, 0x03, 0x0000, 0x000e }, - { 0x00, 0x02, 0, 0x03, 0x0000, 0x0012 }, - { 0x00, 0x03, 0, 0x03, 0x0000, 0x0016 }, - { 0x00, 0x03, 0, 0x03, 0x0000, 0x001e }, - { 0x00, 0x04, 0, 0x03, 0x0000, 0x0026 }, - { 0x00, 0x04, 0, 0x03, 0x0000, 0x0036 }, - { 0x00, 0x01, 0, 0x03, 0x0001, 0x000a }, - { 0x00, 0x01, 0, 0x03, 0x0001, 0x000c }, - { 0x00, 0x02, 0, 0x03, 0x0001, 0x000e }, - { 0x00, 0x02, 0, 0x03, 0x0001, 0x0012 }, - { 0x00, 0x03, 0, 0x03, 0x0001, 0x0016 }, - { 0x00, 0x03, 0, 0x03, 0x0001, 0x001e }, - { 0x00, 0x04, 0, 0x03, 0x0001, 0x0026 }, - { 0x00, 0x04, 0, 0x03, 0x0001, 0x0036 }, - { 0x00, 0x01, 0, 0x03, 0x0002, 0x000a }, - { 0x00, 0x01, 0, 0x03, 0x0002, 0x000c }, - { 0x00, 0x02, 0, 0x03, 0x0002, 0x000e }, - { 0x00, 0x02, 0, 0x03, 0x0002, 0x0012 }, - { 0x00, 0x03, 0, 0x03, 0x0002, 0x0016 }, - { 0x00, 0x03, 0, 0x03, 0x0002, 0x001e }, - { 0x00, 0x04, 0, 0x03, 0x0002, 0x0026 }, - { 0x00, 0x04, 0, 0x03, 0x0002, 0x0036 }, - { 0x00, 0x01, 0, 0x03, 0x0003, 0x000a }, - { 0x00, 0x01, 0, 0x03, 0x0003, 0x000c }, - { 0x00, 0x02, 0, 0x03, 0x0003, 0x000e }, - { 0x00, 0x02, 0, 0x03, 0x0003, 0x0012 }, - { 0x00, 0x03, 0, 0x03, 0x0003, 0x0016 }, - { 0x00, 0x03, 0, 0x03, 0x0003, 0x001e }, - { 0x00, 0x04, 0, 0x03, 0x0003, 0x0026 }, - { 0x00, 0x04, 0, 0x03, 0x0003, 0x0036 }, - { 0x00, 0x01, 0, 0x03, 0x0004, 0x000a }, - { 0x00, 0x01, 0, 0x03, 0x0004, 0x000c }, - { 0x00, 0x02, 0, 0x03, 0x0004, 0x000e }, - { 0x00, 0x02, 0, 0x03, 0x0004, 0x0012 }, - { 0x00, 0x03, 0, 0x03, 0x0004, 0x0016 }, - { 0x00, 0x03, 0, 0x03, 0x0004, 0x001e }, - { 0x00, 0x04, 0, 0x03, 0x0004, 0x0026 }, - { 0x00, 0x04, 0, 0x03, 0x0004, 0x0036 }, - { 0x00, 0x01, 0, 0x03, 0x0005, 0x000a }, - { 0x00, 0x01, 0, 0x03, 0x0005, 0x000c }, - { 0x00, 0x02, 0, 0x03, 0x0005, 0x000e }, - { 0x00, 0x02, 0, 0x03, 0x0005, 0x0012 }, - { 0x00, 0x03, 0, 0x03, 0x0005, 0x0016 }, - { 0x00, 0x03, 0, 0x03, 0x0005, 0x001e }, - { 0x00, 0x04, 0, 0x03, 0x0005, 0x0026 }, - { 0x00, 0x04, 0, 0x03, 0x0005, 0x0036 }, - { 0x01, 0x01, 0, 0x03, 0x0006, 0x000a }, - { 0x01, 0x01, 0, 0x03, 0x0006, 0x000c }, - { 0x01, 0x02, 0, 0x03, 0x0006, 0x000e }, - { 0x01, 0x02, 0, 0x03, 0x0006, 0x0012 }, - { 0x01, 0x03, 0, 0x03, 0x0006, 0x0016 }, - { 0x01, 0x03, 0, 0x03, 0x0006, 0x001e }, - { 0x01, 0x04, 0, 0x03, 0x0006, 0x0026 }, - { 0x01, 0x04, 0, 0x03, 0x0006, 0x0036 }, - { 0x01, 0x01, 0, 0x03, 0x0008, 0x000a }, - { 0x01, 0x01, 0, 0x03, 0x0008, 0x000c }, - { 0x01, 0x02, 0, 0x03, 0x0008, 0x000e }, - { 0x01, 0x02, 0, 0x03, 0x0008, 0x0012 }, - { 0x01, 0x03, 0, 0x03, 0x0008, 0x0016 }, - { 0x01, 0x03, 0, 0x03, 0x0008, 0x001e }, - { 0x01, 0x04, 0, 0x03, 0x0008, 0x0026 }, - { 0x01, 0x04, 0, 0x03, 0x0008, 0x0036 }, - { 0x00, 0x00, -1, 0x00, 0x0000, 0x0002 }, - { 0x00, 0x00, -1, 0x01, 0x0000, 0x0003 }, - { 0x00, 0x00, -1, 0x02, 0x0000, 0x0004 }, - { 0x00, 0x00, -1, 0x03, 0x0000, 0x0005 }, - { 0x00, 0x00, -1, 0x03, 0x0000, 0x0006 }, - { 0x00, 0x00, -1, 0x03, 0x0000, 0x0007 }, - { 0x00, 0x00, -1, 0x03, 0x0000, 0x0008 }, - { 0x00, 0x00, -1, 0x03, 0x0000, 0x0009 }, - { 0x00, 0x00, -1, 0x00, 0x0001, 0x0002 }, - { 0x00, 0x00, -1, 0x01, 0x0001, 0x0003 }, - { 0x00, 0x00, -1, 0x02, 0x0001, 0x0004 }, - { 0x00, 0x00, -1, 0x03, 0x0001, 0x0005 }, - { 0x00, 0x00, -1, 0x03, 0x0001, 0x0006 }, - { 0x00, 0x00, -1, 0x03, 0x0001, 0x0007 }, - { 0x00, 0x00, -1, 0x03, 0x0001, 0x0008 }, - { 0x00, 0x00, -1, 0x03, 0x0001, 0x0009 }, - { 0x00, 0x00, -1, 0x00, 0x0002, 0x0002 }, - { 0x00, 0x00, -1, 0x01, 0x0002, 0x0003 }, - { 0x00, 0x00, -1, 0x02, 0x0002, 0x0004 }, - { 0x00, 0x00, -1, 0x03, 0x0002, 0x0005 }, - { 0x00, 0x00, -1, 0x03, 0x0002, 0x0006 }, - { 0x00, 0x00, -1, 0x03, 0x0002, 0x0007 }, - { 0x00, 0x00, -1, 0x03, 0x0002, 0x0008 }, - { 0x00, 0x00, -1, 0x03, 0x0002, 0x0009 }, - { 0x00, 0x00, -1, 0x00, 0x0003, 0x0002 }, - { 0x00, 0x00, -1, 0x01, 0x0003, 0x0003 }, - { 0x00, 0x00, -1, 0x02, 0x0003, 0x0004 }, - { 0x00, 0x00, -1, 0x03, 0x0003, 0x0005 }, - { 0x00, 0x00, -1, 0x03, 0x0003, 0x0006 }, - { 0x00, 0x00, -1, 0x03, 0x0003, 0x0007 }, - { 0x00, 0x00, -1, 0x03, 0x0003, 0x0008 }, - { 0x00, 0x00, -1, 0x03, 0x0003, 0x0009 }, - { 0x00, 0x00, -1, 0x00, 0x0004, 0x0002 }, - { 0x00, 0x00, -1, 0x01, 0x0004, 0x0003 }, - { 0x00, 0x00, -1, 0x02, 0x0004, 0x0004 }, - { 0x00, 0x00, -1, 0x03, 0x0004, 0x0005 }, - { 0x00, 0x00, -1, 0x03, 0x0004, 0x0006 }, - { 0x00, 0x00, -1, 0x03, 0x0004, 0x0007 }, - { 0x00, 0x00, -1, 0x03, 0x0004, 0x0008 }, - { 0x00, 0x00, -1, 0x03, 0x0004, 0x0009 }, - { 0x00, 0x00, -1, 0x00, 0x0005, 0x0002 }, - { 0x00, 0x00, -1, 0x01, 0x0005, 0x0003 }, - { 0x00, 0x00, -1, 0x02, 0x0005, 0x0004 }, - { 0x00, 0x00, -1, 0x03, 0x0005, 0x0005 }, - { 0x00, 0x00, -1, 0x03, 0x0005, 0x0006 }, - { 0x00, 0x00, -1, 0x03, 0x0005, 0x0007 }, - { 0x00, 0x00, -1, 0x03, 0x0005, 0x0008 }, - { 0x00, 0x00, -1, 0x03, 0x0005, 0x0009 }, - { 0x01, 0x00, -1, 0x00, 0x0006, 0x0002 }, - { 0x01, 0x00, -1, 0x01, 0x0006, 0x0003 }, - { 0x01, 0x00, -1, 0x02, 0x0006, 0x0004 }, - { 0x01, 0x00, -1, 0x03, 0x0006, 0x0005 }, - { 0x01, 0x00, -1, 0x03, 0x0006, 0x0006 }, - { 0x01, 0x00, -1, 0x03, 0x0006, 0x0007 }, - { 0x01, 0x00, -1, 0x03, 0x0006, 0x0008 }, - { 0x01, 0x00, -1, 0x03, 0x0006, 0x0009 }, - { 0x01, 0x00, -1, 0x00, 0x0008, 0x0002 }, - { 0x01, 0x00, -1, 0x01, 0x0008, 0x0003 }, - { 0x01, 0x00, -1, 0x02, 0x0008, 0x0004 }, - { 0x01, 0x00, -1, 0x03, 0x0008, 0x0005 }, - { 0x01, 0x00, -1, 0x03, 0x0008, 0x0006 }, - { 0x01, 0x00, -1, 0x03, 0x0008, 0x0007 }, - { 0x01, 0x00, -1, 0x03, 0x0008, 0x0008 }, - { 0x01, 0x00, -1, 0x03, 0x0008, 0x0009 }, - { 0x00, 0x01, -1, 0x03, 0x0000, 0x000a }, - { 0x00, 0x01, -1, 0x03, 0x0000, 0x000c }, - { 0x00, 0x02, -1, 0x03, 0x0000, 0x000e }, - { 0x00, 0x02, -1, 0x03, 0x0000, 0x0012 }, - { 0x00, 0x03, -1, 0x03, 0x0000, 0x0016 }, - { 0x00, 0x03, -1, 0x03, 0x0000, 0x001e }, - { 0x00, 0x04, -1, 0x03, 0x0000, 0x0026 }, - { 0x00, 0x04, -1, 0x03, 0x0000, 0x0036 }, - { 0x00, 0x01, -1, 0x03, 0x0001, 0x000a }, - { 0x00, 0x01, -1, 0x03, 0x0001, 0x000c }, - { 0x00, 0x02, -1, 0x03, 0x0001, 0x000e }, - { 0x00, 0x02, -1, 0x03, 0x0001, 0x0012 }, - { 0x00, 0x03, -1, 0x03, 0x0001, 0x0016 }, - { 0x00, 0x03, -1, 0x03, 0x0001, 0x001e }, - { 0x00, 0x04, -1, 0x03, 0x0001, 0x0026 }, - { 0x00, 0x04, -1, 0x03, 0x0001, 0x0036 }, - { 0x00, 0x01, -1, 0x03, 0x0002, 0x000a }, - { 0x00, 0x01, -1, 0x03, 0x0002, 0x000c }, - { 0x00, 0x02, -1, 0x03, 0x0002, 0x000e }, - { 0x00, 0x02, -1, 0x03, 0x0002, 0x0012 }, - { 0x00, 0x03, -1, 0x03, 0x0002, 0x0016 }, - { 0x00, 0x03, -1, 0x03, 0x0002, 0x001e }, - { 0x00, 0x04, -1, 0x03, 0x0002, 0x0026 }, - { 0x00, 0x04, -1, 0x03, 0x0002, 0x0036 }, - { 0x00, 0x01, -1, 0x03, 0x0003, 0x000a }, - { 0x00, 0x01, -1, 0x03, 0x0003, 0x000c }, - { 0x00, 0x02, -1, 0x03, 0x0003, 0x000e }, - { 0x00, 0x02, -1, 0x03, 0x0003, 0x0012 }, - { 0x00, 0x03, -1, 0x03, 0x0003, 0x0016 }, - { 0x00, 0x03, -1, 0x03, 0x0003, 0x001e }, - { 0x00, 0x04, -1, 0x03, 0x0003, 0x0026 }, - { 0x00, 0x04, -1, 0x03, 0x0003, 0x0036 }, - { 0x00, 0x01, -1, 0x03, 0x0004, 0x000a }, - { 0x00, 0x01, -1, 0x03, 0x0004, 0x000c }, - { 0x00, 0x02, -1, 0x03, 0x0004, 0x000e }, - { 0x00, 0x02, -1, 0x03, 0x0004, 0x0012 }, - { 0x00, 0x03, -1, 0x03, 0x0004, 0x0016 }, - { 0x00, 0x03, -1, 0x03, 0x0004, 0x001e }, - { 0x00, 0x04, -1, 0x03, 0x0004, 0x0026 }, - { 0x00, 0x04, -1, 0x03, 0x0004, 0x0036 }, - { 0x00, 0x01, -1, 0x03, 0x0005, 0x000a }, - { 0x00, 0x01, -1, 0x03, 0x0005, 0x000c }, - { 0x00, 0x02, -1, 0x03, 0x0005, 0x000e }, - { 0x00, 0x02, -1, 0x03, 0x0005, 0x0012 }, - { 0x00, 0x03, -1, 0x03, 0x0005, 0x0016 }, - { 0x00, 0x03, -1, 0x03, 0x0005, 0x001e }, - { 0x00, 0x04, -1, 0x03, 0x0005, 0x0026 }, - { 0x00, 0x04, -1, 0x03, 0x0005, 0x0036 }, - { 0x01, 0x01, -1, 0x03, 0x0006, 0x000a }, - { 0x01, 0x01, -1, 0x03, 0x0006, 0x000c }, - { 0x01, 0x02, -1, 0x03, 0x0006, 0x000e }, - { 0x01, 0x02, -1, 0x03, 0x0006, 0x0012 }, - { 0x01, 0x03, -1, 0x03, 0x0006, 0x0016 }, - { 0x01, 0x03, -1, 0x03, 0x0006, 0x001e }, - { 0x01, 0x04, -1, 0x03, 0x0006, 0x0026 }, - { 0x01, 0x04, -1, 0x03, 0x0006, 0x0036 }, - { 0x01, 0x01, -1, 0x03, 0x0008, 0x000a }, - { 0x01, 0x01, -1, 0x03, 0x0008, 0x000c }, - { 0x01, 0x02, -1, 0x03, 0x0008, 0x000e }, - { 0x01, 0x02, -1, 0x03, 0x0008, 0x0012 }, - { 0x01, 0x03, -1, 0x03, 0x0008, 0x0016 }, - { 0x01, 0x03, -1, 0x03, 0x0008, 0x001e }, - { 0x01, 0x04, -1, 0x03, 0x0008, 0x0026 }, - { 0x01, 0x04, -1, 0x03, 0x0008, 0x0036 }, - { 0x02, 0x00, -1, 0x00, 0x000a, 0x0002 }, - { 0x02, 0x00, -1, 0x01, 0x000a, 0x0003 }, - { 0x02, 0x00, -1, 0x02, 0x000a, 0x0004 }, - { 0x02, 0x00, -1, 0x03, 0x000a, 0x0005 }, - { 0x02, 0x00, -1, 0x03, 0x000a, 0x0006 }, - { 0x02, 0x00, -1, 0x03, 0x000a, 0x0007 }, - { 0x02, 0x00, -1, 0x03, 0x000a, 0x0008 }, - { 0x02, 0x00, -1, 0x03, 0x000a, 0x0009 }, - { 0x02, 0x00, -1, 0x00, 0x000e, 0x0002 }, - { 0x02, 0x00, -1, 0x01, 0x000e, 0x0003 }, - { 0x02, 0x00, -1, 0x02, 0x000e, 0x0004 }, - { 0x02, 0x00, -1, 0x03, 0x000e, 0x0005 }, - { 0x02, 0x00, -1, 0x03, 0x000e, 0x0006 }, - { 0x02, 0x00, -1, 0x03, 0x000e, 0x0007 }, - { 0x02, 0x00, -1, 0x03, 0x000e, 0x0008 }, - { 0x02, 0x00, -1, 0x03, 0x000e, 0x0009 }, - { 0x03, 0x00, -1, 0x00, 0x0012, 0x0002 }, - { 0x03, 0x00, -1, 0x01, 0x0012, 0x0003 }, - { 0x03, 0x00, -1, 0x02, 0x0012, 0x0004 }, - { 0x03, 0x00, -1, 0x03, 0x0012, 0x0005 }, - { 0x03, 0x00, -1, 0x03, 0x0012, 0x0006 }, - { 0x03, 0x00, -1, 0x03, 0x0012, 0x0007 }, - { 0x03, 0x00, -1, 0x03, 0x0012, 0x0008 }, - { 0x03, 0x00, -1, 0x03, 0x0012, 0x0009 }, - { 0x03, 0x00, -1, 0x00, 0x001a, 0x0002 }, - { 0x03, 0x00, -1, 0x01, 0x001a, 0x0003 }, - { 0x03, 0x00, -1, 0x02, 0x001a, 0x0004 }, - { 0x03, 0x00, -1, 0x03, 0x001a, 0x0005 }, - { 0x03, 0x00, -1, 0x03, 0x001a, 0x0006 }, - { 0x03, 0x00, -1, 0x03, 0x001a, 0x0007 }, - { 0x03, 0x00, -1, 0x03, 0x001a, 0x0008 }, - { 0x03, 0x00, -1, 0x03, 0x001a, 0x0009 }, - { 0x04, 0x00, -1, 0x00, 0x0022, 0x0002 }, - { 0x04, 0x00, -1, 0x01, 0x0022, 0x0003 }, - { 0x04, 0x00, -1, 0x02, 0x0022, 0x0004 }, - { 0x04, 0x00, -1, 0x03, 0x0022, 0x0005 }, - { 0x04, 0x00, -1, 0x03, 0x0022, 0x0006 }, - { 0x04, 0x00, -1, 0x03, 0x0022, 0x0007 }, - { 0x04, 0x00, -1, 0x03, 0x0022, 0x0008 }, - { 0x04, 0x00, -1, 0x03, 0x0022, 0x0009 }, - { 0x04, 0x00, -1, 0x00, 0x0032, 0x0002 }, - { 0x04, 0x00, -1, 0x01, 0x0032, 0x0003 }, - { 0x04, 0x00, -1, 0x02, 0x0032, 0x0004 }, - { 0x04, 0x00, -1, 0x03, 0x0032, 0x0005 }, - { 0x04, 0x00, -1, 0x03, 0x0032, 0x0006 }, - { 0x04, 0x00, -1, 0x03, 0x0032, 0x0007 }, - { 0x04, 0x00, -1, 0x03, 0x0032, 0x0008 }, - { 0x04, 0x00, -1, 0x03, 0x0032, 0x0009 }, - { 0x05, 0x00, -1, 0x00, 0x0042, 0x0002 }, - { 0x05, 0x00, -1, 0x01, 0x0042, 0x0003 }, - { 0x05, 0x00, -1, 0x02, 0x0042, 0x0004 }, - { 0x05, 0x00, -1, 0x03, 0x0042, 0x0005 }, - { 0x05, 0x00, -1, 0x03, 0x0042, 0x0006 }, - { 0x05, 0x00, -1, 0x03, 0x0042, 0x0007 }, - { 0x05, 0x00, -1, 0x03, 0x0042, 0x0008 }, - { 0x05, 0x00, -1, 0x03, 0x0042, 0x0009 }, - { 0x05, 0x00, -1, 0x00, 0x0062, 0x0002 }, - { 0x05, 0x00, -1, 0x01, 0x0062, 0x0003 }, - { 0x05, 0x00, -1, 0x02, 0x0062, 0x0004 }, - { 0x05, 0x00, -1, 0x03, 0x0062, 0x0005 }, - { 0x05, 0x00, -1, 0x03, 0x0062, 0x0006 }, - { 0x05, 0x00, -1, 0x03, 0x0062, 0x0007 }, - { 0x05, 0x00, -1, 0x03, 0x0062, 0x0008 }, - { 0x05, 0x00, -1, 0x03, 0x0062, 0x0009 }, - { 0x02, 0x01, -1, 0x03, 0x000a, 0x000a }, - { 0x02, 0x01, -1, 0x03, 0x000a, 0x000c }, - { 0x02, 0x02, -1, 0x03, 0x000a, 0x000e }, - { 0x02, 0x02, -1, 0x03, 0x000a, 0x0012 }, - { 0x02, 0x03, -1, 0x03, 0x000a, 0x0016 }, - { 0x02, 0x03, -1, 0x03, 0x000a, 0x001e }, - { 0x02, 0x04, -1, 0x03, 0x000a, 0x0026 }, - { 0x02, 0x04, -1, 0x03, 0x000a, 0x0036 }, - { 0x02, 0x01, -1, 0x03, 0x000e, 0x000a }, - { 0x02, 0x01, -1, 0x03, 0x000e, 0x000c }, - { 0x02, 0x02, -1, 0x03, 0x000e, 0x000e }, - { 0x02, 0x02, -1, 0x03, 0x000e, 0x0012 }, - { 0x02, 0x03, -1, 0x03, 0x000e, 0x0016 }, - { 0x02, 0x03, -1, 0x03, 0x000e, 0x001e }, - { 0x02, 0x04, -1, 0x03, 0x000e, 0x0026 }, - { 0x02, 0x04, -1, 0x03, 0x000e, 0x0036 }, - { 0x03, 0x01, -1, 0x03, 0x0012, 0x000a }, - { 0x03, 0x01, -1, 0x03, 0x0012, 0x000c }, - { 0x03, 0x02, -1, 0x03, 0x0012, 0x000e }, - { 0x03, 0x02, -1, 0x03, 0x0012, 0x0012 }, - { 0x03, 0x03, -1, 0x03, 0x0012, 0x0016 }, - { 0x03, 0x03, -1, 0x03, 0x0012, 0x001e }, - { 0x03, 0x04, -1, 0x03, 0x0012, 0x0026 }, - { 0x03, 0x04, -1, 0x03, 0x0012, 0x0036 }, - { 0x03, 0x01, -1, 0x03, 0x001a, 0x000a }, - { 0x03, 0x01, -1, 0x03, 0x001a, 0x000c }, - { 0x03, 0x02, -1, 0x03, 0x001a, 0x000e }, - { 0x03, 0x02, -1, 0x03, 0x001a, 0x0012 }, - { 0x03, 0x03, -1, 0x03, 0x001a, 0x0016 }, - { 0x03, 0x03, -1, 0x03, 0x001a, 0x001e }, - { 0x03, 0x04, -1, 0x03, 0x001a, 0x0026 }, - { 0x03, 0x04, -1, 0x03, 0x001a, 0x0036 }, - { 0x04, 0x01, -1, 0x03, 0x0022, 0x000a }, - { 0x04, 0x01, -1, 0x03, 0x0022, 0x000c }, - { 0x04, 0x02, -1, 0x03, 0x0022, 0x000e }, - { 0x04, 0x02, -1, 0x03, 0x0022, 0x0012 }, - { 0x04, 0x03, -1, 0x03, 0x0022, 0x0016 }, - { 0x04, 0x03, -1, 0x03, 0x0022, 0x001e }, - { 0x04, 0x04, -1, 0x03, 0x0022, 0x0026 }, - { 0x04, 0x04, -1, 0x03, 0x0022, 0x0036 }, - { 0x04, 0x01, -1, 0x03, 0x0032, 0x000a }, - { 0x04, 0x01, -1, 0x03, 0x0032, 0x000c }, - { 0x04, 0x02, -1, 0x03, 0x0032, 0x000e }, - { 0x04, 0x02, -1, 0x03, 0x0032, 0x0012 }, - { 0x04, 0x03, -1, 0x03, 0x0032, 0x0016 }, - { 0x04, 0x03, -1, 0x03, 0x0032, 0x001e }, - { 0x04, 0x04, -1, 0x03, 0x0032, 0x0026 }, - { 0x04, 0x04, -1, 0x03, 0x0032, 0x0036 }, - { 0x05, 0x01, -1, 0x03, 0x0042, 0x000a }, - { 0x05, 0x01, -1, 0x03, 0x0042, 0x000c }, - { 0x05, 0x02, -1, 0x03, 0x0042, 0x000e }, - { 0x05, 0x02, -1, 0x03, 0x0042, 0x0012 }, - { 0x05, 0x03, -1, 0x03, 0x0042, 0x0016 }, - { 0x05, 0x03, -1, 0x03, 0x0042, 0x001e }, - { 0x05, 0x04, -1, 0x03, 0x0042, 0x0026 }, - { 0x05, 0x04, -1, 0x03, 0x0042, 0x0036 }, - { 0x05, 0x01, -1, 0x03, 0x0062, 0x000a }, - { 0x05, 0x01, -1, 0x03, 0x0062, 0x000c }, - { 0x05, 0x02, -1, 0x03, 0x0062, 0x000e }, - { 0x05, 0x02, -1, 0x03, 0x0062, 0x0012 }, - { 0x05, 0x03, -1, 0x03, 0x0062, 0x0016 }, - { 0x05, 0x03, -1, 0x03, 0x0062, 0x001e }, - { 0x05, 0x04, -1, 0x03, 0x0062, 0x0026 }, - { 0x05, 0x04, -1, 0x03, 0x0062, 0x0036 }, - { 0x00, 0x05, -1, 0x03, 0x0000, 0x0046 }, - { 0x00, 0x05, -1, 0x03, 0x0000, 0x0066 }, - { 0x00, 0x06, -1, 0x03, 0x0000, 0x0086 }, - { 0x00, 0x07, -1, 0x03, 0x0000, 0x00c6 }, - { 0x00, 0x08, -1, 0x03, 0x0000, 0x0146 }, - { 0x00, 0x09, -1, 0x03, 0x0000, 0x0246 }, - { 0x00, 0x0a, -1, 0x03, 0x0000, 0x0446 }, - { 0x00, 0x18, -1, 0x03, 0x0000, 0x0846 }, - { 0x00, 0x05, -1, 0x03, 0x0001, 0x0046 }, - { 0x00, 0x05, -1, 0x03, 0x0001, 0x0066 }, - { 0x00, 0x06, -1, 0x03, 0x0001, 0x0086 }, - { 0x00, 0x07, -1, 0x03, 0x0001, 0x00c6 }, - { 0x00, 0x08, -1, 0x03, 0x0001, 0x0146 }, - { 0x00, 0x09, -1, 0x03, 0x0001, 0x0246 }, - { 0x00, 0x0a, -1, 0x03, 0x0001, 0x0446 }, - { 0x00, 0x18, -1, 0x03, 0x0001, 0x0846 }, - { 0x00, 0x05, -1, 0x03, 0x0002, 0x0046 }, - { 0x00, 0x05, -1, 0x03, 0x0002, 0x0066 }, - { 0x00, 0x06, -1, 0x03, 0x0002, 0x0086 }, - { 0x00, 0x07, -1, 0x03, 0x0002, 0x00c6 }, - { 0x00, 0x08, -1, 0x03, 0x0002, 0x0146 }, - { 0x00, 0x09, -1, 0x03, 0x0002, 0x0246 }, - { 0x00, 0x0a, -1, 0x03, 0x0002, 0x0446 }, - { 0x00, 0x18, -1, 0x03, 0x0002, 0x0846 }, - { 0x00, 0x05, -1, 0x03, 0x0003, 0x0046 }, - { 0x00, 0x05, -1, 0x03, 0x0003, 0x0066 }, - { 0x00, 0x06, -1, 0x03, 0x0003, 0x0086 }, - { 0x00, 0x07, -1, 0x03, 0x0003, 0x00c6 }, - { 0x00, 0x08, -1, 0x03, 0x0003, 0x0146 }, - { 0x00, 0x09, -1, 0x03, 0x0003, 0x0246 }, - { 0x00, 0x0a, -1, 0x03, 0x0003, 0x0446 }, - { 0x00, 0x18, -1, 0x03, 0x0003, 0x0846 }, - { 0x00, 0x05, -1, 0x03, 0x0004, 0x0046 }, - { 0x00, 0x05, -1, 0x03, 0x0004, 0x0066 }, - { 0x00, 0x06, -1, 0x03, 0x0004, 0x0086 }, - { 0x00, 0x07, -1, 0x03, 0x0004, 0x00c6 }, - { 0x00, 0x08, -1, 0x03, 0x0004, 0x0146 }, - { 0x00, 0x09, -1, 0x03, 0x0004, 0x0246 }, - { 0x00, 0x0a, -1, 0x03, 0x0004, 0x0446 }, - { 0x00, 0x18, -1, 0x03, 0x0004, 0x0846 }, - { 0x00, 0x05, -1, 0x03, 0x0005, 0x0046 }, - { 0x00, 0x05, -1, 0x03, 0x0005, 0x0066 }, - { 0x00, 0x06, -1, 0x03, 0x0005, 0x0086 }, - { 0x00, 0x07, -1, 0x03, 0x0005, 0x00c6 }, - { 0x00, 0x08, -1, 0x03, 0x0005, 0x0146 }, - { 0x00, 0x09, -1, 0x03, 0x0005, 0x0246 }, - { 0x00, 0x0a, -1, 0x03, 0x0005, 0x0446 }, - { 0x00, 0x18, -1, 0x03, 0x0005, 0x0846 }, - { 0x01, 0x05, -1, 0x03, 0x0006, 0x0046 }, - { 0x01, 0x05, -1, 0x03, 0x0006, 0x0066 }, - { 0x01, 0x06, -1, 0x03, 0x0006, 0x0086 }, - { 0x01, 0x07, -1, 0x03, 0x0006, 0x00c6 }, - { 0x01, 0x08, -1, 0x03, 0x0006, 0x0146 }, - { 0x01, 0x09, -1, 0x03, 0x0006, 0x0246 }, - { 0x01, 0x0a, -1, 0x03, 0x0006, 0x0446 }, - { 0x01, 0x18, -1, 0x03, 0x0006, 0x0846 }, - { 0x01, 0x05, -1, 0x03, 0x0008, 0x0046 }, - { 0x01, 0x05, -1, 0x03, 0x0008, 0x0066 }, - { 0x01, 0x06, -1, 0x03, 0x0008, 0x0086 }, - { 0x01, 0x07, -1, 0x03, 0x0008, 0x00c6 }, - { 0x01, 0x08, -1, 0x03, 0x0008, 0x0146 }, - { 0x01, 0x09, -1, 0x03, 0x0008, 0x0246 }, - { 0x01, 0x0a, -1, 0x03, 0x0008, 0x0446 }, - { 0x01, 0x18, -1, 0x03, 0x0008, 0x0846 }, - { 0x06, 0x00, -1, 0x00, 0x0082, 0x0002 }, - { 0x06, 0x00, -1, 0x01, 0x0082, 0x0003 }, - { 0x06, 0x00, -1, 0x02, 0x0082, 0x0004 }, - { 0x06, 0x00, -1, 0x03, 0x0082, 0x0005 }, - { 0x06, 0x00, -1, 0x03, 0x0082, 0x0006 }, - { 0x06, 0x00, -1, 0x03, 0x0082, 0x0007 }, - { 0x06, 0x00, -1, 0x03, 0x0082, 0x0008 }, - { 0x06, 0x00, -1, 0x03, 0x0082, 0x0009 }, - { 0x07, 0x00, -1, 0x00, 0x00c2, 0x0002 }, - { 0x07, 0x00, -1, 0x01, 0x00c2, 0x0003 }, - { 0x07, 0x00, -1, 0x02, 0x00c2, 0x0004 }, - { 0x07, 0x00, -1, 0x03, 0x00c2, 0x0005 }, - { 0x07, 0x00, -1, 0x03, 0x00c2, 0x0006 }, - { 0x07, 0x00, -1, 0x03, 0x00c2, 0x0007 }, - { 0x07, 0x00, -1, 0x03, 0x00c2, 0x0008 }, - { 0x07, 0x00, -1, 0x03, 0x00c2, 0x0009 }, - { 0x08, 0x00, -1, 0x00, 0x0142, 0x0002 }, - { 0x08, 0x00, -1, 0x01, 0x0142, 0x0003 }, - { 0x08, 0x00, -1, 0x02, 0x0142, 0x0004 }, - { 0x08, 0x00, -1, 0x03, 0x0142, 0x0005 }, - { 0x08, 0x00, -1, 0x03, 0x0142, 0x0006 }, - { 0x08, 0x00, -1, 0x03, 0x0142, 0x0007 }, - { 0x08, 0x00, -1, 0x03, 0x0142, 0x0008 }, - { 0x08, 0x00, -1, 0x03, 0x0142, 0x0009 }, - { 0x09, 0x00, -1, 0x00, 0x0242, 0x0002 }, - { 0x09, 0x00, -1, 0x01, 0x0242, 0x0003 }, - { 0x09, 0x00, -1, 0x02, 0x0242, 0x0004 }, - { 0x09, 0x00, -1, 0x03, 0x0242, 0x0005 }, - { 0x09, 0x00, -1, 0x03, 0x0242, 0x0006 }, - { 0x09, 0x00, -1, 0x03, 0x0242, 0x0007 }, - { 0x09, 0x00, -1, 0x03, 0x0242, 0x0008 }, - { 0x09, 0x00, -1, 0x03, 0x0242, 0x0009 }, - { 0x0a, 0x00, -1, 0x00, 0x0442, 0x0002 }, - { 0x0a, 0x00, -1, 0x01, 0x0442, 0x0003 }, - { 0x0a, 0x00, -1, 0x02, 0x0442, 0x0004 }, - { 0x0a, 0x00, -1, 0x03, 0x0442, 0x0005 }, - { 0x0a, 0x00, -1, 0x03, 0x0442, 0x0006 }, - { 0x0a, 0x00, -1, 0x03, 0x0442, 0x0007 }, - { 0x0a, 0x00, -1, 0x03, 0x0442, 0x0008 }, - { 0x0a, 0x00, -1, 0x03, 0x0442, 0x0009 }, - { 0x0c, 0x00, -1, 0x00, 0x0842, 0x0002 }, - { 0x0c, 0x00, -1, 0x01, 0x0842, 0x0003 }, - { 0x0c, 0x00, -1, 0x02, 0x0842, 0x0004 }, - { 0x0c, 0x00, -1, 0x03, 0x0842, 0x0005 }, - { 0x0c, 0x00, -1, 0x03, 0x0842, 0x0006 }, - { 0x0c, 0x00, -1, 0x03, 0x0842, 0x0007 }, - { 0x0c, 0x00, -1, 0x03, 0x0842, 0x0008 }, - { 0x0c, 0x00, -1, 0x03, 0x0842, 0x0009 }, - { 0x0e, 0x00, -1, 0x00, 0x1842, 0x0002 }, - { 0x0e, 0x00, -1, 0x01, 0x1842, 0x0003 }, - { 0x0e, 0x00, -1, 0x02, 0x1842, 0x0004 }, - { 0x0e, 0x00, -1, 0x03, 0x1842, 0x0005 }, - { 0x0e, 0x00, -1, 0x03, 0x1842, 0x0006 }, - { 0x0e, 0x00, -1, 0x03, 0x1842, 0x0007 }, - { 0x0e, 0x00, -1, 0x03, 0x1842, 0x0008 }, - { 0x0e, 0x00, -1, 0x03, 0x1842, 0x0009 }, - { 0x18, 0x00, -1, 0x00, 0x5842, 0x0002 }, - { 0x18, 0x00, -1, 0x01, 0x5842, 0x0003 }, - { 0x18, 0x00, -1, 0x02, 0x5842, 0x0004 }, - { 0x18, 0x00, -1, 0x03, 0x5842, 0x0005 }, - { 0x18, 0x00, -1, 0x03, 0x5842, 0x0006 }, - { 0x18, 0x00, -1, 0x03, 0x5842, 0x0007 }, - { 0x18, 0x00, -1, 0x03, 0x5842, 0x0008 }, - { 0x18, 0x00, -1, 0x03, 0x5842, 0x0009 }, - { 0x02, 0x05, -1, 0x03, 0x000a, 0x0046 }, - { 0x02, 0x05, -1, 0x03, 0x000a, 0x0066 }, - { 0x02, 0x06, -1, 0x03, 0x000a, 0x0086 }, - { 0x02, 0x07, -1, 0x03, 0x000a, 0x00c6 }, - { 0x02, 0x08, -1, 0x03, 0x000a, 0x0146 }, - { 0x02, 0x09, -1, 0x03, 0x000a, 0x0246 }, - { 0x02, 0x0a, -1, 0x03, 0x000a, 0x0446 }, - { 0x02, 0x18, -1, 0x03, 0x000a, 0x0846 }, - { 0x02, 0x05, -1, 0x03, 0x000e, 0x0046 }, - { 0x02, 0x05, -1, 0x03, 0x000e, 0x0066 }, - { 0x02, 0x06, -1, 0x03, 0x000e, 0x0086 }, - { 0x02, 0x07, -1, 0x03, 0x000e, 0x00c6 }, - { 0x02, 0x08, -1, 0x03, 0x000e, 0x0146 }, - { 0x02, 0x09, -1, 0x03, 0x000e, 0x0246 }, - { 0x02, 0x0a, -1, 0x03, 0x000e, 0x0446 }, - { 0x02, 0x18, -1, 0x03, 0x000e, 0x0846 }, - { 0x03, 0x05, -1, 0x03, 0x0012, 0x0046 }, - { 0x03, 0x05, -1, 0x03, 0x0012, 0x0066 }, - { 0x03, 0x06, -1, 0x03, 0x0012, 0x0086 }, - { 0x03, 0x07, -1, 0x03, 0x0012, 0x00c6 }, - { 0x03, 0x08, -1, 0x03, 0x0012, 0x0146 }, - { 0x03, 0x09, -1, 0x03, 0x0012, 0x0246 }, - { 0x03, 0x0a, -1, 0x03, 0x0012, 0x0446 }, - { 0x03, 0x18, -1, 0x03, 0x0012, 0x0846 }, - { 0x03, 0x05, -1, 0x03, 0x001a, 0x0046 }, - { 0x03, 0x05, -1, 0x03, 0x001a, 0x0066 }, - { 0x03, 0x06, -1, 0x03, 0x001a, 0x0086 }, - { 0x03, 0x07, -1, 0x03, 0x001a, 0x00c6 }, - { 0x03, 0x08, -1, 0x03, 0x001a, 0x0146 }, - { 0x03, 0x09, -1, 0x03, 0x001a, 0x0246 }, - { 0x03, 0x0a, -1, 0x03, 0x001a, 0x0446 }, - { 0x03, 0x18, -1, 0x03, 0x001a, 0x0846 }, - { 0x04, 0x05, -1, 0x03, 0x0022, 0x0046 }, - { 0x04, 0x05, -1, 0x03, 0x0022, 0x0066 }, - { 0x04, 0x06, -1, 0x03, 0x0022, 0x0086 }, - { 0x04, 0x07, -1, 0x03, 0x0022, 0x00c6 }, - { 0x04, 0x08, -1, 0x03, 0x0022, 0x0146 }, - { 0x04, 0x09, -1, 0x03, 0x0022, 0x0246 }, - { 0x04, 0x0a, -1, 0x03, 0x0022, 0x0446 }, - { 0x04, 0x18, -1, 0x03, 0x0022, 0x0846 }, - { 0x04, 0x05, -1, 0x03, 0x0032, 0x0046 }, - { 0x04, 0x05, -1, 0x03, 0x0032, 0x0066 }, - { 0x04, 0x06, -1, 0x03, 0x0032, 0x0086 }, - { 0x04, 0x07, -1, 0x03, 0x0032, 0x00c6 }, - { 0x04, 0x08, -1, 0x03, 0x0032, 0x0146 }, - { 0x04, 0x09, -1, 0x03, 0x0032, 0x0246 }, - { 0x04, 0x0a, -1, 0x03, 0x0032, 0x0446 }, - { 0x04, 0x18, -1, 0x03, 0x0032, 0x0846 }, - { 0x05, 0x05, -1, 0x03, 0x0042, 0x0046 }, - { 0x05, 0x05, -1, 0x03, 0x0042, 0x0066 }, - { 0x05, 0x06, -1, 0x03, 0x0042, 0x0086 }, - { 0x05, 0x07, -1, 0x03, 0x0042, 0x00c6 }, - { 0x05, 0x08, -1, 0x03, 0x0042, 0x0146 }, - { 0x05, 0x09, -1, 0x03, 0x0042, 0x0246 }, - { 0x05, 0x0a, -1, 0x03, 0x0042, 0x0446 }, - { 0x05, 0x18, -1, 0x03, 0x0042, 0x0846 }, - { 0x05, 0x05, -1, 0x03, 0x0062, 0x0046 }, - { 0x05, 0x05, -1, 0x03, 0x0062, 0x0066 }, - { 0x05, 0x06, -1, 0x03, 0x0062, 0x0086 }, - { 0x05, 0x07, -1, 0x03, 0x0062, 0x00c6 }, - { 0x05, 0x08, -1, 0x03, 0x0062, 0x0146 }, - { 0x05, 0x09, -1, 0x03, 0x0062, 0x0246 }, - { 0x05, 0x0a, -1, 0x03, 0x0062, 0x0446 }, - { 0x05, 0x18, -1, 0x03, 0x0062, 0x0846 }, - { 0x06, 0x01, -1, 0x03, 0x0082, 0x000a }, - { 0x06, 0x01, -1, 0x03, 0x0082, 0x000c }, - { 0x06, 0x02, -1, 0x03, 0x0082, 0x000e }, - { 0x06, 0x02, -1, 0x03, 0x0082, 0x0012 }, - { 0x06, 0x03, -1, 0x03, 0x0082, 0x0016 }, - { 0x06, 0x03, -1, 0x03, 0x0082, 0x001e }, - { 0x06, 0x04, -1, 0x03, 0x0082, 0x0026 }, - { 0x06, 0x04, -1, 0x03, 0x0082, 0x0036 }, - { 0x07, 0x01, -1, 0x03, 0x00c2, 0x000a }, - { 0x07, 0x01, -1, 0x03, 0x00c2, 0x000c }, - { 0x07, 0x02, -1, 0x03, 0x00c2, 0x000e }, - { 0x07, 0x02, -1, 0x03, 0x00c2, 0x0012 }, - { 0x07, 0x03, -1, 0x03, 0x00c2, 0x0016 }, - { 0x07, 0x03, -1, 0x03, 0x00c2, 0x001e }, - { 0x07, 0x04, -1, 0x03, 0x00c2, 0x0026 }, - { 0x07, 0x04, -1, 0x03, 0x00c2, 0x0036 }, - { 0x08, 0x01, -1, 0x03, 0x0142, 0x000a }, - { 0x08, 0x01, -1, 0x03, 0x0142, 0x000c }, - { 0x08, 0x02, -1, 0x03, 0x0142, 0x000e }, - { 0x08, 0x02, -1, 0x03, 0x0142, 0x0012 }, - { 0x08, 0x03, -1, 0x03, 0x0142, 0x0016 }, - { 0x08, 0x03, -1, 0x03, 0x0142, 0x001e }, - { 0x08, 0x04, -1, 0x03, 0x0142, 0x0026 }, - { 0x08, 0x04, -1, 0x03, 0x0142, 0x0036 }, - { 0x09, 0x01, -1, 0x03, 0x0242, 0x000a }, - { 0x09, 0x01, -1, 0x03, 0x0242, 0x000c }, - { 0x09, 0x02, -1, 0x03, 0x0242, 0x000e }, - { 0x09, 0x02, -1, 0x03, 0x0242, 0x0012 }, - { 0x09, 0x03, -1, 0x03, 0x0242, 0x0016 }, - { 0x09, 0x03, -1, 0x03, 0x0242, 0x001e }, - { 0x09, 0x04, -1, 0x03, 0x0242, 0x0026 }, - { 0x09, 0x04, -1, 0x03, 0x0242, 0x0036 }, - { 0x0a, 0x01, -1, 0x03, 0x0442, 0x000a }, - { 0x0a, 0x01, -1, 0x03, 0x0442, 0x000c }, - { 0x0a, 0x02, -1, 0x03, 0x0442, 0x000e }, - { 0x0a, 0x02, -1, 0x03, 0x0442, 0x0012 }, - { 0x0a, 0x03, -1, 0x03, 0x0442, 0x0016 }, - { 0x0a, 0x03, -1, 0x03, 0x0442, 0x001e }, - { 0x0a, 0x04, -1, 0x03, 0x0442, 0x0026 }, - { 0x0a, 0x04, -1, 0x03, 0x0442, 0x0036 }, - { 0x0c, 0x01, -1, 0x03, 0x0842, 0x000a }, - { 0x0c, 0x01, -1, 0x03, 0x0842, 0x000c }, - { 0x0c, 0x02, -1, 0x03, 0x0842, 0x000e }, - { 0x0c, 0x02, -1, 0x03, 0x0842, 0x0012 }, - { 0x0c, 0x03, -1, 0x03, 0x0842, 0x0016 }, - { 0x0c, 0x03, -1, 0x03, 0x0842, 0x001e }, - { 0x0c, 0x04, -1, 0x03, 0x0842, 0x0026 }, - { 0x0c, 0x04, -1, 0x03, 0x0842, 0x0036 }, - { 0x0e, 0x01, -1, 0x03, 0x1842, 0x000a }, - { 0x0e, 0x01, -1, 0x03, 0x1842, 0x000c }, - { 0x0e, 0x02, -1, 0x03, 0x1842, 0x000e }, - { 0x0e, 0x02, -1, 0x03, 0x1842, 0x0012 }, - { 0x0e, 0x03, -1, 0x03, 0x1842, 0x0016 }, - { 0x0e, 0x03, -1, 0x03, 0x1842, 0x001e }, - { 0x0e, 0x04, -1, 0x03, 0x1842, 0x0026 }, - { 0x0e, 0x04, -1, 0x03, 0x1842, 0x0036 }, - { 0x18, 0x01, -1, 0x03, 0x5842, 0x000a }, - { 0x18, 0x01, -1, 0x03, 0x5842, 0x000c }, - { 0x18, 0x02, -1, 0x03, 0x5842, 0x000e }, - { 0x18, 0x02, -1, 0x03, 0x5842, 0x0012 }, - { 0x18, 0x03, -1, 0x03, 0x5842, 0x0016 }, - { 0x18, 0x03, -1, 0x03, 0x5842, 0x001e }, - { 0x18, 0x04, -1, 0x03, 0x5842, 0x0026 }, - { 0x18, 0x04, -1, 0x03, 0x5842, 0x0036 }, - { 0x06, 0x05, -1, 0x03, 0x0082, 0x0046 }, - { 0x06, 0x05, -1, 0x03, 0x0082, 0x0066 }, - { 0x06, 0x06, -1, 0x03, 0x0082, 0x0086 }, - { 0x06, 0x07, -1, 0x03, 0x0082, 0x00c6 }, - { 0x06, 0x08, -1, 0x03, 0x0082, 0x0146 }, - { 0x06, 0x09, -1, 0x03, 0x0082, 0x0246 }, - { 0x06, 0x0a, -1, 0x03, 0x0082, 0x0446 }, - { 0x06, 0x18, -1, 0x03, 0x0082, 0x0846 }, - { 0x07, 0x05, -1, 0x03, 0x00c2, 0x0046 }, - { 0x07, 0x05, -1, 0x03, 0x00c2, 0x0066 }, - { 0x07, 0x06, -1, 0x03, 0x00c2, 0x0086 }, - { 0x07, 0x07, -1, 0x03, 0x00c2, 0x00c6 }, - { 0x07, 0x08, -1, 0x03, 0x00c2, 0x0146 }, - { 0x07, 0x09, -1, 0x03, 0x00c2, 0x0246 }, - { 0x07, 0x0a, -1, 0x03, 0x00c2, 0x0446 }, - { 0x07, 0x18, -1, 0x03, 0x00c2, 0x0846 }, - { 0x08, 0x05, -1, 0x03, 0x0142, 0x0046 }, - { 0x08, 0x05, -1, 0x03, 0x0142, 0x0066 }, - { 0x08, 0x06, -1, 0x03, 0x0142, 0x0086 }, - { 0x08, 0x07, -1, 0x03, 0x0142, 0x00c6 }, - { 0x08, 0x08, -1, 0x03, 0x0142, 0x0146 }, - { 0x08, 0x09, -1, 0x03, 0x0142, 0x0246 }, - { 0x08, 0x0a, -1, 0x03, 0x0142, 0x0446 }, - { 0x08, 0x18, -1, 0x03, 0x0142, 0x0846 }, - { 0x09, 0x05, -1, 0x03, 0x0242, 0x0046 }, - { 0x09, 0x05, -1, 0x03, 0x0242, 0x0066 }, - { 0x09, 0x06, -1, 0x03, 0x0242, 0x0086 }, - { 0x09, 0x07, -1, 0x03, 0x0242, 0x00c6 }, - { 0x09, 0x08, -1, 0x03, 0x0242, 0x0146 }, - { 0x09, 0x09, -1, 0x03, 0x0242, 0x0246 }, - { 0x09, 0x0a, -1, 0x03, 0x0242, 0x0446 }, - { 0x09, 0x18, -1, 0x03, 0x0242, 0x0846 }, - { 0x0a, 0x05, -1, 0x03, 0x0442, 0x0046 }, - { 0x0a, 0x05, -1, 0x03, 0x0442, 0x0066 }, - { 0x0a, 0x06, -1, 0x03, 0x0442, 0x0086 }, - { 0x0a, 0x07, -1, 0x03, 0x0442, 0x00c6 }, - { 0x0a, 0x08, -1, 0x03, 0x0442, 0x0146 }, - { 0x0a, 0x09, -1, 0x03, 0x0442, 0x0246 }, - { 0x0a, 0x0a, -1, 0x03, 0x0442, 0x0446 }, - { 0x0a, 0x18, -1, 0x03, 0x0442, 0x0846 }, - { 0x0c, 0x05, -1, 0x03, 0x0842, 0x0046 }, - { 0x0c, 0x05, -1, 0x03, 0x0842, 0x0066 }, - { 0x0c, 0x06, -1, 0x03, 0x0842, 0x0086 }, - { 0x0c, 0x07, -1, 0x03, 0x0842, 0x00c6 }, - { 0x0c, 0x08, -1, 0x03, 0x0842, 0x0146 }, - { 0x0c, 0x09, -1, 0x03, 0x0842, 0x0246 }, - { 0x0c, 0x0a, -1, 0x03, 0x0842, 0x0446 }, - { 0x0c, 0x18, -1, 0x03, 0x0842, 0x0846 }, - { 0x0e, 0x05, -1, 0x03, 0x1842, 0x0046 }, - { 0x0e, 0x05, -1, 0x03, 0x1842, 0x0066 }, - { 0x0e, 0x06, -1, 0x03, 0x1842, 0x0086 }, - { 0x0e, 0x07, -1, 0x03, 0x1842, 0x00c6 }, - { 0x0e, 0x08, -1, 0x03, 0x1842, 0x0146 }, - { 0x0e, 0x09, -1, 0x03, 0x1842, 0x0246 }, - { 0x0e, 0x0a, -1, 0x03, 0x1842, 0x0446 }, - { 0x0e, 0x18, -1, 0x03, 0x1842, 0x0846 }, - { 0x18, 0x05, -1, 0x03, 0x5842, 0x0046 }, - { 0x18, 0x05, -1, 0x03, 0x5842, 0x0066 }, - { 0x18, 0x06, -1, 0x03, 0x5842, 0x0086 }, - { 0x18, 0x07, -1, 0x03, 0x5842, 0x00c6 }, - { 0x18, 0x08, -1, 0x03, 0x5842, 0x0146 }, - { 0x18, 0x09, -1, 0x03, 0x5842, 0x0246 }, - { 0x18, 0x0a, -1, 0x03, 0x5842, 0x0446 }, - { 0x18, 0x18, -1, 0x03, 0x5842, 0x0846 }, -}; - -#endif /* BROTLI_DEC_PREFIX_H_ */ + { 0x00, 0x00, 0, 0x00, 0x0000, 0x0002 }, + { 0x00, 0x00, 0, 0x01, 0x0000, 0x0003 }, + { 0x00, 0x00, 0, 0x02, 0x0000, 0x0004 }, + { 0x00, 0x00, 0, 0x03, 0x0000, 0x0005 }, + { 0x00, 0x00, 0, 0x03, 0x0000, 0x0006 }, + { 0x00, 0x00, 0, 0x03, 0x0000, 0x0007 }, + { 0x00, 0x00, 0, 0x03, 0x0000, 0x0008 }, + { 0x00, 0x00, 0, 0x03, 0x0000, 0x0009 }, + { 0x00, 0x00, 0, 0x00, 0x0001, 0x0002 }, + { 0x00, 0x00, 0, 0x01, 0x0001, 0x0003 }, + { 0x00, 0x00, 0, 0x02, 0x0001, 0x0004 }, + { 0x00, 0x00, 0, 0x03, 0x0001, 0x0005 }, + { 0x00, 0x00, 0, 0x03, 0x0001, 0x0006 }, + { 0x00, 0x00, 0, 0x03, 0x0001, 0x0007 }, + { 0x00, 0x00, 0, 0x03, 0x0001, 0x0008 }, + { 0x00, 0x00, 0, 0x03, 0x0001, 0x0009 }, + { 0x00, 0x00, 0, 0x00, 0x0002, 0x0002 }, + { 0x00, 0x00, 0, 0x01, 0x0002, 0x0003 }, + { 0x00, 0x00, 0, 0x02, 0x0002, 0x0004 }, + { 0x00, 0x00, 0, 0x03, 0x0002, 0x0005 }, + { 0x00, 0x00, 0, 0x03, 0x0002, 0x0006 }, + { 0x00, 0x00, 0, 0x03, 0x0002, 0x0007 }, + { 0x00, 0x00, 0, 0x03, 0x0002, 0x0008 }, + { 0x00, 0x00, 0, 0x03, 0x0002, 0x0009 }, + { 0x00, 0x00, 0, 0x00, 0x0003, 0x0002 }, + { 0x00, 0x00, 0, 0x01, 0x0003, 0x0003 }, + { 0x00, 0x00, 0, 0x02, 0x0003, 0x0004 }, + { 0x00, 0x00, 0, 0x03, 0x0003, 0x0005 }, + { 0x00, 0x00, 0, 0x03, 0x0003, 0x0006 }, + { 0x00, 0x00, 0, 0x03, 0x0003, 0x0007 }, + { 0x00, 0x00, 0, 0x03, 0x0003, 0x0008 }, + { 0x00, 0x00, 0, 0x03, 0x0003, 0x0009 }, + { 0x00, 0x00, 0, 0x00, 0x0004, 0x0002 }, + { 0x00, 0x00, 0, 0x01, 0x0004, 0x0003 }, + { 0x00, 0x00, 0, 0x02, 0x0004, 0x0004 }, + { 0x00, 0x00, 0, 0x03, 0x0004, 0x0005 }, + { 0x00, 0x00, 0, 0x03, 0x0004, 0x0006 }, + { 0x00, 0x00, 0, 0x03, 0x0004, 0x0007 }, + { 0x00, 0x00, 0, 0x03, 0x0004, 0x0008 }, + { 0x00, 0x00, 0, 0x03, 0x0004, 0x0009 }, + { 0x00, 0x00, 0, 0x00, 0x0005, 0x0002 }, + { 0x00, 0x00, 0, 0x01, 0x0005, 0x0003 }, + { 0x00, 0x00, 0, 0x02, 0x0005, 0x0004 }, + { 0x00, 0x00, 0, 0x03, 0x0005, 0x0005 }, + { 0x00, 0x00, 0, 0x03, 0x0005, 0x0006 }, + { 0x00, 0x00, 0, 0x03, 0x0005, 0x0007 }, + { 0x00, 0x00, 0, 0x03, 0x0005, 0x0008 }, + { 0x00, 0x00, 0, 0x03, 0x0005, 0x0009 }, + { 0x01, 0x00, 0, 0x00, 0x0006, 0x0002 }, + { 0x01, 0x00, 0, 0x01, 0x0006, 0x0003 }, + { 0x01, 0x00, 0, 0x02, 0x0006, 0x0004 }, + { 0x01, 0x00, 0, 0x03, 0x0006, 0x0005 }, + { 0x01, 0x00, 0, 0x03, 0x0006, 0x0006 }, + { 0x01, 0x00, 0, 0x03, 0x0006, 0x0007 }, + { 0x01, 0x00, 0, 0x03, 0x0006, 0x0008 }, + { 0x01, 0x00, 0, 0x03, 0x0006, 0x0009 }, + { 0x01, 0x00, 0, 0x00, 0x0008, 0x0002 }, + { 0x01, 0x00, 0, 0x01, 0x0008, 0x0003 }, + { 0x01, 0x00, 0, 0x02, 0x0008, 0x0004 }, + { 0x01, 0x00, 0, 0x03, 0x0008, 0x0005 }, + { 0x01, 0x00, 0, 0x03, 0x0008, 0x0006 }, + { 0x01, 0x00, 0, 0x03, 0x0008, 0x0007 }, + { 0x01, 0x00, 0, 0x03, 0x0008, 0x0008 }, + { 0x01, 0x00, 0, 0x03, 0x0008, 0x0009 }, + { 0x00, 0x01, 0, 0x03, 0x0000, 0x000a }, + { 0x00, 0x01, 0, 0x03, 0x0000, 0x000c }, + { 0x00, 0x02, 0, 0x03, 0x0000, 0x000e }, + { 0x00, 0x02, 0, 0x03, 0x0000, 0x0012 }, + { 0x00, 0x03, 0, 0x03, 0x0000, 0x0016 }, + { 0x00, 0x03, 0, 0x03, 0x0000, 0x001e }, + { 0x00, 0x04, 0, 0x03, 0x0000, 0x0026 }, + { 0x00, 0x04, 0, 0x03, 0x0000, 0x0036 }, + { 0x00, 0x01, 0, 0x03, 0x0001, 0x000a }, + { 0x00, 0x01, 0, 0x03, 0x0001, 0x000c }, + { 0x00, 0x02, 0, 0x03, 0x0001, 0x000e }, + { 0x00, 0x02, 0, 0x03, 0x0001, 0x0012 }, + { 0x00, 0x03, 0, 0x03, 0x0001, 0x0016 }, + { 0x00, 0x03, 0, 0x03, 0x0001, 0x001e }, + { 0x00, 0x04, 0, 0x03, 0x0001, 0x0026 }, + { 0x00, 0x04, 0, 0x03, 0x0001, 0x0036 }, + { 0x00, 0x01, 0, 0x03, 0x0002, 0x000a }, + { 0x00, 0x01, 0, 0x03, 0x0002, 0x000c }, + { 0x00, 0x02, 0, 0x03, 0x0002, 0x000e }, + { 0x00, 0x02, 0, 0x03, 0x0002, 0x0012 }, + { 0x00, 0x03, 0, 0x03, 0x0002, 0x0016 }, + { 0x00, 0x03, 0, 0x03, 0x0002, 0x001e }, + { 0x00, 0x04, 0, 0x03, 0x0002, 0x0026 }, + { 0x00, 0x04, 0, 0x03, 0x0002, 0x0036 }, + { 0x00, 0x01, 0, 0x03, 0x0003, 0x000a }, + { 0x00, 0x01, 0, 0x03, 0x0003, 0x000c }, + { 0x00, 0x02, 0, 0x03, 0x0003, 0x000e }, + { 0x00, 0x02, 0, 0x03, 0x0003, 0x0012 }, + { 0x00, 0x03, 0, 0x03, 0x0003, 0x0016 }, + { 0x00, 0x03, 0, 0x03, 0x0003, 0x001e }, + { 0x00, 0x04, 0, 0x03, 0x0003, 0x0026 }, + { 0x00, 0x04, 0, 0x03, 0x0003, 0x0036 }, + { 0x00, 0x01, 0, 0x03, 0x0004, 0x000a }, + { 0x00, 0x01, 0, 0x03, 0x0004, 0x000c }, + { 0x00, 0x02, 0, 0x03, 0x0004, 0x000e }, + { 0x00, 0x02, 0, 0x03, 0x0004, 0x0012 }, + { 0x00, 0x03, 0, 0x03, 0x0004, 0x0016 }, + { 0x00, 0x03, 0, 0x03, 0x0004, 0x001e }, + { 0x00, 0x04, 0, 0x03, 0x0004, 0x0026 }, + { 0x00, 0x04, 0, 0x03, 0x0004, 0x0036 }, + { 0x00, 0x01, 0, 0x03, 0x0005, 0x000a }, + { 0x00, 0x01, 0, 0x03, 0x0005, 0x000c }, + { 0x00, 0x02, 0, 0x03, 0x0005, 0x000e }, + { 0x00, 0x02, 0, 0x03, 0x0005, 0x0012 }, + { 0x00, 0x03, 0, 0x03, 0x0005, 0x0016 }, + { 0x00, 0x03, 0, 0x03, 0x0005, 0x001e }, + { 0x00, 0x04, 0, 0x03, 0x0005, 0x0026 }, + { 0x00, 0x04, 0, 0x03, 0x0005, 0x0036 }, + { 0x01, 0x01, 0, 0x03, 0x0006, 0x000a }, + { 0x01, 0x01, 0, 0x03, 0x0006, 0x000c }, + { 0x01, 0x02, 0, 0x03, 0x0006, 0x000e }, + { 0x01, 0x02, 0, 0x03, 0x0006, 0x0012 }, + { 0x01, 0x03, 0, 0x03, 0x0006, 0x0016 }, + { 0x01, 0x03, 0, 0x03, 0x0006, 0x001e }, + { 0x01, 0x04, 0, 0x03, 0x0006, 0x0026 }, + { 0x01, 0x04, 0, 0x03, 0x0006, 0x0036 }, + { 0x01, 0x01, 0, 0x03, 0x0008, 0x000a }, + { 0x01, 0x01, 0, 0x03, 0x0008, 0x000c }, + { 0x01, 0x02, 0, 0x03, 0x0008, 0x000e }, + { 0x01, 0x02, 0, 0x03, 0x0008, 0x0012 }, + { 0x01, 0x03, 0, 0x03, 0x0008, 0x0016 }, + { 0x01, 0x03, 0, 0x03, 0x0008, 0x001e }, + { 0x01, 0x04, 0, 0x03, 0x0008, 0x0026 }, + { 0x01, 0x04, 0, 0x03, 0x0008, 0x0036 }, + { 0x00, 0x00, -1, 0x00, 0x0000, 0x0002 }, + { 0x00, 0x00, -1, 0x01, 0x0000, 0x0003 }, + { 0x00, 0x00, -1, 0x02, 0x0000, 0x0004 }, + { 0x00, 0x00, -1, 0x03, 0x0000, 0x0005 }, + { 0x00, 0x00, -1, 0x03, 0x0000, 0x0006 }, + { 0x00, 0x00, -1, 0x03, 0x0000, 0x0007 }, + { 0x00, 0x00, -1, 0x03, 0x0000, 0x0008 }, + { 0x00, 0x00, -1, 0x03, 0x0000, 0x0009 }, + { 0x00, 0x00, -1, 0x00, 0x0001, 0x0002 }, + { 0x00, 0x00, -1, 0x01, 0x0001, 0x0003 }, + { 0x00, 0x00, -1, 0x02, 0x0001, 0x0004 }, + { 0x00, 0x00, -1, 0x03, 0x0001, 0x0005 }, + { 0x00, 0x00, -1, 0x03, 0x0001, 0x0006 }, + { 0x00, 0x00, -1, 0x03, 0x0001, 0x0007 }, + { 0x00, 0x00, -1, 0x03, 0x0001, 0x0008 }, + { 0x00, 0x00, -1, 0x03, 0x0001, 0x0009 }, + { 0x00, 0x00, -1, 0x00, 0x0002, 0x0002 }, + { 0x00, 0x00, -1, 0x01, 0x0002, 0x0003 }, + { 0x00, 0x00, -1, 0x02, 0x0002, 0x0004 }, + { 0x00, 0x00, -1, 0x03, 0x0002, 0x0005 }, + { 0x00, 0x00, -1, 0x03, 0x0002, 0x0006 }, + { 0x00, 0x00, -1, 0x03, 0x0002, 0x0007 }, + { 0x00, 0x00, -1, 0x03, 0x0002, 0x0008 }, + { 0x00, 0x00, -1, 0x03, 0x0002, 0x0009 }, + { 0x00, 0x00, -1, 0x00, 0x0003, 0x0002 }, + { 0x00, 0x00, -1, 0x01, 0x0003, 0x0003 }, + { 0x00, 0x00, -1, 0x02, 0x0003, 0x0004 }, + { 0x00, 0x00, -1, 0x03, 0x0003, 0x0005 }, + { 0x00, 0x00, -1, 0x03, 0x0003, 0x0006 }, + { 0x00, 0x00, -1, 0x03, 0x0003, 0x0007 }, + { 0x00, 0x00, -1, 0x03, 0x0003, 0x0008 }, + { 0x00, 0x00, -1, 0x03, 0x0003, 0x0009 }, + { 0x00, 0x00, -1, 0x00, 0x0004, 0x0002 }, + { 0x00, 0x00, -1, 0x01, 0x0004, 0x0003 }, + { 0x00, 0x00, -1, 0x02, 0x0004, 0x0004 }, + { 0x00, 0x00, -1, 0x03, 0x0004, 0x0005 }, + { 0x00, 0x00, -1, 0x03, 0x0004, 0x0006 }, + { 0x00, 0x00, -1, 0x03, 0x0004, 0x0007 }, + { 0x00, 0x00, -1, 0x03, 0x0004, 0x0008 }, + { 0x00, 0x00, -1, 0x03, 0x0004, 0x0009 }, + { 0x00, 0x00, -1, 0x00, 0x0005, 0x0002 }, + { 0x00, 0x00, -1, 0x01, 0x0005, 0x0003 }, + { 0x00, 0x00, -1, 0x02, 0x0005, 0x0004 }, + { 0x00, 0x00, -1, 0x03, 0x0005, 0x0005 }, + { 0x00, 0x00, -1, 0x03, 0x0005, 0x0006 }, + { 0x00, 0x00, -1, 0x03, 0x0005, 0x0007 }, + { 0x00, 0x00, -1, 0x03, 0x0005, 0x0008 }, + { 0x00, 0x00, -1, 0x03, 0x0005, 0x0009 }, + { 0x01, 0x00, -1, 0x00, 0x0006, 0x0002 }, + { 0x01, 0x00, -1, 0x01, 0x0006, 0x0003 }, + { 0x01, 0x00, -1, 0x02, 0x0006, 0x0004 }, + { 0x01, 0x00, -1, 0x03, 0x0006, 0x0005 }, + { 0x01, 0x00, -1, 0x03, 0x0006, 0x0006 }, + { 0x01, 0x00, -1, 0x03, 0x0006, 0x0007 }, + { 0x01, 0x00, -1, 0x03, 0x0006, 0x0008 }, + { 0x01, 0x00, -1, 0x03, 0x0006, 0x0009 }, + { 0x01, 0x00, -1, 0x00, 0x0008, 0x0002 }, + { 0x01, 0x00, -1, 0x01, 0x0008, 0x0003 }, + { 0x01, 0x00, -1, 0x02, 0x0008, 0x0004 }, + { 0x01, 0x00, -1, 0x03, 0x0008, 0x0005 }, + { 0x01, 0x00, -1, 0x03, 0x0008, 0x0006 }, + { 0x01, 0x00, -1, 0x03, 0x0008, 0x0007 }, + { 0x01, 0x00, -1, 0x03, 0x0008, 0x0008 }, + { 0x01, 0x00, -1, 0x03, 0x0008, 0x0009 }, + { 0x00, 0x01, -1, 0x03, 0x0000, 0x000a }, + { 0x00, 0x01, -1, 0x03, 0x0000, 0x000c }, + { 0x00, 0x02, -1, 0x03, 0x0000, 0x000e }, + { 0x00, 0x02, -1, 0x03, 0x0000, 0x0012 }, + { 0x00, 0x03, -1, 0x03, 0x0000, 0x0016 }, + { 0x00, 0x03, -1, 0x03, 0x0000, 0x001e }, + { 0x00, 0x04, -1, 0x03, 0x0000, 0x0026 }, + { 0x00, 0x04, -1, 0x03, 0x0000, 0x0036 }, + { 0x00, 0x01, -1, 0x03, 0x0001, 0x000a }, + { 0x00, 0x01, -1, 0x03, 0x0001, 0x000c }, + { 0x00, 0x02, -1, 0x03, 0x0001, 0x000e }, + { 0x00, 0x02, -1, 0x03, 0x0001, 0x0012 }, + { 0x00, 0x03, -1, 0x03, 0x0001, 0x0016 }, + { 0x00, 0x03, -1, 0x03, 0x0001, 0x001e }, + { 0x00, 0x04, -1, 0x03, 0x0001, 0x0026 }, + { 0x00, 0x04, -1, 0x03, 0x0001, 0x0036 }, + { 0x00, 0x01, -1, 0x03, 0x0002, 0x000a }, + { 0x00, 0x01, -1, 0x03, 0x0002, 0x000c }, + { 0x00, 0x02, -1, 0x03, 0x0002, 0x000e }, + { 0x00, 0x02, -1, 0x03, 0x0002, 0x0012 }, + { 0x00, 0x03, -1, 0x03, 0x0002, 0x0016 }, + { 0x00, 0x03, -1, 0x03, 0x0002, 0x001e }, + { 0x00, 0x04, -1, 0x03, 0x0002, 0x0026 }, + { 0x00, 0x04, -1, 0x03, 0x0002, 0x0036 }, + { 0x00, 0x01, -1, 0x03, 0x0003, 0x000a }, + { 0x00, 0x01, -1, 0x03, 0x0003, 0x000c }, + { 0x00, 0x02, -1, 0x03, 0x0003, 0x000e }, + { 0x00, 0x02, -1, 0x03, 0x0003, 0x0012 }, + { 0x00, 0x03, -1, 0x03, 0x0003, 0x0016 }, + { 0x00, 0x03, -1, 0x03, 0x0003, 0x001e }, + { 0x00, 0x04, -1, 0x03, 0x0003, 0x0026 }, + { 0x00, 0x04, -1, 0x03, 0x0003, 0x0036 }, + { 0x00, 0x01, -1, 0x03, 0x0004, 0x000a }, + { 0x00, 0x01, -1, 0x03, 0x0004, 0x000c }, + { 0x00, 0x02, -1, 0x03, 0x0004, 0x000e }, + { 0x00, 0x02, -1, 0x03, 0x0004, 0x0012 }, + { 0x00, 0x03, -1, 0x03, 0x0004, 0x0016 }, + { 0x00, 0x03, -1, 0x03, 0x0004, 0x001e }, + { 0x00, 0x04, -1, 0x03, 0x0004, 0x0026 }, + { 0x00, 0x04, -1, 0x03, 0x0004, 0x0036 }, + { 0x00, 0x01, -1, 0x03, 0x0005, 0x000a }, + { 0x00, 0x01, -1, 0x03, 0x0005, 0x000c }, + { 0x00, 0x02, -1, 0x03, 0x0005, 0x000e }, + { 0x00, 0x02, -1, 0x03, 0x0005, 0x0012 }, + { 0x00, 0x03, -1, 0x03, 0x0005, 0x0016 }, + { 0x00, 0x03, -1, 0x03, 0x0005, 0x001e }, + { 0x00, 0x04, -1, 0x03, 0x0005, 0x0026 }, + { 0x00, 0x04, -1, 0x03, 0x0005, 0x0036 }, + { 0x01, 0x01, -1, 0x03, 0x0006, 0x000a }, + { 0x01, 0x01, -1, 0x03, 0x0006, 0x000c }, + { 0x01, 0x02, -1, 0x03, 0x0006, 0x000e }, + { 0x01, 0x02, -1, 0x03, 0x0006, 0x0012 }, + { 0x01, 0x03, -1, 0x03, 0x0006, 0x0016 }, + { 0x01, 0x03, -1, 0x03, 0x0006, 0x001e }, + { 0x01, 0x04, -1, 0x03, 0x0006, 0x0026 }, + { 0x01, 0x04, -1, 0x03, 0x0006, 0x0036 }, + { 0x01, 0x01, -1, 0x03, 0x0008, 0x000a }, + { 0x01, 0x01, -1, 0x03, 0x0008, 0x000c }, + { 0x01, 0x02, -1, 0x03, 0x0008, 0x000e }, + { 0x01, 0x02, -1, 0x03, 0x0008, 0x0012 }, + { 0x01, 0x03, -1, 0x03, 0x0008, 0x0016 }, + { 0x01, 0x03, -1, 0x03, 0x0008, 0x001e }, + { 0x01, 0x04, -1, 0x03, 0x0008, 0x0026 }, + { 0x01, 0x04, -1, 0x03, 0x0008, 0x0036 }, + { 0x02, 0x00, -1, 0x00, 0x000a, 0x0002 }, + { 0x02, 0x00, -1, 0x01, 0x000a, 0x0003 }, + { 0x02, 0x00, -1, 0x02, 0x000a, 0x0004 }, + { 0x02, 0x00, -1, 0x03, 0x000a, 0x0005 }, + { 0x02, 0x00, -1, 0x03, 0x000a, 0x0006 }, + { 0x02, 0x00, -1, 0x03, 0x000a, 0x0007 }, + { 0x02, 0x00, -1, 0x03, 0x000a, 0x0008 }, + { 0x02, 0x00, -1, 0x03, 0x000a, 0x0009 }, + { 0x02, 0x00, -1, 0x00, 0x000e, 0x0002 }, + { 0x02, 0x00, -1, 0x01, 0x000e, 0x0003 }, + { 0x02, 0x00, -1, 0x02, 0x000e, 0x0004 }, + { 0x02, 0x00, -1, 0x03, 0x000e, 0x0005 }, + { 0x02, 0x00, -1, 0x03, 0x000e, 0x0006 }, + { 0x02, 0x00, -1, 0x03, 0x000e, 0x0007 }, + { 0x02, 0x00, -1, 0x03, 0x000e, 0x0008 }, + { 0x02, 0x00, -1, 0x03, 0x000e, 0x0009 }, + { 0x03, 0x00, -1, 0x00, 0x0012, 0x0002 }, + { 0x03, 0x00, -1, 0x01, 0x0012, 0x0003 }, + { 0x03, 0x00, -1, 0x02, 0x0012, 0x0004 }, + { 0x03, 0x00, -1, 0x03, 0x0012, 0x0005 }, + { 0x03, 0x00, -1, 0x03, 0x0012, 0x0006 }, + { 0x03, 0x00, -1, 0x03, 0x0012, 0x0007 }, + { 0x03, 0x00, -1, 0x03, 0x0012, 0x0008 }, + { 0x03, 0x00, -1, 0x03, 0x0012, 0x0009 }, + { 0x03, 0x00, -1, 0x00, 0x001a, 0x0002 }, + { 0x03, 0x00, -1, 0x01, 0x001a, 0x0003 }, + { 0x03, 0x00, -1, 0x02, 0x001a, 0x0004 }, + { 0x03, 0x00, -1, 0x03, 0x001a, 0x0005 }, + { 0x03, 0x00, -1, 0x03, 0x001a, 0x0006 }, + { 0x03, 0x00, -1, 0x03, 0x001a, 0x0007 }, + { 0x03, 0x00, -1, 0x03, 0x001a, 0x0008 }, + { 0x03, 0x00, -1, 0x03, 0x001a, 0x0009 }, + { 0x04, 0x00, -1, 0x00, 0x0022, 0x0002 }, + { 0x04, 0x00, -1, 0x01, 0x0022, 0x0003 }, + { 0x04, 0x00, -1, 0x02, 0x0022, 0x0004 }, + { 0x04, 0x00, -1, 0x03, 0x0022, 0x0005 }, + { 0x04, 0x00, -1, 0x03, 0x0022, 0x0006 }, + { 0x04, 0x00, -1, 0x03, 0x0022, 0x0007 }, + { 0x04, 0x00, -1, 0x03, 0x0022, 0x0008 }, + { 0x04, 0x00, -1, 0x03, 0x0022, 0x0009 }, + { 0x04, 0x00, -1, 0x00, 0x0032, 0x0002 }, + { 0x04, 0x00, -1, 0x01, 0x0032, 0x0003 }, + { 0x04, 0x00, -1, 0x02, 0x0032, 0x0004 }, + { 0x04, 0x00, -1, 0x03, 0x0032, 0x0005 }, + { 0x04, 0x00, -1, 0x03, 0x0032, 0x0006 }, + { 0x04, 0x00, -1, 0x03, 0x0032, 0x0007 }, + { 0x04, 0x00, -1, 0x03, 0x0032, 0x0008 }, + { 0x04, 0x00, -1, 0x03, 0x0032, 0x0009 }, + { 0x05, 0x00, -1, 0x00, 0x0042, 0x0002 }, + { 0x05, 0x00, -1, 0x01, 0x0042, 0x0003 }, + { 0x05, 0x00, -1, 0x02, 0x0042, 0x0004 }, + { 0x05, 0x00, -1, 0x03, 0x0042, 0x0005 }, + { 0x05, 0x00, -1, 0x03, 0x0042, 0x0006 }, + { 0x05, 0x00, -1, 0x03, 0x0042, 0x0007 }, + { 0x05, 0x00, -1, 0x03, 0x0042, 0x0008 }, + { 0x05, 0x00, -1, 0x03, 0x0042, 0x0009 }, + { 0x05, 0x00, -1, 0x00, 0x0062, 0x0002 }, + { 0x05, 0x00, -1, 0x01, 0x0062, 0x0003 }, + { 0x05, 0x00, -1, 0x02, 0x0062, 0x0004 }, + { 0x05, 0x00, -1, 0x03, 0x0062, 0x0005 }, + { 0x05, 0x00, -1, 0x03, 0x0062, 0x0006 }, + { 0x05, 0x00, -1, 0x03, 0x0062, 0x0007 }, + { 0x05, 0x00, -1, 0x03, 0x0062, 0x0008 }, + { 0x05, 0x00, -1, 0x03, 0x0062, 0x0009 }, + { 0x02, 0x01, -1, 0x03, 0x000a, 0x000a }, + { 0x02, 0x01, -1, 0x03, 0x000a, 0x000c }, + { 0x02, 0x02, -1, 0x03, 0x000a, 0x000e }, + { 0x02, 0x02, -1, 0x03, 0x000a, 0x0012 }, + { 0x02, 0x03, -1, 0x03, 0x000a, 0x0016 }, + { 0x02, 0x03, -1, 0x03, 0x000a, 0x001e }, + { 0x02, 0x04, -1, 0x03, 0x000a, 0x0026 }, + { 0x02, 0x04, -1, 0x03, 0x000a, 0x0036 }, + { 0x02, 0x01, -1, 0x03, 0x000e, 0x000a }, + { 0x02, 0x01, -1, 0x03, 0x000e, 0x000c }, + { 0x02, 0x02, -1, 0x03, 0x000e, 0x000e }, + { 0x02, 0x02, -1, 0x03, 0x000e, 0x0012 }, + { 0x02, 0x03, -1, 0x03, 0x000e, 0x0016 }, + { 0x02, 0x03, -1, 0x03, 0x000e, 0x001e }, + { 0x02, 0x04, -1, 0x03, 0x000e, 0x0026 }, + { 0x02, 0x04, -1, 0x03, 0x000e, 0x0036 }, + { 0x03, 0x01, -1, 0x03, 0x0012, 0x000a }, + { 0x03, 0x01, -1, 0x03, 0x0012, 0x000c }, + { 0x03, 0x02, -1, 0x03, 0x0012, 0x000e }, + { 0x03, 0x02, -1, 0x03, 0x0012, 0x0012 }, + { 0x03, 0x03, -1, 0x03, 0x0012, 0x0016 }, + { 0x03, 0x03, -1, 0x03, 0x0012, 0x001e }, + { 0x03, 0x04, -1, 0x03, 0x0012, 0x0026 }, + { 0x03, 0x04, -1, 0x03, 0x0012, 0x0036 }, + { 0x03, 0x01, -1, 0x03, 0x001a, 0x000a }, + { 0x03, 0x01, -1, 0x03, 0x001a, 0x000c }, + { 0x03, 0x02, -1, 0x03, 0x001a, 0x000e }, + { 0x03, 0x02, -1, 0x03, 0x001a, 0x0012 }, + { 0x03, 0x03, -1, 0x03, 0x001a, 0x0016 }, + { 0x03, 0x03, -1, 0x03, 0x001a, 0x001e }, + { 0x03, 0x04, -1, 0x03, 0x001a, 0x0026 }, + { 0x03, 0x04, -1, 0x03, 0x001a, 0x0036 }, + { 0x04, 0x01, -1, 0x03, 0x0022, 0x000a }, + { 0x04, 0x01, -1, 0x03, 0x0022, 0x000c }, + { 0x04, 0x02, -1, 0x03, 0x0022, 0x000e }, + { 0x04, 0x02, -1, 0x03, 0x0022, 0x0012 }, + { 0x04, 0x03, -1, 0x03, 0x0022, 0x0016 }, + { 0x04, 0x03, -1, 0x03, 0x0022, 0x001e }, + { 0x04, 0x04, -1, 0x03, 0x0022, 0x0026 }, + { 0x04, 0x04, -1, 0x03, 0x0022, 0x0036 }, + { 0x04, 0x01, -1, 0x03, 0x0032, 0x000a }, + { 0x04, 0x01, -1, 0x03, 0x0032, 0x000c }, + { 0x04, 0x02, -1, 0x03, 0x0032, 0x000e }, + { 0x04, 0x02, -1, 0x03, 0x0032, 0x0012 }, + { 0x04, 0x03, -1, 0x03, 0x0032, 0x0016 }, + { 0x04, 0x03, -1, 0x03, 0x0032, 0x001e }, + { 0x04, 0x04, -1, 0x03, 0x0032, 0x0026 }, + { 0x04, 0x04, -1, 0x03, 0x0032, 0x0036 }, + { 0x05, 0x01, -1, 0x03, 0x0042, 0x000a }, + { 0x05, 0x01, -1, 0x03, 0x0042, 0x000c }, + { 0x05, 0x02, -1, 0x03, 0x0042, 0x000e }, + { 0x05, 0x02, -1, 0x03, 0x0042, 0x0012 }, + { 0x05, 0x03, -1, 0x03, 0x0042, 0x0016 }, + { 0x05, 0x03, -1, 0x03, 0x0042, 0x001e }, + { 0x05, 0x04, -1, 0x03, 0x0042, 0x0026 }, + { 0x05, 0x04, -1, 0x03, 0x0042, 0x0036 }, + { 0x05, 0x01, -1, 0x03, 0x0062, 0x000a }, + { 0x05, 0x01, -1, 0x03, 0x0062, 0x000c }, + { 0x05, 0x02, -1, 0x03, 0x0062, 0x000e }, + { 0x05, 0x02, -1, 0x03, 0x0062, 0x0012 }, + { 0x05, 0x03, -1, 0x03, 0x0062, 0x0016 }, + { 0x05, 0x03, -1, 0x03, 0x0062, 0x001e }, + { 0x05, 0x04, -1, 0x03, 0x0062, 0x0026 }, + { 0x05, 0x04, -1, 0x03, 0x0062, 0x0036 }, + { 0x00, 0x05, -1, 0x03, 0x0000, 0x0046 }, + { 0x00, 0x05, -1, 0x03, 0x0000, 0x0066 }, + { 0x00, 0x06, -1, 0x03, 0x0000, 0x0086 }, + { 0x00, 0x07, -1, 0x03, 0x0000, 0x00c6 }, + { 0x00, 0x08, -1, 0x03, 0x0000, 0x0146 }, + { 0x00, 0x09, -1, 0x03, 0x0000, 0x0246 }, + { 0x00, 0x0a, -1, 0x03, 0x0000, 0x0446 }, + { 0x00, 0x18, -1, 0x03, 0x0000, 0x0846 }, + { 0x00, 0x05, -1, 0x03, 0x0001, 0x0046 }, + { 0x00, 0x05, -1, 0x03, 0x0001, 0x0066 }, + { 0x00, 0x06, -1, 0x03, 0x0001, 0x0086 }, + { 0x00, 0x07, -1, 0x03, 0x0001, 0x00c6 }, + { 0x00, 0x08, -1, 0x03, 0x0001, 0x0146 }, + { 0x00, 0x09, -1, 0x03, 0x0001, 0x0246 }, + { 0x00, 0x0a, -1, 0x03, 0x0001, 0x0446 }, + { 0x00, 0x18, -1, 0x03, 0x0001, 0x0846 }, + { 0x00, 0x05, -1, 0x03, 0x0002, 0x0046 }, + { 0x00, 0x05, -1, 0x03, 0x0002, 0x0066 }, + { 0x00, 0x06, -1, 0x03, 0x0002, 0x0086 }, + { 0x00, 0x07, -1, 0x03, 0x0002, 0x00c6 }, + { 0x00, 0x08, -1, 0x03, 0x0002, 0x0146 }, + { 0x00, 0x09, -1, 0x03, 0x0002, 0x0246 }, + { 0x00, 0x0a, -1, 0x03, 0x0002, 0x0446 }, + { 0x00, 0x18, -1, 0x03, 0x0002, 0x0846 }, + { 0x00, 0x05, -1, 0x03, 0x0003, 0x0046 }, + { 0x00, 0x05, -1, 0x03, 0x0003, 0x0066 }, + { 0x00, 0x06, -1, 0x03, 0x0003, 0x0086 }, + { 0x00, 0x07, -1, 0x03, 0x0003, 0x00c6 }, + { 0x00, 0x08, -1, 0x03, 0x0003, 0x0146 }, + { 0x00, 0x09, -1, 0x03, 0x0003, 0x0246 }, + { 0x00, 0x0a, -1, 0x03, 0x0003, 0x0446 }, + { 0x00, 0x18, -1, 0x03, 0x0003, 0x0846 }, + { 0x00, 0x05, -1, 0x03, 0x0004, 0x0046 }, + { 0x00, 0x05, -1, 0x03, 0x0004, 0x0066 }, + { 0x00, 0x06, -1, 0x03, 0x0004, 0x0086 }, + { 0x00, 0x07, -1, 0x03, 0x0004, 0x00c6 }, + { 0x00, 0x08, -1, 0x03, 0x0004, 0x0146 }, + { 0x00, 0x09, -1, 0x03, 0x0004, 0x0246 }, + { 0x00, 0x0a, -1, 0x03, 0x0004, 0x0446 }, + { 0x00, 0x18, -1, 0x03, 0x0004, 0x0846 }, + { 0x00, 0x05, -1, 0x03, 0x0005, 0x0046 }, + { 0x00, 0x05, -1, 0x03, 0x0005, 0x0066 }, + { 0x00, 0x06, -1, 0x03, 0x0005, 0x0086 }, + { 0x00, 0x07, -1, 0x03, 0x0005, 0x00c6 }, + { 0x00, 0x08, -1, 0x03, 0x0005, 0x0146 }, + { 0x00, 0x09, -1, 0x03, 0x0005, 0x0246 }, + { 0x00, 0x0a, -1, 0x03, 0x0005, 0x0446 }, + { 0x00, 0x18, -1, 0x03, 0x0005, 0x0846 }, + { 0x01, 0x05, -1, 0x03, 0x0006, 0x0046 }, + { 0x01, 0x05, -1, 0x03, 0x0006, 0x0066 }, + { 0x01, 0x06, -1, 0x03, 0x0006, 0x0086 }, + { 0x01, 0x07, -1, 0x03, 0x0006, 0x00c6 }, + { 0x01, 0x08, -1, 0x03, 0x0006, 0x0146 }, + { 0x01, 0x09, -1, 0x03, 0x0006, 0x0246 }, + { 0x01, 0x0a, -1, 0x03, 0x0006, 0x0446 }, + { 0x01, 0x18, -1, 0x03, 0x0006, 0x0846 }, + { 0x01, 0x05, -1, 0x03, 0x0008, 0x0046 }, + { 0x01, 0x05, -1, 0x03, 0x0008, 0x0066 }, + { 0x01, 0x06, -1, 0x03, 0x0008, 0x0086 }, + { 0x01, 0x07, -1, 0x03, 0x0008, 0x00c6 }, + { 0x01, 0x08, -1, 0x03, 0x0008, 0x0146 }, + { 0x01, 0x09, -1, 0x03, 0x0008, 0x0246 }, + { 0x01, 0x0a, -1, 0x03, 0x0008, 0x0446 }, + { 0x01, 0x18, -1, 0x03, 0x0008, 0x0846 }, + { 0x06, 0x00, -1, 0x00, 0x0082, 0x0002 }, + { 0x06, 0x00, -1, 0x01, 0x0082, 0x0003 }, + { 0x06, 0x00, -1, 0x02, 0x0082, 0x0004 }, + { 0x06, 0x00, -1, 0x03, 0x0082, 0x0005 }, + { 0x06, 0x00, -1, 0x03, 0x0082, 0x0006 }, + { 0x06, 0x00, -1, 0x03, 0x0082, 0x0007 }, + { 0x06, 0x00, -1, 0x03, 0x0082, 0x0008 }, + { 0x06, 0x00, -1, 0x03, 0x0082, 0x0009 }, + { 0x07, 0x00, -1, 0x00, 0x00c2, 0x0002 }, + { 0x07, 0x00, -1, 0x01, 0x00c2, 0x0003 }, + { 0x07, 0x00, -1, 0x02, 0x00c2, 0x0004 }, + { 0x07, 0x00, -1, 0x03, 0x00c2, 0x0005 }, + { 0x07, 0x00, -1, 0x03, 0x00c2, 0x0006 }, + { 0x07, 0x00, -1, 0x03, 0x00c2, 0x0007 }, + { 0x07, 0x00, -1, 0x03, 0x00c2, 0x0008 }, + { 0x07, 0x00, -1, 0x03, 0x00c2, 0x0009 }, + { 0x08, 0x00, -1, 0x00, 0x0142, 0x0002 }, + { 0x08, 0x00, -1, 0x01, 0x0142, 0x0003 }, + { 0x08, 0x00, -1, 0x02, 0x0142, 0x0004 }, + { 0x08, 0x00, -1, 0x03, 0x0142, 0x0005 }, + { 0x08, 0x00, -1, 0x03, 0x0142, 0x0006 }, + { 0x08, 0x00, -1, 0x03, 0x0142, 0x0007 }, + { 0x08, 0x00, -1, 0x03, 0x0142, 0x0008 }, + { 0x08, 0x00, -1, 0x03, 0x0142, 0x0009 }, + { 0x09, 0x00, -1, 0x00, 0x0242, 0x0002 }, + { 0x09, 0x00, -1, 0x01, 0x0242, 0x0003 }, + { 0x09, 0x00, -1, 0x02, 0x0242, 0x0004 }, + { 0x09, 0x00, -1, 0x03, 0x0242, 0x0005 }, + { 0x09, 0x00, -1, 0x03, 0x0242, 0x0006 }, + { 0x09, 0x00, -1, 0x03, 0x0242, 0x0007 }, + { 0x09, 0x00, -1, 0x03, 0x0242, 0x0008 }, + { 0x09, 0x00, -1, 0x03, 0x0242, 0x0009 }, + { 0x0a, 0x00, -1, 0x00, 0x0442, 0x0002 }, + { 0x0a, 0x00, -1, 0x01, 0x0442, 0x0003 }, + { 0x0a, 0x00, -1, 0x02, 0x0442, 0x0004 }, + { 0x0a, 0x00, -1, 0x03, 0x0442, 0x0005 }, + { 0x0a, 0x00, -1, 0x03, 0x0442, 0x0006 }, + { 0x0a, 0x00, -1, 0x03, 0x0442, 0x0007 }, + { 0x0a, 0x00, -1, 0x03, 0x0442, 0x0008 }, + { 0x0a, 0x00, -1, 0x03, 0x0442, 0x0009 }, + { 0x0c, 0x00, -1, 0x00, 0x0842, 0x0002 }, + { 0x0c, 0x00, -1, 0x01, 0x0842, 0x0003 }, + { 0x0c, 0x00, -1, 0x02, 0x0842, 0x0004 }, + { 0x0c, 0x00, -1, 0x03, 0x0842, 0x0005 }, + { 0x0c, 0x00, -1, 0x03, 0x0842, 0x0006 }, + { 0x0c, 0x00, -1, 0x03, 0x0842, 0x0007 }, + { 0x0c, 0x00, -1, 0x03, 0x0842, 0x0008 }, + { 0x0c, 0x00, -1, 0x03, 0x0842, 0x0009 }, + { 0x0e, 0x00, -1, 0x00, 0x1842, 0x0002 }, + { 0x0e, 0x00, -1, 0x01, 0x1842, 0x0003 }, + { 0x0e, 0x00, -1, 0x02, 0x1842, 0x0004 }, + { 0x0e, 0x00, -1, 0x03, 0x1842, 0x0005 }, + { 0x0e, 0x00, -1, 0x03, 0x1842, 0x0006 }, + { 0x0e, 0x00, -1, 0x03, 0x1842, 0x0007 }, + { 0x0e, 0x00, -1, 0x03, 0x1842, 0x0008 }, + { 0x0e, 0x00, -1, 0x03, 0x1842, 0x0009 }, + { 0x18, 0x00, -1, 0x00, 0x5842, 0x0002 }, + { 0x18, 0x00, -1, 0x01, 0x5842, 0x0003 }, + { 0x18, 0x00, -1, 0x02, 0x5842, 0x0004 }, + { 0x18, 0x00, -1, 0x03, 0x5842, 0x0005 }, + { 0x18, 0x00, -1, 0x03, 0x5842, 0x0006 }, + { 0x18, 0x00, -1, 0x03, 0x5842, 0x0007 }, + { 0x18, 0x00, -1, 0x03, 0x5842, 0x0008 }, + { 0x18, 0x00, -1, 0x03, 0x5842, 0x0009 }, + { 0x02, 0x05, -1, 0x03, 0x000a, 0x0046 }, + { 0x02, 0x05, -1, 0x03, 0x000a, 0x0066 }, + { 0x02, 0x06, -1, 0x03, 0x000a, 0x0086 }, + { 0x02, 0x07, -1, 0x03, 0x000a, 0x00c6 }, + { 0x02, 0x08, -1, 0x03, 0x000a, 0x0146 }, + { 0x02, 0x09, -1, 0x03, 0x000a, 0x0246 }, + { 0x02, 0x0a, -1, 0x03, 0x000a, 0x0446 }, + { 0x02, 0x18, -1, 0x03, 0x000a, 0x0846 }, + { 0x02, 0x05, -1, 0x03, 0x000e, 0x0046 }, + { 0x02, 0x05, -1, 0x03, 0x000e, 0x0066 }, + { 0x02, 0x06, -1, 0x03, 0x000e, 0x0086 }, + { 0x02, 0x07, -1, 0x03, 0x000e, 0x00c6 }, + { 0x02, 0x08, -1, 0x03, 0x000e, 0x0146 }, + { 0x02, 0x09, -1, 0x03, 0x000e, 0x0246 }, + { 0x02, 0x0a, -1, 0x03, 0x000e, 0x0446 }, + { 0x02, 0x18, -1, 0x03, 0x000e, 0x0846 }, + { 0x03, 0x05, -1, 0x03, 0x0012, 0x0046 }, + { 0x03, 0x05, -1, 0x03, 0x0012, 0x0066 }, + { 0x03, 0x06, -1, 0x03, 0x0012, 0x0086 }, + { 0x03, 0x07, -1, 0x03, 0x0012, 0x00c6 }, + { 0x03, 0x08, -1, 0x03, 0x0012, 0x0146 }, + { 0x03, 0x09, -1, 0x03, 0x0012, 0x0246 }, + { 0x03, 0x0a, -1, 0x03, 0x0012, 0x0446 }, + { 0x03, 0x18, -1, 0x03, 0x0012, 0x0846 }, + { 0x03, 0x05, -1, 0x03, 0x001a, 0x0046 }, + { 0x03, 0x05, -1, 0x03, 0x001a, 0x0066 }, + { 0x03, 0x06, -1, 0x03, 0x001a, 0x0086 }, + { 0x03, 0x07, -1, 0x03, 0x001a, 0x00c6 }, + { 0x03, 0x08, -1, 0x03, 0x001a, 0x0146 }, + { 0x03, 0x09, -1, 0x03, 0x001a, 0x0246 }, + { 0x03, 0x0a, -1, 0x03, 0x001a, 0x0446 }, + { 0x03, 0x18, -1, 0x03, 0x001a, 0x0846 }, + { 0x04, 0x05, -1, 0x03, 0x0022, 0x0046 }, + { 0x04, 0x05, -1, 0x03, 0x0022, 0x0066 }, + { 0x04, 0x06, -1, 0x03, 0x0022, 0x0086 }, + { 0x04, 0x07, -1, 0x03, 0x0022, 0x00c6 }, + { 0x04, 0x08, -1, 0x03, 0x0022, 0x0146 }, + { 0x04, 0x09, -1, 0x03, 0x0022, 0x0246 }, + { 0x04, 0x0a, -1, 0x03, 0x0022, 0x0446 }, + { 0x04, 0x18, -1, 0x03, 0x0022, 0x0846 }, + { 0x04, 0x05, -1, 0x03, 0x0032, 0x0046 }, + { 0x04, 0x05, -1, 0x03, 0x0032, 0x0066 }, + { 0x04, 0x06, -1, 0x03, 0x0032, 0x0086 }, + { 0x04, 0x07, -1, 0x03, 0x0032, 0x00c6 }, + { 0x04, 0x08, -1, 0x03, 0x0032, 0x0146 }, + { 0x04, 0x09, -1, 0x03, 0x0032, 0x0246 }, + { 0x04, 0x0a, -1, 0x03, 0x0032, 0x0446 }, + { 0x04, 0x18, -1, 0x03, 0x0032, 0x0846 }, + { 0x05, 0x05, -1, 0x03, 0x0042, 0x0046 }, + { 0x05, 0x05, -1, 0x03, 0x0042, 0x0066 }, + { 0x05, 0x06, -1, 0x03, 0x0042, 0x0086 }, + { 0x05, 0x07, -1, 0x03, 0x0042, 0x00c6 }, + { 0x05, 0x08, -1, 0x03, 0x0042, 0x0146 }, + { 0x05, 0x09, -1, 0x03, 0x0042, 0x0246 }, + { 0x05, 0x0a, -1, 0x03, 0x0042, 0x0446 }, + { 0x05, 0x18, -1, 0x03, 0x0042, 0x0846 }, + { 0x05, 0x05, -1, 0x03, 0x0062, 0x0046 }, + { 0x05, 0x05, -1, 0x03, 0x0062, 0x0066 }, + { 0x05, 0x06, -1, 0x03, 0x0062, 0x0086 }, + { 0x05, 0x07, -1, 0x03, 0x0062, 0x00c6 }, + { 0x05, 0x08, -1, 0x03, 0x0062, 0x0146 }, + { 0x05, 0x09, -1, 0x03, 0x0062, 0x0246 }, + { 0x05, 0x0a, -1, 0x03, 0x0062, 0x0446 }, + { 0x05, 0x18, -1, 0x03, 0x0062, 0x0846 }, + { 0x06, 0x01, -1, 0x03, 0x0082, 0x000a }, + { 0x06, 0x01, -1, 0x03, 0x0082, 0x000c }, + { 0x06, 0x02, -1, 0x03, 0x0082, 0x000e }, + { 0x06, 0x02, -1, 0x03, 0x0082, 0x0012 }, + { 0x06, 0x03, -1, 0x03, 0x0082, 0x0016 }, + { 0x06, 0x03, -1, 0x03, 0x0082, 0x001e }, + { 0x06, 0x04, -1, 0x03, 0x0082, 0x0026 }, + { 0x06, 0x04, -1, 0x03, 0x0082, 0x0036 }, + { 0x07, 0x01, -1, 0x03, 0x00c2, 0x000a }, + { 0x07, 0x01, -1, 0x03, 0x00c2, 0x000c }, + { 0x07, 0x02, -1, 0x03, 0x00c2, 0x000e }, + { 0x07, 0x02, -1, 0x03, 0x00c2, 0x0012 }, + { 0x07, 0x03, -1, 0x03, 0x00c2, 0x0016 }, + { 0x07, 0x03, -1, 0x03, 0x00c2, 0x001e }, + { 0x07, 0x04, -1, 0x03, 0x00c2, 0x0026 }, + { 0x07, 0x04, -1, 0x03, 0x00c2, 0x0036 }, + { 0x08, 0x01, -1, 0x03, 0x0142, 0x000a }, + { 0x08, 0x01, -1, 0x03, 0x0142, 0x000c }, + { 0x08, 0x02, -1, 0x03, 0x0142, 0x000e }, + { 0x08, 0x02, -1, 0x03, 0x0142, 0x0012 }, + { 0x08, 0x03, -1, 0x03, 0x0142, 0x0016 }, + { 0x08, 0x03, -1, 0x03, 0x0142, 0x001e }, + { 0x08, 0x04, -1, 0x03, 0x0142, 0x0026 }, + { 0x08, 0x04, -1, 0x03, 0x0142, 0x0036 }, + { 0x09, 0x01, -1, 0x03, 0x0242, 0x000a }, + { 0x09, 0x01, -1, 0x03, 0x0242, 0x000c }, + { 0x09, 0x02, -1, 0x03, 0x0242, 0x000e }, + { 0x09, 0x02, -1, 0x03, 0x0242, 0x0012 }, + { 0x09, 0x03, -1, 0x03, 0x0242, 0x0016 }, + { 0x09, 0x03, -1, 0x03, 0x0242, 0x001e }, + { 0x09, 0x04, -1, 0x03, 0x0242, 0x0026 }, + { 0x09, 0x04, -1, 0x03, 0x0242, 0x0036 }, + { 0x0a, 0x01, -1, 0x03, 0x0442, 0x000a }, + { 0x0a, 0x01, -1, 0x03, 0x0442, 0x000c }, + { 0x0a, 0x02, -1, 0x03, 0x0442, 0x000e }, + { 0x0a, 0x02, -1, 0x03, 0x0442, 0x0012 }, + { 0x0a, 0x03, -1, 0x03, 0x0442, 0x0016 }, + { 0x0a, 0x03, -1, 0x03, 0x0442, 0x001e }, + { 0x0a, 0x04, -1, 0x03, 0x0442, 0x0026 }, + { 0x0a, 0x04, -1, 0x03, 0x0442, 0x0036 }, + { 0x0c, 0x01, -1, 0x03, 0x0842, 0x000a }, + { 0x0c, 0x01, -1, 0x03, 0x0842, 0x000c }, + { 0x0c, 0x02, -1, 0x03, 0x0842, 0x000e }, + { 0x0c, 0x02, -1, 0x03, 0x0842, 0x0012 }, + { 0x0c, 0x03, -1, 0x03, 0x0842, 0x0016 }, + { 0x0c, 0x03, -1, 0x03, 0x0842, 0x001e }, + { 0x0c, 0x04, -1, 0x03, 0x0842, 0x0026 }, + { 0x0c, 0x04, -1, 0x03, 0x0842, 0x0036 }, + { 0x0e, 0x01, -1, 0x03, 0x1842, 0x000a }, + { 0x0e, 0x01, -1, 0x03, 0x1842, 0x000c }, + { 0x0e, 0x02, -1, 0x03, 0x1842, 0x000e }, + { 0x0e, 0x02, -1, 0x03, 0x1842, 0x0012 }, + { 0x0e, 0x03, -1, 0x03, 0x1842, 0x0016 }, + { 0x0e, 0x03, -1, 0x03, 0x1842, 0x001e }, + { 0x0e, 0x04, -1, 0x03, 0x1842, 0x0026 }, + { 0x0e, 0x04, -1, 0x03, 0x1842, 0x0036 }, + { 0x18, 0x01, -1, 0x03, 0x5842, 0x000a }, + { 0x18, 0x01, -1, 0x03, 0x5842, 0x000c }, + { 0x18, 0x02, -1, 0x03, 0x5842, 0x000e }, + { 0x18, 0x02, -1, 0x03, 0x5842, 0x0012 }, + { 0x18, 0x03, -1, 0x03, 0x5842, 0x0016 }, + { 0x18, 0x03, -1, 0x03, 0x5842, 0x001e }, + { 0x18, 0x04, -1, 0x03, 0x5842, 0x0026 }, + { 0x18, 0x04, -1, 0x03, 0x5842, 0x0036 }, + { 0x06, 0x05, -1, 0x03, 0x0082, 0x0046 }, + { 0x06, 0x05, -1, 0x03, 0x0082, 0x0066 }, + { 0x06, 0x06, -1, 0x03, 0x0082, 0x0086 }, + { 0x06, 0x07, -1, 0x03, 0x0082, 0x00c6 }, + { 0x06, 0x08, -1, 0x03, 0x0082, 0x0146 }, + { 0x06, 0x09, -1, 0x03, 0x0082, 0x0246 }, + { 0x06, 0x0a, -1, 0x03, 0x0082, 0x0446 }, + { 0x06, 0x18, -1, 0x03, 0x0082, 0x0846 }, + { 0x07, 0x05, -1, 0x03, 0x00c2, 0x0046 }, + { 0x07, 0x05, -1, 0x03, 0x00c2, 0x0066 }, + { 0x07, 0x06, -1, 0x03, 0x00c2, 0x0086 }, + { 0x07, 0x07, -1, 0x03, 0x00c2, 0x00c6 }, + { 0x07, 0x08, -1, 0x03, 0x00c2, 0x0146 }, + { 0x07, 0x09, -1, 0x03, 0x00c2, 0x0246 }, + { 0x07, 0x0a, -1, 0x03, 0x00c2, 0x0446 }, + { 0x07, 0x18, -1, 0x03, 0x00c2, 0x0846 }, + { 0x08, 0x05, -1, 0x03, 0x0142, 0x0046 }, + { 0x08, 0x05, -1, 0x03, 0x0142, 0x0066 }, + { 0x08, 0x06, -1, 0x03, 0x0142, 0x0086 }, + { 0x08, 0x07, -1, 0x03, 0x0142, 0x00c6 }, + { 0x08, 0x08, -1, 0x03, 0x0142, 0x0146 }, + { 0x08, 0x09, -1, 0x03, 0x0142, 0x0246 }, + { 0x08, 0x0a, -1, 0x03, 0x0142, 0x0446 }, + { 0x08, 0x18, -1, 0x03, 0x0142, 0x0846 }, + { 0x09, 0x05, -1, 0x03, 0x0242, 0x0046 }, + { 0x09, 0x05, -1, 0x03, 0x0242, 0x0066 }, + { 0x09, 0x06, -1, 0x03, 0x0242, 0x0086 }, + { 0x09, 0x07, -1, 0x03, 0x0242, 0x00c6 }, + { 0x09, 0x08, -1, 0x03, 0x0242, 0x0146 }, + { 0x09, 0x09, -1, 0x03, 0x0242, 0x0246 }, + { 0x09, 0x0a, -1, 0x03, 0x0242, 0x0446 }, + { 0x09, 0x18, -1, 0x03, 0x0242, 0x0846 }, + { 0x0a, 0x05, -1, 0x03, 0x0442, 0x0046 }, + { 0x0a, 0x05, -1, 0x03, 0x0442, 0x0066 }, + { 0x0a, 0x06, -1, 0x03, 0x0442, 0x0086 }, + { 0x0a, 0x07, -1, 0x03, 0x0442, 0x00c6 }, + { 0x0a, 0x08, -1, 0x03, 0x0442, 0x0146 }, + { 0x0a, 0x09, -1, 0x03, 0x0442, 0x0246 }, + { 0x0a, 0x0a, -1, 0x03, 0x0442, 0x0446 }, + { 0x0a, 0x18, -1, 0x03, 0x0442, 0x0846 }, + { 0x0c, 0x05, -1, 0x03, 0x0842, 0x0046 }, + { 0x0c, 0x05, -1, 0x03, 0x0842, 0x0066 }, + { 0x0c, 0x06, -1, 0x03, 0x0842, 0x0086 }, + { 0x0c, 0x07, -1, 0x03, 0x0842, 0x00c6 }, + { 0x0c, 0x08, -1, 0x03, 0x0842, 0x0146 }, + { 0x0c, 0x09, -1, 0x03, 0x0842, 0x0246 }, + { 0x0c, 0x0a, -1, 0x03, 0x0842, 0x0446 }, + { 0x0c, 0x18, -1, 0x03, 0x0842, 0x0846 }, + { 0x0e, 0x05, -1, 0x03, 0x1842, 0x0046 }, + { 0x0e, 0x05, -1, 0x03, 0x1842, 0x0066 }, + { 0x0e, 0x06, -1, 0x03, 0x1842, 0x0086 }, + { 0x0e, 0x07, -1, 0x03, 0x1842, 0x00c6 }, + { 0x0e, 0x08, -1, 0x03, 0x1842, 0x0146 }, + { 0x0e, 0x09, -1, 0x03, 0x1842, 0x0246 }, + { 0x0e, 0x0a, -1, 0x03, 0x1842, 0x0446 }, + { 0x0e, 0x18, -1, 0x03, 0x1842, 0x0846 }, + { 0x18, 0x05, -1, 0x03, 0x5842, 0x0046 }, + { 0x18, 0x05, -1, 0x03, 0x5842, 0x0066 }, + { 0x18, 0x06, -1, 0x03, 0x5842, 0x0086 }, + { 0x18, 0x07, -1, 0x03, 0x5842, 0x00c6 }, + { 0x18, 0x08, -1, 0x03, 0x5842, 0x0146 }, + { 0x18, 0x09, -1, 0x03, 0x5842, 0x0246 }, + { 0x18, 0x0a, -1, 0x03, 0x5842, 0x0446 }, + { 0x18, 0x18, -1, 0x03, 0x5842, 0x0846 }, +}; + +#endif /* BROTLI_DEC_PREFIX_H_ */ diff --git a/contrib/libs/brotli/dec/state.c b/contrib/libs/brotli/dec/state.c index aebdee19c4..e0b37c2dcd 100644 --- a/contrib/libs/brotli/dec/state.c +++ b/contrib/libs/brotli/dec/state.c @@ -1,20 +1,20 @@ -/* Copyright 2015 Google Inc. All Rights Reserved. - +/* Copyright 2015 Google Inc. All Rights Reserved. + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ - + #include "./state.h" - + #include <stdlib.h> /* free, malloc */ - + #include <brotli/types.h> -#include "./huffman.h" - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - +#include "./huffman.h" + +#if defined(__cplusplus) || defined(c_plusplus) +extern "C" { +#endif + BROTLI_BOOL BrotliDecoderStateInit(BrotliDecoderState* s, brotli_alloc_func alloc_func, brotli_free_func free_func, void* opaque) { if (!alloc_func) { @@ -30,101 +30,101 @@ BROTLI_BOOL BrotliDecoderStateInit(BrotliDecoderState* s, s->error_code = 0; /* BROTLI_DECODER_NO_ERROR */ BrotliInitBitReader(&s->br); - s->state = BROTLI_STATE_UNINITED; + s->state = BROTLI_STATE_UNINITED; s->large_window = 0; - s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_NONE; - s->substate_tree_group = BROTLI_STATE_TREE_GROUP_NONE; - s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_NONE; - s->substate_uncompressed = BROTLI_STATE_UNCOMPRESSED_NONE; - s->substate_huffman = BROTLI_STATE_HUFFMAN_NONE; - s->substate_decode_uint8 = BROTLI_STATE_DECODE_UINT8_NONE; + s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_NONE; + s->substate_tree_group = BROTLI_STATE_TREE_GROUP_NONE; + s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_NONE; + s->substate_uncompressed = BROTLI_STATE_UNCOMPRESSED_NONE; + s->substate_huffman = BROTLI_STATE_HUFFMAN_NONE; + s->substate_decode_uint8 = BROTLI_STATE_DECODE_UINT8_NONE; s->substate_read_block_length = BROTLI_STATE_READ_BLOCK_LENGTH_NONE; - + s->buffer_length = 0; s->loop_counter = 0; s->pos = 0; s->rb_roundtrips = 0; s->partial_pos_out = 0; - s->block_type_trees = NULL; - s->block_len_trees = NULL; - s->ringbuffer = NULL; + s->block_type_trees = NULL; + s->block_len_trees = NULL; + s->ringbuffer = NULL; s->ringbuffer_size = 0; s->new_ringbuffer_size = 0; s->ringbuffer_mask = 0; - - s->context_map = NULL; - s->context_modes = NULL; - s->dist_context_map = NULL; - s->context_map_slice = NULL; - s->dist_context_map_slice = NULL; - + + s->context_map = NULL; + s->context_modes = NULL; + s->dist_context_map = NULL; + s->context_map_slice = NULL; + s->dist_context_map_slice = NULL; + s->sub_loop_counter = 0; - s->literal_hgroup.codes = NULL; - s->literal_hgroup.htrees = NULL; - s->insert_copy_hgroup.codes = NULL; - s->insert_copy_hgroup.htrees = NULL; - s->distance_hgroup.codes = NULL; - s->distance_hgroup.htrees = NULL; - + s->literal_hgroup.codes = NULL; + s->literal_hgroup.htrees = NULL; + s->insert_copy_hgroup.codes = NULL; + s->insert_copy_hgroup.htrees = NULL; + s->distance_hgroup.codes = NULL; + s->distance_hgroup.htrees = NULL; + s->is_last_metablock = 0; s->is_uncompressed = 0; s->is_metadata = 0; s->should_wrap_ringbuffer = 0; s->canny_ringbuffer_allocation = 1; - - s->window_bits = 0; - s->max_distance = 0; - s->dist_rb[0] = 16; - s->dist_rb[1] = 15; - s->dist_rb[2] = 11; - s->dist_rb[3] = 4; - s->dist_rb_idx = 0; - s->block_type_trees = NULL; - s->block_len_trees = NULL; - - /* Make small negative indexes addressable. */ - s->symbol_lists = &s->symbols_lists_array[BROTLI_HUFFMAN_MAX_CODE_LENGTH + 1]; - + + s->window_bits = 0; + s->max_distance = 0; + s->dist_rb[0] = 16; + s->dist_rb[1] = 15; + s->dist_rb[2] = 11; + s->dist_rb[3] = 4; + s->dist_rb_idx = 0; + s->block_type_trees = NULL; + s->block_len_trees = NULL; + + /* Make small negative indexes addressable. */ + s->symbol_lists = &s->symbols_lists_array[BROTLI_HUFFMAN_MAX_CODE_LENGTH + 1]; + s->mtf_upper_bound = 63; s->dictionary = BrotliGetDictionary(); s->transforms = BrotliGetTransforms(); return BROTLI_TRUE; -} - +} + void BrotliDecoderStateMetablockBegin(BrotliDecoderState* s) { - s->meta_block_remaining_len = 0; + s->meta_block_remaining_len = 0; s->block_length[0] = 1U << 24; s->block_length[1] = 1U << 24; s->block_length[2] = 1U << 24; - s->num_block_types[0] = 1; - s->num_block_types[1] = 1; - s->num_block_types[2] = 1; - s->block_type_rb[0] = 1; - s->block_type_rb[1] = 0; - s->block_type_rb[2] = 1; - s->block_type_rb[3] = 0; - s->block_type_rb[4] = 1; - s->block_type_rb[5] = 0; - s->context_map = NULL; - s->context_modes = NULL; - s->dist_context_map = NULL; - s->context_map_slice = NULL; - s->literal_htree = NULL; - s->dist_context_map_slice = NULL; - s->dist_htree_index = 0; + s->num_block_types[0] = 1; + s->num_block_types[1] = 1; + s->num_block_types[2] = 1; + s->block_type_rb[0] = 1; + s->block_type_rb[1] = 0; + s->block_type_rb[2] = 1; + s->block_type_rb[3] = 0; + s->block_type_rb[4] = 1; + s->block_type_rb[5] = 0; + s->context_map = NULL; + s->context_modes = NULL; + s->dist_context_map = NULL; + s->context_map_slice = NULL; + s->literal_htree = NULL; + s->dist_context_map_slice = NULL; + s->dist_htree_index = 0; s->context_lookup = NULL; - s->literal_hgroup.codes = NULL; - s->literal_hgroup.htrees = NULL; - s->insert_copy_hgroup.codes = NULL; - s->insert_copy_hgroup.htrees = NULL; - s->distance_hgroup.codes = NULL; - s->distance_hgroup.htrees = NULL; -} - + s->literal_hgroup.codes = NULL; + s->literal_hgroup.htrees = NULL; + s->insert_copy_hgroup.codes = NULL; + s->insert_copy_hgroup.htrees = NULL; + s->distance_hgroup.codes = NULL; + s->distance_hgroup.htrees = NULL; +} + void BrotliDecoderStateCleanupAfterMetablock(BrotliDecoderState* s) { BROTLI_DECODER_FREE(s, s->context_modes); BROTLI_DECODER_FREE(s, s->context_map); @@ -132,15 +132,15 @@ void BrotliDecoderStateCleanupAfterMetablock(BrotliDecoderState* s) { BROTLI_DECODER_FREE(s, s->literal_hgroup.htrees); BROTLI_DECODER_FREE(s, s->insert_copy_hgroup.htrees); BROTLI_DECODER_FREE(s, s->distance_hgroup.htrees); -} - +} + void BrotliDecoderStateCleanup(BrotliDecoderState* s) { BrotliDecoderStateCleanupAfterMetablock(s); - + BROTLI_DECODER_FREE(s, s->ringbuffer); BROTLI_DECODER_FREE(s, s->block_type_trees); -} - +} + BROTLI_BOOL BrotliDecoderHuffmanTreeGroupInit(BrotliDecoderState* s, HuffmanTreeGroup* group, uint32_t alphabet_size, uint32_t max_symbol, uint32_t ntrees) { @@ -159,6 +159,6 @@ BROTLI_BOOL BrotliDecoderHuffmanTreeGroupInit(BrotliDecoderState* s, return !!p; } -#if defined(__cplusplus) || defined(c_plusplus) +#if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ -#endif +#endif diff --git a/contrib/libs/brotli/dec/state.h b/contrib/libs/brotli/dec/state.h index b21553ee72..d28b63920e 100644 --- a/contrib/libs/brotli/dec/state.h +++ b/contrib/libs/brotli/dec/state.h @@ -1,110 +1,110 @@ -/* Copyright 2015 Google Inc. All Rights Reserved. - +/* Copyright 2015 Google Inc. All Rights Reserved. + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT -*/ - -/* Brotli state for partial streaming decoding. */ - -#ifndef BROTLI_DEC_STATE_H_ -#define BROTLI_DEC_STATE_H_ - +*/ + +/* Brotli state for partial streaming decoding. */ + +#ifndef BROTLI_DEC_STATE_H_ +#define BROTLI_DEC_STATE_H_ + #include "../common/constants.h" #include "../common/dictionary.h" #include "../common/platform.h" #include "../common/transform.h" #include <brotli/types.h> -#include "./bit_reader.h" -#include "./huffman.h" - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -typedef enum { - BROTLI_STATE_UNINITED, +#include "./bit_reader.h" +#include "./huffman.h" + +#if defined(__cplusplus) || defined(c_plusplus) +extern "C" { +#endif + +typedef enum { + BROTLI_STATE_UNINITED, BROTLI_STATE_LARGE_WINDOW_BITS, BROTLI_STATE_INITIALIZE, - BROTLI_STATE_METABLOCK_BEGIN, - BROTLI_STATE_METABLOCK_HEADER, + BROTLI_STATE_METABLOCK_BEGIN, + BROTLI_STATE_METABLOCK_HEADER, BROTLI_STATE_METABLOCK_HEADER_2, - BROTLI_STATE_CONTEXT_MODES, - BROTLI_STATE_COMMAND_BEGIN, - BROTLI_STATE_COMMAND_INNER, + BROTLI_STATE_CONTEXT_MODES, + BROTLI_STATE_COMMAND_BEGIN, + BROTLI_STATE_COMMAND_INNER, BROTLI_STATE_COMMAND_POST_DECODE_LITERALS, BROTLI_STATE_COMMAND_POST_WRAP_COPY, - BROTLI_STATE_UNCOMPRESSED, - BROTLI_STATE_METADATA, - BROTLI_STATE_COMMAND_INNER_WRITE, - BROTLI_STATE_METABLOCK_DONE, - BROTLI_STATE_COMMAND_POST_WRITE_1, - BROTLI_STATE_COMMAND_POST_WRITE_2, - BROTLI_STATE_HUFFMAN_CODE_0, - BROTLI_STATE_HUFFMAN_CODE_1, - BROTLI_STATE_HUFFMAN_CODE_2, - BROTLI_STATE_HUFFMAN_CODE_3, - BROTLI_STATE_CONTEXT_MAP_1, - BROTLI_STATE_CONTEXT_MAP_2, - BROTLI_STATE_TREE_GROUP, - BROTLI_STATE_DONE -} BrotliRunningState; - -typedef enum { - BROTLI_STATE_METABLOCK_HEADER_NONE, - BROTLI_STATE_METABLOCK_HEADER_EMPTY, - BROTLI_STATE_METABLOCK_HEADER_NIBBLES, - BROTLI_STATE_METABLOCK_HEADER_SIZE, - BROTLI_STATE_METABLOCK_HEADER_UNCOMPRESSED, - BROTLI_STATE_METABLOCK_HEADER_RESERVED, - BROTLI_STATE_METABLOCK_HEADER_BYTES, - BROTLI_STATE_METABLOCK_HEADER_METADATA -} BrotliRunningMetablockHeaderState; - -typedef enum { - BROTLI_STATE_UNCOMPRESSED_NONE, + BROTLI_STATE_UNCOMPRESSED, + BROTLI_STATE_METADATA, + BROTLI_STATE_COMMAND_INNER_WRITE, + BROTLI_STATE_METABLOCK_DONE, + BROTLI_STATE_COMMAND_POST_WRITE_1, + BROTLI_STATE_COMMAND_POST_WRITE_2, + BROTLI_STATE_HUFFMAN_CODE_0, + BROTLI_STATE_HUFFMAN_CODE_1, + BROTLI_STATE_HUFFMAN_CODE_2, + BROTLI_STATE_HUFFMAN_CODE_3, + BROTLI_STATE_CONTEXT_MAP_1, + BROTLI_STATE_CONTEXT_MAP_2, + BROTLI_STATE_TREE_GROUP, + BROTLI_STATE_DONE +} BrotliRunningState; + +typedef enum { + BROTLI_STATE_METABLOCK_HEADER_NONE, + BROTLI_STATE_METABLOCK_HEADER_EMPTY, + BROTLI_STATE_METABLOCK_HEADER_NIBBLES, + BROTLI_STATE_METABLOCK_HEADER_SIZE, + BROTLI_STATE_METABLOCK_HEADER_UNCOMPRESSED, + BROTLI_STATE_METABLOCK_HEADER_RESERVED, + BROTLI_STATE_METABLOCK_HEADER_BYTES, + BROTLI_STATE_METABLOCK_HEADER_METADATA +} BrotliRunningMetablockHeaderState; + +typedef enum { + BROTLI_STATE_UNCOMPRESSED_NONE, BROTLI_STATE_UNCOMPRESSED_WRITE -} BrotliRunningUncompressedState; - -typedef enum { - BROTLI_STATE_TREE_GROUP_NONE, - BROTLI_STATE_TREE_GROUP_LOOP -} BrotliRunningTreeGroupState; - -typedef enum { - BROTLI_STATE_CONTEXT_MAP_NONE, - BROTLI_STATE_CONTEXT_MAP_READ_PREFIX, - BROTLI_STATE_CONTEXT_MAP_HUFFMAN, +} BrotliRunningUncompressedState; + +typedef enum { + BROTLI_STATE_TREE_GROUP_NONE, + BROTLI_STATE_TREE_GROUP_LOOP +} BrotliRunningTreeGroupState; + +typedef enum { + BROTLI_STATE_CONTEXT_MAP_NONE, + BROTLI_STATE_CONTEXT_MAP_READ_PREFIX, + BROTLI_STATE_CONTEXT_MAP_HUFFMAN, BROTLI_STATE_CONTEXT_MAP_DECODE, BROTLI_STATE_CONTEXT_MAP_TRANSFORM -} BrotliRunningContextMapState; - -typedef enum { - BROTLI_STATE_HUFFMAN_NONE, +} BrotliRunningContextMapState; + +typedef enum { + BROTLI_STATE_HUFFMAN_NONE, BROTLI_STATE_HUFFMAN_SIMPLE_SIZE, BROTLI_STATE_HUFFMAN_SIMPLE_READ, BROTLI_STATE_HUFFMAN_SIMPLE_BUILD, BROTLI_STATE_HUFFMAN_COMPLEX, - BROTLI_STATE_HUFFMAN_LENGTH_SYMBOLS -} BrotliRunningHuffmanState; - -typedef enum { - BROTLI_STATE_DECODE_UINT8_NONE, - BROTLI_STATE_DECODE_UINT8_SHORT, - BROTLI_STATE_DECODE_UINT8_LONG -} BrotliRunningDecodeUint8State; - + BROTLI_STATE_HUFFMAN_LENGTH_SYMBOLS +} BrotliRunningHuffmanState; + +typedef enum { + BROTLI_STATE_DECODE_UINT8_NONE, + BROTLI_STATE_DECODE_UINT8_SHORT, + BROTLI_STATE_DECODE_UINT8_LONG +} BrotliRunningDecodeUint8State; + typedef enum { BROTLI_STATE_READ_BLOCK_LENGTH_NONE, BROTLI_STATE_READ_BLOCK_LENGTH_SUFFIX } BrotliRunningReadBlockLengthState; struct BrotliDecoderStateStruct { - BrotliRunningState state; + BrotliRunningState state; - /* This counter is reused for several disjoint loops. */ + /* This counter is reused for several disjoint loops. */ int loop_counter; - BrotliBitReader br; + BrotliBitReader br; brotli_alloc_func alloc_func; brotli_free_func free_func; @@ -117,99 +117,99 @@ struct BrotliDecoderStateStruct { } buffer; uint32_t buffer_length; - int pos; - int max_backward_distance; - int max_distance; - int ringbuffer_size; - int ringbuffer_mask; - int dist_rb_idx; - int dist_rb[4]; + int pos; + int max_backward_distance; + int max_distance; + int ringbuffer_size; + int ringbuffer_mask; + int dist_rb_idx; + int dist_rb[4]; int error_code; uint32_t sub_loop_counter; - uint8_t* ringbuffer; - uint8_t* ringbuffer_end; - HuffmanCode* htree_command; + uint8_t* ringbuffer; + uint8_t* ringbuffer_end; + HuffmanCode* htree_command; const uint8_t* context_lookup; - uint8_t* context_map_slice; - uint8_t* dist_context_map_slice; - + uint8_t* context_map_slice; + uint8_t* dist_context_map_slice; + /* This ring buffer holds a few past copy distances that will be used by some special distance codes. */ - HuffmanTreeGroup literal_hgroup; - HuffmanTreeGroup insert_copy_hgroup; - HuffmanTreeGroup distance_hgroup; - HuffmanCode* block_type_trees; - HuffmanCode* block_len_trees; - /* This is true if the literal context map histogram type always matches the + HuffmanTreeGroup literal_hgroup; + HuffmanTreeGroup insert_copy_hgroup; + HuffmanTreeGroup distance_hgroup; + HuffmanCode* block_type_trees; + HuffmanCode* block_len_trees; + /* This is true if the literal context map histogram type always matches the block type. It is then not needed to keep the context (faster decoding). */ - int trivial_literal_context; + int trivial_literal_context; /* Distance context is actual after command is decoded and before distance is computed. After distance computation it is used as a temporary variable. */ - int distance_context; - int meta_block_remaining_len; + int distance_context; + int meta_block_remaining_len; uint32_t block_length_index; uint32_t block_length[3]; uint32_t num_block_types[3]; uint32_t block_type_rb[6]; uint32_t distance_postfix_bits; uint32_t num_direct_distance_codes; - int distance_postfix_mask; + int distance_postfix_mask; uint32_t num_dist_htrees; - uint8_t* dist_context_map; + uint8_t* dist_context_map; HuffmanCode* literal_htree; - uint8_t dist_htree_index; + uint8_t dist_htree_index; uint32_t repeat_code_len; uint32_t prev_code_len; - - int copy_length; - int distance_code; - + + int copy_length; + int distance_code; + /* For partial write operations. */ size_t rb_roundtrips; /* how many times we went around the ring-buffer */ size_t partial_pos_out; /* how much output to the user in total */ - + /* For ReadHuffmanCode. */ - uint32_t symbol; - uint32_t repeat; - uint32_t space; - - HuffmanCode table[32]; + uint32_t symbol; + uint32_t repeat; + uint32_t space; + + HuffmanCode table[32]; /* List of heads of symbol chains. */ - uint16_t* symbol_lists; - /* Storage from symbol_lists. */ - uint16_t symbols_lists_array[BROTLI_HUFFMAN_MAX_CODE_LENGTH + 1 + + uint16_t* symbol_lists; + /* Storage from symbol_lists. */ + uint16_t symbols_lists_array[BROTLI_HUFFMAN_MAX_CODE_LENGTH + 1 + BROTLI_NUM_COMMAND_SYMBOLS]; - /* Tails of symbol chains. */ - int next_symbol[32]; + /* Tails of symbol chains. */ + int next_symbol[32]; uint8_t code_length_code_lengths[BROTLI_CODE_LENGTH_CODES]; /* Population counts for the code lengths. */ - uint16_t code_length_histo[16]; - + uint16_t code_length_histo[16]; + /* For HuffmanTreeGroupDecode. */ - int htree_index; - HuffmanCode* next; - + int htree_index; + HuffmanCode* next; + /* For DecodeContextMap. */ uint32_t context_index; uint32_t max_run_length_prefix; uint32_t code; HuffmanCode context_map_table[BROTLI_HUFFMAN_MAX_SIZE_272]; - + /* For InverseMoveToFrontTransform. */ uint32_t mtf_upper_bound; uint32_t mtf[64 + 1]; - + /* Less used attributes are at the end of this struct. */ /* States inside function calls. */ - BrotliRunningMetablockHeaderState substate_metablock_header; - BrotliRunningTreeGroupState substate_tree_group; - BrotliRunningContextMapState substate_context_map; - BrotliRunningUncompressedState substate_uncompressed; - BrotliRunningHuffmanState substate_huffman; - BrotliRunningDecodeUint8State substate_decode_uint8; + BrotliRunningMetablockHeaderState substate_metablock_header; + BrotliRunningTreeGroupState substate_tree_group; + BrotliRunningContextMapState substate_context_map; + BrotliRunningUncompressedState substate_uncompressed; + BrotliRunningHuffmanState substate_huffman; + BrotliRunningDecodeUint8State substate_decode_uint8; BrotliRunningReadBlockLengthState substate_read_block_length; - + unsigned int is_last_metablock : 1; unsigned int is_uncompressed : 1; unsigned int is_metadata : 1; @@ -217,20 +217,20 @@ struct BrotliDecoderStateStruct { unsigned int canny_ringbuffer_allocation : 1; unsigned int large_window : 1; unsigned int size_nibbles : 8; - uint32_t window_bits; - + uint32_t window_bits; + int new_ringbuffer_size; - + uint32_t num_literal_htrees; - uint8_t* context_map; - uint8_t* context_modes; + uint8_t* context_map; + uint8_t* context_modes; const BrotliDictionary* dictionary; const BrotliTransforms* transforms; - + uint32_t trivial_literal_contexts[8]; /* 256 bits */ }; - + typedef struct BrotliDecoderStateStruct BrotliDecoderStateInternal; #define BrotliDecoderState BrotliDecoderStateInternal @@ -251,8 +251,8 @@ BROTLI_INTERNAL BROTLI_BOOL BrotliDecoderHuffmanTreeGroupInit( X = NULL; \ } -#if defined(__cplusplus) || defined(c_plusplus) +#if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ -#endif - -#endif /* BROTLI_DEC_STATE_H_ */ +#endif + +#endif /* BROTLI_DEC_STATE_H_ */ diff --git a/contrib/libs/brotli/dec/ya.make b/contrib/libs/brotli/dec/ya.make index c510ee5a5d..0f482f36ed 100644 --- a/contrib/libs/brotli/dec/ya.make +++ b/contrib/libs/brotli/dec/ya.make @@ -1,6 +1,6 @@ -LIBRARY() - -LICENSE(MIT) +LIBRARY() + +LICENSE(MIT) LICENSE_TEXTS(.yandex_meta/licenses.list.txt) @@ -9,22 +9,22 @@ OWNER( g:contrib g:cpp-contrib ) - -NO_UTIL() -NO_COMPILER_WARNINGS() - +NO_UTIL() + +NO_COMPILER_WARNINGS() + ADDINCL(GLOBAL contrib/libs/brotli/include) PEERDIR( contrib/libs/brotli/common ) -SRCS( - bit_reader.c - decode.c - huffman.c - state.c -) - -END() +SRCS( + bit_reader.c + decode.c + huffman.c + state.c +) + +END() diff --git a/contrib/libs/brotli/enc/backward_references.h b/contrib/libs/brotli/enc/backward_references.h index 7b3c04a8ff..3a4146647c 100644 --- a/contrib/libs/brotli/enc/backward_references.h +++ b/contrib/libs/brotli/enc/backward_references.h @@ -1,26 +1,26 @@ /* Copyright 2013 Google Inc. All Rights Reserved. - + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ /* Function to find backward reference copies. */ -#ifndef BROTLI_ENC_BACKWARD_REFERENCES_H_ -#define BROTLI_ENC_BACKWARD_REFERENCES_H_ - +#ifndef BROTLI_ENC_BACKWARD_REFERENCES_H_ +#define BROTLI_ENC_BACKWARD_REFERENCES_H_ + #include "../common/constants.h" #include "../common/dictionary.h" #include "../common/platform.h" #include <brotli/types.h> #include "./command.h" -#include "./hash.h" +#include "./hash.h" #include "./quality.h" - + #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif - + /* "commands" points to the next output command to write to, "*num_commands" is initially the total amount of commands output by previous CreateBackwardReferences calls, and must be incremented by the amount written @@ -30,9 +30,9 @@ BROTLI_INTERNAL void BrotliCreateBackwardReferences( size_t ringbuffer_mask, const BrotliEncoderParams* params, HasherHandle hasher, int* dist_cache, size_t* last_insert_len, Command* commands, size_t* num_commands, size_t* num_literals); - + #if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ #endif - + #endif /* BROTLI_ENC_BACKWARD_REFERENCES_H_ */ diff --git a/contrib/libs/brotli/enc/bit_cost.h b/contrib/libs/brotli/enc/bit_cost.h index 30324d38c7..6586469e62 100644 --- a/contrib/libs/brotli/enc/bit_cost.h +++ b/contrib/libs/brotli/enc/bit_cost.h @@ -1,63 +1,63 @@ /* Copyright 2013 Google Inc. All Rights Reserved. - + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ /* Functions to estimate the bit cost of Huffman trees. */ -#ifndef BROTLI_ENC_BIT_COST_H_ -#define BROTLI_ENC_BIT_COST_H_ - +#ifndef BROTLI_ENC_BIT_COST_H_ +#define BROTLI_ENC_BIT_COST_H_ + #include "../common/platform.h" #include <brotli/types.h> -#include "./fast_log.h" +#include "./fast_log.h" #include "./histogram.h" - + #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif - + static BROTLI_INLINE double ShannonEntropy( const uint32_t* population, size_t size, size_t* total) { size_t sum = 0; - double retval = 0; + double retval = 0; const uint32_t* population_end = population + size; size_t p; - if (size & 1) { - goto odd_number_of_elements_left; - } - while (population < population_end) { - p = *population++; - sum += p; + if (size & 1) { + goto odd_number_of_elements_left; + } + while (population < population_end) { + p = *population++; + sum += p; retval -= (double)p * FastLog2(p); - odd_number_of_elements_left: - p = *population++; - sum += p; + odd_number_of_elements_left: + p = *population++; + sum += p; retval -= (double)p * FastLog2(p); - } + } if (sum) retval += (double)sum * FastLog2(sum); - *total = sum; - return retval; -} - + *total = sum; + return retval; +} + static BROTLI_INLINE double BitsEntropy( const uint32_t* population, size_t size) { size_t sum; - double retval = ShannonEntropy(population, size, &sum); - if (retval < sum) { + double retval = ShannonEntropy(population, size, &sum); + if (retval < sum) { /* At least one bit per literal is needed. */ retval = (double)sum; - } - return retval; -} - + } + return retval; +} + BROTLI_INTERNAL double BrotliPopulationCostLiteral(const HistogramLiteral*); BROTLI_INTERNAL double BrotliPopulationCostCommand(const HistogramCommand*); BROTLI_INTERNAL double BrotliPopulationCostDistance(const HistogramDistance*); - + #if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ #endif - + #endif /* BROTLI_ENC_BIT_COST_H_ */ diff --git a/contrib/libs/brotli/enc/block_splitter.h b/contrib/libs/brotli/enc/block_splitter.h index 2fd1cb417a..a5e006c4b3 100644 --- a/contrib/libs/brotli/enc/block_splitter.h +++ b/contrib/libs/brotli/enc/block_splitter.h @@ -1,38 +1,38 @@ /* Copyright 2013 Google Inc. All Rights Reserved. - + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ /* Block split point selection utilities. */ -#ifndef BROTLI_ENC_BLOCK_SPLITTER_H_ -#define BROTLI_ENC_BLOCK_SPLITTER_H_ - +#ifndef BROTLI_ENC_BLOCK_SPLITTER_H_ +#define BROTLI_ENC_BLOCK_SPLITTER_H_ + #include "../common/platform.h" #include <brotli/types.h> -#include "./command.h" +#include "./command.h" #include "./memory.h" #include "./quality.h" - + #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif - + typedef struct BlockSplit { size_t num_types; /* Amount of distinct types */ size_t num_blocks; /* Amount of values in types and length */ uint8_t* types; uint32_t* lengths; - + size_t types_alloc_size; size_t lengths_alloc_size; } BlockSplit; - + BROTLI_INTERNAL void BrotliInitBlockSplit(BlockSplit* self); BROTLI_INTERNAL void BrotliDestroyBlockSplit(MemoryManager* m, BlockSplit* self); - + BROTLI_INTERNAL void BrotliSplitBlock(MemoryManager* m, const Command* cmds, const size_t num_commands, @@ -43,9 +43,9 @@ BROTLI_INTERNAL void BrotliSplitBlock(MemoryManager* m, BlockSplit* literal_split, BlockSplit* insert_and_copy_split, BlockSplit* dist_split); - + #if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ #endif - + #endif /* BROTLI_ENC_BLOCK_SPLITTER_H_ */ diff --git a/contrib/libs/brotli/enc/brotli_bit_stream.h b/contrib/libs/brotli/enc/brotli_bit_stream.h index 42663c6704..2ed703bf79 100644 --- a/contrib/libs/brotli/enc/brotli_bit_stream.h +++ b/contrib/libs/brotli/enc/brotli_bit_stream.h @@ -1,5 +1,5 @@ /* Copyright 2014 Google Inc. All Rights Reserved. - + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ @@ -13,32 +13,32 @@ is called "storage" and the index to the bit is called storage_ix in function arguments. */ -#ifndef BROTLI_ENC_BROTLI_BIT_STREAM_H_ -#define BROTLI_ENC_BROTLI_BIT_STREAM_H_ - +#ifndef BROTLI_ENC_BROTLI_BIT_STREAM_H_ +#define BROTLI_ENC_BROTLI_BIT_STREAM_H_ + #include "../common/context.h" #include "../common/platform.h" #include <brotli/types.h> #include "./command.h" #include "./entropy_encode.h" #include "./memory.h" -#include "./metablock.h" - +#include "./metablock.h" + #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif - + /* All Store functions here will use a storage_ix, which is always the bit position for the current storage. */ - + BROTLI_INTERNAL void BrotliStoreHuffmanTree(const uint8_t* depths, size_t num, HuffmanTree* tree, size_t* storage_ix, uint8_t* storage); - + BROTLI_INTERNAL void BrotliBuildAndStoreHuffmanTreeFast( MemoryManager* m, const uint32_t* histogram, const size_t histogram_total, const size_t max_bits, uint8_t* depth, uint16_t* bits, size_t* storage_ix, uint8_t* storage); - + /* REQUIRES: length > 0 */ /* REQUIRES: length <= (1 << 24) */ BROTLI_INTERNAL void BrotliStoreMetaBlock(MemoryManager* m, @@ -47,7 +47,7 @@ BROTLI_INTERNAL void BrotliStoreMetaBlock(MemoryManager* m, const BrotliEncoderParams* params, ContextType literal_context_mode, const Command* commands, size_t n_commands, const MetaBlockSplit* mb, size_t* storage_ix, uint8_t* storage); - + /* Stores the meta-block without doing any block splitting, just collects one histogram per block category and uses that for entropy coding. REQUIRES: length > 0 @@ -57,7 +57,7 @@ BROTLI_INTERNAL void BrotliStoreMetaBlockTrivial(MemoryManager* m, BROTLI_BOOL is_last, const BrotliEncoderParams* params, const Command* commands, size_t n_commands, size_t* storage_ix, uint8_t* storage); - + /* Same as above, but uses static prefix codes for histograms with a only a few symbols, and uses static code length prefix codes for all other histograms. REQUIRES: length > 0 @@ -67,7 +67,7 @@ BROTLI_INTERNAL void BrotliStoreMetaBlockFast(MemoryManager* m, BROTLI_BOOL is_last, const BrotliEncoderParams* params, const Command* commands, size_t n_commands, size_t* storage_ix, uint8_t* storage); - + /* This is for storing uncompressed blocks (simple raw storage of bytes-as-bytes). REQUIRES: length > 0 @@ -76,9 +76,9 @@ BROTLI_INTERNAL void BrotliStoreUncompressedMetaBlock( BROTLI_BOOL is_final_block, const uint8_t* BROTLI_RESTRICT input, size_t position, size_t mask, size_t len, size_t* BROTLI_RESTRICT storage_ix, uint8_t* BROTLI_RESTRICT storage); - + #if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ #endif - + #endif /* BROTLI_ENC_BROTLI_BIT_STREAM_H_ */ diff --git a/contrib/libs/brotli/enc/cluster.h b/contrib/libs/brotli/enc/cluster.h index daf573dc65..bb26124d24 100644 --- a/contrib/libs/brotli/enc/cluster.h +++ b/contrib/libs/brotli/enc/cluster.h @@ -1,48 +1,48 @@ /* Copyright 2013 Google Inc. All Rights Reserved. - + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ /* Functions for clustering similar histograms together. */ -#ifndef BROTLI_ENC_CLUSTER_H_ -#define BROTLI_ENC_CLUSTER_H_ - +#ifndef BROTLI_ENC_CLUSTER_H_ +#define BROTLI_ENC_CLUSTER_H_ + #include "../common/platform.h" #include <brotli/types.h> -#include "./histogram.h" +#include "./histogram.h" #include "./memory.h" - + #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif - + typedef struct HistogramPair { uint32_t idx1; uint32_t idx2; - double cost_combo; - double cost_diff; + double cost_combo; + double cost_diff; } HistogramPair; - + #define CODE(X) /* Declaration */; - + #define FN(X) X ## Literal #include "./cluster_inc.h" /* NOLINT(build/include) */ #undef FN - + #define FN(X) X ## Command #include "./cluster_inc.h" /* NOLINT(build/include) */ #undef FN - + #define FN(X) X ## Distance #include "./cluster_inc.h" /* NOLINT(build/include) */ #undef FN - + #undef CODE - + #if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ #endif - + #endif /* BROTLI_ENC_CLUSTER_H_ */ diff --git a/contrib/libs/brotli/enc/command.h b/contrib/libs/brotli/enc/command.h index 181510cd67..1aac85689b 100644 --- a/contrib/libs/brotli/enc/command.h +++ b/contrib/libs/brotli/enc/command.h @@ -1,25 +1,25 @@ /* Copyright 2013 Google Inc. All Rights Reserved. - + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ /* This class models a sequence of literals and a backward reference copy. */ -#ifndef BROTLI_ENC_COMMAND_H_ -#define BROTLI_ENC_COMMAND_H_ - +#ifndef BROTLI_ENC_COMMAND_H_ +#define BROTLI_ENC_COMMAND_H_ + #include "../common/constants.h" #include "../common/platform.h" #include <brotli/types.h> -#include "./fast_log.h" +#include "./fast_log.h" #include "./params.h" -#include "./prefix.h" - +#include "./prefix.h" + #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif - + static uint32_t kInsBase[] = { 0, 1, 2, 3, 4, 5, 6, 8, 10, 14, 18, 26, 34, 50, 66, 98, 130, 194, 322, 578, 1090, 2114, 6210, 22594 }; static uint32_t kInsExtra[] = { 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, @@ -28,44 +28,44 @@ static uint32_t kCopyBase[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 18, 22, 30, 38, 54, 70, 102, 134, 198, 326, 582, 1094, 2118 }; static uint32_t kCopyExtra[] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10, 24 }; - + static BROTLI_INLINE uint16_t GetInsertLengthCode(size_t insertlen) { - if (insertlen < 6) { + if (insertlen < 6) { return (uint16_t)insertlen; - } else if (insertlen < 130) { + } else if (insertlen < 130) { uint32_t nbits = Log2FloorNonZero(insertlen - 2) - 1u; return (uint16_t)((nbits << 1) + ((insertlen - 2) >> nbits) + 2); - } else if (insertlen < 2114) { + } else if (insertlen < 2114) { return (uint16_t)(Log2FloorNonZero(insertlen - 66) + 10); - } else if (insertlen < 6210) { + } else if (insertlen < 6210) { return 21u; - } else if (insertlen < 22594) { + } else if (insertlen < 22594) { return 22u; - } else { + } else { return 23u; - } -} - + } +} + static BROTLI_INLINE uint16_t GetCopyLengthCode(size_t copylen) { - if (copylen < 10) { + if (copylen < 10) { return (uint16_t)(copylen - 2); - } else if (copylen < 134) { + } else if (copylen < 134) { uint32_t nbits = Log2FloorNonZero(copylen - 6) - 1u; return (uint16_t)((nbits << 1) + ((copylen - 6) >> nbits) + 4); - } else if (copylen < 2118) { + } else if (copylen < 2118) { return (uint16_t)(Log2FloorNonZero(copylen - 70) + 12); - } else { + } else { return 23u; - } -} - + } +} + static BROTLI_INLINE uint16_t CombineLengthCodes( uint16_t inscode, uint16_t copycode, BROTLI_BOOL use_last_distance) { uint16_t bits64 = (uint16_t)((copycode & 0x7u) | ((inscode & 0x7u) << 3u)); if (use_last_distance && inscode < 8u && copycode < 16u) { return (copycode < 8u) ? bits64 : (bits64 | 64u); - } else { + } else { /* Specification: 5 Encoding of ... (last table) */ /* offset = 2 * index, where index is in range [0..8] */ uint32_t offset = 2u * ((copycode >> 3u) + 3u * (inscode >> 3u)); @@ -77,29 +77,29 @@ static BROTLI_INLINE uint16_t CombineLengthCodes( Magic constant is shifted 6 bits left, to avoid final multiplication. */ offset = (offset << 5u) + 0x40u + ((0x520D40u >> offset) & 0xC0u); return (uint16_t)(offset | bits64); - } -} - + } +} + static BROTLI_INLINE void GetLengthCode(size_t insertlen, size_t copylen, BROTLI_BOOL use_last_distance, uint16_t* code) { uint16_t inscode = GetInsertLengthCode(insertlen); uint16_t copycode = GetCopyLengthCode(copylen); *code = CombineLengthCodes(inscode, copycode, use_last_distance); -} - +} + static BROTLI_INLINE uint32_t GetInsertBase(uint16_t inscode) { return kInsBase[inscode]; } - + static BROTLI_INLINE uint32_t GetInsertExtra(uint16_t inscode) { return kInsExtra[inscode]; } - + static BROTLI_INLINE uint32_t GetCopyBase(uint16_t copycode) { return kCopyBase[copycode]; } - + static BROTLI_INLINE uint32_t GetCopyExtra(uint16_t copycode) { return kCopyExtra[copycode]; } @@ -161,28 +161,28 @@ static BROTLI_INLINE uint32_t CommandRestoreDistanceCode( uint32_t offset = ((2U + (hcode & 1U)) << nbits) - 4U; return ((offset + extra) << dist->distance_postfix_bits) + lcode + dist->num_direct_distance_codes + BROTLI_NUM_DISTANCE_SHORT_CODES; - } + } } - + static BROTLI_INLINE uint32_t CommandDistanceContext(const Command* self) { uint32_t r = self->cmd_prefix_ >> 6; uint32_t c = self->cmd_prefix_ & 7; if ((r == 0 || r == 2 || r == 4 || r == 7) && (c <= 2)) { return c; - } + } return 3; } - + static BROTLI_INLINE uint32_t CommandCopyLen(const Command* self) { return self->copy_len_ & 0x1FFFFFF; } - + static BROTLI_INLINE uint32_t CommandCopyLenCode(const Command* self) { uint32_t modifier = self->copy_len_ >> 25; int32_t delta = (int8_t)((uint8_t)(modifier | ((modifier & 0x40) << 1))); return (uint32_t)((int32_t)(self->copy_len_ & 0x1FFFFFF) + delta); } - + #if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ #endif diff --git a/contrib/libs/brotli/enc/dictionary_hash.h b/contrib/libs/brotli/enc/dictionary_hash.h index a7fafbe065..b3bb9599f4 100644 --- a/contrib/libs/brotli/enc/dictionary_hash.h +++ b/contrib/libs/brotli/enc/dictionary_hash.h @@ -1,24 +1,24 @@ /* Copyright 2015 Google Inc. All Rights Reserved. - + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ /* Hash table on the 4-byte prefixes of static dictionary words. */ -#ifndef BROTLI_ENC_DICTIONARY_HASH_H_ -#define BROTLI_ENC_DICTIONARY_HASH_H_ - +#ifndef BROTLI_ENC_DICTIONARY_HASH_H_ +#define BROTLI_ENC_DICTIONARY_HASH_H_ + #include <brotli/types.h> - + #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif - + extern const uint16_t kStaticDictionaryHash[32768]; - + #if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ #endif - + #endif /* BROTLI_ENC_DICTIONARY_HASH_H_ */ diff --git a/contrib/libs/brotli/enc/entropy_encode.h b/contrib/libs/brotli/enc/entropy_encode.h index b1f02d5a35..f23d9c379d 100644 --- a/contrib/libs/brotli/enc/entropy_encode.h +++ b/contrib/libs/brotli/enc/entropy_encode.h @@ -1,57 +1,57 @@ /* Copyright 2010 Google Inc. All Rights Reserved. - + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ /* Entropy encoding (Huffman) utilities. */ -#ifndef BROTLI_ENC_ENTROPY_ENCODE_H_ -#define BROTLI_ENC_ENTROPY_ENCODE_H_ - +#ifndef BROTLI_ENC_ENTROPY_ENCODE_H_ +#define BROTLI_ENC_ENTROPY_ENCODE_H_ + #include "../common/platform.h" #include <brotli/types.h> - + #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif - + /* A node of a Huffman tree. */ typedef struct HuffmanTree { uint32_t total_count_; int16_t index_left_; int16_t index_right_or_value_; } HuffmanTree; - + static BROTLI_INLINE void InitHuffmanTree(HuffmanTree* self, uint32_t count, int16_t left, int16_t right) { self->total_count_ = count; self->index_left_ = left; self->index_right_or_value_ = right; } - + /* Returns 1 is assignment of depths succeeded, otherwise 0. */ BROTLI_INTERNAL BROTLI_BOOL BrotliSetDepth( int p, HuffmanTree* pool, uint8_t* depth, int max_depth); - + /* This function will create a Huffman tree. - + The (data,length) contains the population counts. The tree_limit is the maximum bit depth of the Huffman codes. - + The depth contains the tree, i.e., how many bits are used for the symbol. - + The actual Huffman tree is constructed in the tree[] array, which has to be at least 2 * length + 1 long. - + See http://en.wikipedia.org/wiki/Huffman_coding */ BROTLI_INTERNAL void BrotliCreateHuffmanTree(const uint32_t* data, const size_t length, const int tree_limit, HuffmanTree* tree, uint8_t* depth); - + /* Change the population counts in a way that the consequent Huffman tree compression, especially its RLE-part will be more likely to compress this data more efficiently. diff --git a/contrib/libs/brotli/enc/fast_log.h b/contrib/libs/brotli/enc/fast_log.h index 7b5d067de6..cade1235ad 100644 --- a/contrib/libs/brotli/enc/fast_log.h +++ b/contrib/libs/brotli/enc/fast_log.h @@ -1,147 +1,147 @@ /* Copyright 2013 Google Inc. All Rights Reserved. - + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ /* Utilities for fast computation of logarithms. */ -#ifndef BROTLI_ENC_FAST_LOG_H_ -#define BROTLI_ENC_FAST_LOG_H_ - -#include <math.h> - +#ifndef BROTLI_ENC_FAST_LOG_H_ +#define BROTLI_ENC_FAST_LOG_H_ + +#include <math.h> + #include "../common/platform.h" #include <brotli/types.h> - + #if defined(__cplusplus) || defined(c_plusplus) extern "C" { -#endif - +#endif + static BROTLI_INLINE uint32_t Log2FloorNonZero(size_t n) { /* TODO: generalize and move to platform.h */ #if BROTLI_GNUC_HAS_BUILTIN(__builtin_clz, 3, 4, 0) || \ BROTLI_INTEL_VERSION_CHECK(16, 0, 0) return 31u ^ (uint32_t)__builtin_clz((uint32_t)n); -#else +#else uint32_t result = 0; - while (n >>= 1) result++; - return result; -#endif -} - + while (n >>= 1) result++; + return result; +#endif +} + /* A lookup table for small values of log2(int) to be used in entropy computation. - + ", ".join(["%.16ff" % x for x in [0.0]+[log2(x) for x in range(1, 256)]]) */ -static const float kLog2Table[] = { - 0.0000000000000000f, 0.0000000000000000f, 1.0000000000000000f, - 1.5849625007211563f, 2.0000000000000000f, 2.3219280948873622f, - 2.5849625007211561f, 2.8073549220576042f, 3.0000000000000000f, - 3.1699250014423126f, 3.3219280948873626f, 3.4594316186372978f, - 3.5849625007211565f, 3.7004397181410922f, 3.8073549220576037f, - 3.9068905956085187f, 4.0000000000000000f, 4.0874628412503400f, - 4.1699250014423122f, 4.2479275134435852f, 4.3219280948873626f, - 4.3923174227787607f, 4.4594316186372973f, 4.5235619560570131f, - 4.5849625007211570f, 4.6438561897747244f, 4.7004397181410926f, - 4.7548875021634691f, 4.8073549220576037f, 4.8579809951275728f, - 4.9068905956085187f, 4.9541963103868758f, 5.0000000000000000f, - 5.0443941193584534f, 5.0874628412503400f, 5.1292830169449664f, - 5.1699250014423122f, 5.2094533656289501f, 5.2479275134435852f, - 5.2854022188622487f, 5.3219280948873626f, 5.3575520046180838f, - 5.3923174227787607f, 5.4262647547020979f, 5.4594316186372973f, - 5.4918530963296748f, 5.5235619560570131f, 5.5545888516776376f, - 5.5849625007211570f, 5.6147098441152083f, 5.6438561897747244f, - 5.6724253419714961f, 5.7004397181410926f, 5.7279204545631996f, - 5.7548875021634691f, 5.7813597135246599f, 5.8073549220576046f, - 5.8328900141647422f, 5.8579809951275719f, 5.8826430493618416f, - 5.9068905956085187f, 5.9307373375628867f, 5.9541963103868758f, - 5.9772799234999168f, 6.0000000000000000f, 6.0223678130284544f, - 6.0443941193584534f, 6.0660891904577721f, 6.0874628412503400f, - 6.1085244567781700f, 6.1292830169449672f, 6.1497471195046822f, - 6.1699250014423122f, 6.1898245588800176f, 6.2094533656289510f, - 6.2288186904958804f, 6.2479275134435861f, 6.2667865406949019f, - 6.2854022188622487f, 6.3037807481771031f, 6.3219280948873617f, - 6.3398500028846252f, 6.3575520046180847f, 6.3750394313469254f, - 6.3923174227787598f, 6.4093909361377026f, 6.4262647547020979f, - 6.4429434958487288f, 6.4594316186372982f, 6.4757334309663976f, - 6.4918530963296748f, 6.5077946401986964f, 6.5235619560570131f, - 6.5391588111080319f, 6.5545888516776376f, 6.5698556083309478f, - 6.5849625007211561f, 6.5999128421871278f, 6.6147098441152092f, - 6.6293566200796095f, 6.6438561897747253f, 6.6582114827517955f, - 6.6724253419714952f, 6.6865005271832185f, 6.7004397181410917f, - 6.7142455176661224f, 6.7279204545631988f, 6.7414669864011465f, - 6.7548875021634691f, 6.7681843247769260f, 6.7813597135246599f, - 6.7944158663501062f, 6.8073549220576037f, 6.8201789624151887f, - 6.8328900141647422f, 6.8454900509443757f, 6.8579809951275719f, - 6.8703647195834048f, 6.8826430493618416f, 6.8948177633079437f, - 6.9068905956085187f, 6.9188632372745955f, 6.9307373375628867f, - 6.9425145053392399f, 6.9541963103868758f, 6.9657842846620879f, - 6.9772799234999168f, 6.9886846867721664f, 7.0000000000000000f, - 7.0112272554232540f, 7.0223678130284544f, 7.0334230015374501f, - 7.0443941193584534f, 7.0552824355011898f, 7.0660891904577721f, - 7.0768155970508317f, 7.0874628412503400f, 7.0980320829605272f, - 7.1085244567781700f, 7.1189410727235076f, 7.1292830169449664f, - 7.1395513523987937f, 7.1497471195046822f, 7.1598713367783891f, - 7.1699250014423130f, 7.1799090900149345f, 7.1898245588800176f, - 7.1996723448363644f, 7.2094533656289492f, 7.2191685204621621f, - 7.2288186904958804f, 7.2384047393250794f, 7.2479275134435861f, - 7.2573878426926521f, 7.2667865406949019f, 7.2761244052742384f, - 7.2854022188622487f, 7.2946207488916270f, 7.3037807481771031f, - 7.3128829552843557f, 7.3219280948873617f, 7.3309168781146177f, - 7.3398500028846243f, 7.3487281542310781f, 7.3575520046180847f, - 7.3663222142458151f, 7.3750394313469254f, 7.3837042924740528f, - 7.3923174227787607f, 7.4008794362821844f, 7.4093909361377026f, - 7.4178525148858991f, 7.4262647547020979f, 7.4346282276367255f, - 7.4429434958487288f, 7.4512111118323299f, 7.4594316186372973f, - 7.4676055500829976f, 7.4757334309663976f, 7.4838157772642564f, - 7.4918530963296748f, 7.4998458870832057f, 7.5077946401986964f, - 7.5156998382840436f, 7.5235619560570131f, 7.5313814605163119f, - 7.5391588111080319f, 7.5468944598876373f, 7.5545888516776376f, - 7.5622424242210728f, 7.5698556083309478f, 7.5774288280357487f, - 7.5849625007211561f, 7.5924570372680806f, 7.5999128421871278f, - 7.6073303137496113f, 7.6147098441152075f, 7.6220518194563764f, - 7.6293566200796095f, 7.6366246205436488f, 7.6438561897747244f, - 7.6510516911789290f, 7.6582114827517955f, 7.6653359171851765f, - 7.6724253419714952f, 7.6794800995054464f, 7.6865005271832185f, - 7.6934869574993252f, 7.7004397181410926f, 7.7073591320808825f, - 7.7142455176661224f, 7.7210991887071856f, 7.7279204545631996f, - 7.7347096202258392f, 7.7414669864011465f, 7.7481928495894596f, - 7.7548875021634691f, 7.7615512324444795f, 7.7681843247769260f, - 7.7747870596011737f, 7.7813597135246608f, 7.7879025593914317f, - 7.7944158663501062f, 7.8008998999203047f, 7.8073549220576037f, - 7.8137811912170374f, 7.8201789624151887f, 7.8265484872909159f, - 7.8328900141647422f, 7.8392037880969445f, 7.8454900509443757f, - 7.8517490414160571f, 7.8579809951275719f, 7.8641861446542798f, - 7.8703647195834048f, 7.8765169465650002f, 7.8826430493618425f, - 7.8887432488982601f, 7.8948177633079446f, 7.9008668079807496f, - 7.9068905956085187f, 7.9128893362299619f, 7.9188632372745955f, - 7.9248125036057813f, 7.9307373375628867f, 7.9366379390025719f, - 7.9425145053392399f, 7.9483672315846778f, 7.9541963103868758f, - 7.9600019320680806f, 7.9657842846620870f, 7.9715435539507720f, - 7.9772799234999168f, 7.9829935746943104f, 7.9886846867721664f, - 7.9943534368588578f -}; - +static const float kLog2Table[] = { + 0.0000000000000000f, 0.0000000000000000f, 1.0000000000000000f, + 1.5849625007211563f, 2.0000000000000000f, 2.3219280948873622f, + 2.5849625007211561f, 2.8073549220576042f, 3.0000000000000000f, + 3.1699250014423126f, 3.3219280948873626f, 3.4594316186372978f, + 3.5849625007211565f, 3.7004397181410922f, 3.8073549220576037f, + 3.9068905956085187f, 4.0000000000000000f, 4.0874628412503400f, + 4.1699250014423122f, 4.2479275134435852f, 4.3219280948873626f, + 4.3923174227787607f, 4.4594316186372973f, 4.5235619560570131f, + 4.5849625007211570f, 4.6438561897747244f, 4.7004397181410926f, + 4.7548875021634691f, 4.8073549220576037f, 4.8579809951275728f, + 4.9068905956085187f, 4.9541963103868758f, 5.0000000000000000f, + 5.0443941193584534f, 5.0874628412503400f, 5.1292830169449664f, + 5.1699250014423122f, 5.2094533656289501f, 5.2479275134435852f, + 5.2854022188622487f, 5.3219280948873626f, 5.3575520046180838f, + 5.3923174227787607f, 5.4262647547020979f, 5.4594316186372973f, + 5.4918530963296748f, 5.5235619560570131f, 5.5545888516776376f, + 5.5849625007211570f, 5.6147098441152083f, 5.6438561897747244f, + 5.6724253419714961f, 5.7004397181410926f, 5.7279204545631996f, + 5.7548875021634691f, 5.7813597135246599f, 5.8073549220576046f, + 5.8328900141647422f, 5.8579809951275719f, 5.8826430493618416f, + 5.9068905956085187f, 5.9307373375628867f, 5.9541963103868758f, + 5.9772799234999168f, 6.0000000000000000f, 6.0223678130284544f, + 6.0443941193584534f, 6.0660891904577721f, 6.0874628412503400f, + 6.1085244567781700f, 6.1292830169449672f, 6.1497471195046822f, + 6.1699250014423122f, 6.1898245588800176f, 6.2094533656289510f, + 6.2288186904958804f, 6.2479275134435861f, 6.2667865406949019f, + 6.2854022188622487f, 6.3037807481771031f, 6.3219280948873617f, + 6.3398500028846252f, 6.3575520046180847f, 6.3750394313469254f, + 6.3923174227787598f, 6.4093909361377026f, 6.4262647547020979f, + 6.4429434958487288f, 6.4594316186372982f, 6.4757334309663976f, + 6.4918530963296748f, 6.5077946401986964f, 6.5235619560570131f, + 6.5391588111080319f, 6.5545888516776376f, 6.5698556083309478f, + 6.5849625007211561f, 6.5999128421871278f, 6.6147098441152092f, + 6.6293566200796095f, 6.6438561897747253f, 6.6582114827517955f, + 6.6724253419714952f, 6.6865005271832185f, 6.7004397181410917f, + 6.7142455176661224f, 6.7279204545631988f, 6.7414669864011465f, + 6.7548875021634691f, 6.7681843247769260f, 6.7813597135246599f, + 6.7944158663501062f, 6.8073549220576037f, 6.8201789624151887f, + 6.8328900141647422f, 6.8454900509443757f, 6.8579809951275719f, + 6.8703647195834048f, 6.8826430493618416f, 6.8948177633079437f, + 6.9068905956085187f, 6.9188632372745955f, 6.9307373375628867f, + 6.9425145053392399f, 6.9541963103868758f, 6.9657842846620879f, + 6.9772799234999168f, 6.9886846867721664f, 7.0000000000000000f, + 7.0112272554232540f, 7.0223678130284544f, 7.0334230015374501f, + 7.0443941193584534f, 7.0552824355011898f, 7.0660891904577721f, + 7.0768155970508317f, 7.0874628412503400f, 7.0980320829605272f, + 7.1085244567781700f, 7.1189410727235076f, 7.1292830169449664f, + 7.1395513523987937f, 7.1497471195046822f, 7.1598713367783891f, + 7.1699250014423130f, 7.1799090900149345f, 7.1898245588800176f, + 7.1996723448363644f, 7.2094533656289492f, 7.2191685204621621f, + 7.2288186904958804f, 7.2384047393250794f, 7.2479275134435861f, + 7.2573878426926521f, 7.2667865406949019f, 7.2761244052742384f, + 7.2854022188622487f, 7.2946207488916270f, 7.3037807481771031f, + 7.3128829552843557f, 7.3219280948873617f, 7.3309168781146177f, + 7.3398500028846243f, 7.3487281542310781f, 7.3575520046180847f, + 7.3663222142458151f, 7.3750394313469254f, 7.3837042924740528f, + 7.3923174227787607f, 7.4008794362821844f, 7.4093909361377026f, + 7.4178525148858991f, 7.4262647547020979f, 7.4346282276367255f, + 7.4429434958487288f, 7.4512111118323299f, 7.4594316186372973f, + 7.4676055500829976f, 7.4757334309663976f, 7.4838157772642564f, + 7.4918530963296748f, 7.4998458870832057f, 7.5077946401986964f, + 7.5156998382840436f, 7.5235619560570131f, 7.5313814605163119f, + 7.5391588111080319f, 7.5468944598876373f, 7.5545888516776376f, + 7.5622424242210728f, 7.5698556083309478f, 7.5774288280357487f, + 7.5849625007211561f, 7.5924570372680806f, 7.5999128421871278f, + 7.6073303137496113f, 7.6147098441152075f, 7.6220518194563764f, + 7.6293566200796095f, 7.6366246205436488f, 7.6438561897747244f, + 7.6510516911789290f, 7.6582114827517955f, 7.6653359171851765f, + 7.6724253419714952f, 7.6794800995054464f, 7.6865005271832185f, + 7.6934869574993252f, 7.7004397181410926f, 7.7073591320808825f, + 7.7142455176661224f, 7.7210991887071856f, 7.7279204545631996f, + 7.7347096202258392f, 7.7414669864011465f, 7.7481928495894596f, + 7.7548875021634691f, 7.7615512324444795f, 7.7681843247769260f, + 7.7747870596011737f, 7.7813597135246608f, 7.7879025593914317f, + 7.7944158663501062f, 7.8008998999203047f, 7.8073549220576037f, + 7.8137811912170374f, 7.8201789624151887f, 7.8265484872909159f, + 7.8328900141647422f, 7.8392037880969445f, 7.8454900509443757f, + 7.8517490414160571f, 7.8579809951275719f, 7.8641861446542798f, + 7.8703647195834048f, 7.8765169465650002f, 7.8826430493618425f, + 7.8887432488982601f, 7.8948177633079446f, 7.9008668079807496f, + 7.9068905956085187f, 7.9128893362299619f, 7.9188632372745955f, + 7.9248125036057813f, 7.9307373375628867f, 7.9366379390025719f, + 7.9425145053392399f, 7.9483672315846778f, 7.9541963103868758f, + 7.9600019320680806f, 7.9657842846620870f, 7.9715435539507720f, + 7.9772799234999168f, 7.9829935746943104f, 7.9886846867721664f, + 7.9943534368588578f +}; + #define LOG_2_INV 1.4426950408889634 /* Faster logarithm for small integers, with the property of log2(0) == 0. */ static BROTLI_INLINE double FastLog2(size_t v) { if (v < sizeof(kLog2Table) / sizeof(kLog2Table[0])) { - return kLog2Table[v]; - } + return kLog2Table[v]; + } #if (defined(_MSC_VER) && _MSC_VER <= 1700) || \ (defined(__ANDROID_API__) && __ANDROID_API__ < 18) /* Visual Studio 2012 and Android API levels < 18 do not have the log2() * function defined, so we use log() and a multiplication instead. */ return log((double)v) * LOG_2_INV; -#else +#else return log2((double)v); -#endif -} - +#endif +} + #if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ #endif - + #endif /* BROTLI_ENC_FAST_LOG_H_ */ diff --git a/contrib/libs/brotli/enc/find_match_length.h b/contrib/libs/brotli/enc/find_match_length.h index 5dd2bbb52e..bc428cffda 100644 --- a/contrib/libs/brotli/enc/find_match_length.h +++ b/contrib/libs/brotli/enc/find_match_length.h @@ -1,24 +1,24 @@ /* Copyright 2010 Google Inc. All Rights Reserved. - + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ /* Function to find maximal matching prefixes of strings. */ -#ifndef BROTLI_ENC_FIND_MATCH_LENGTH_H_ -#define BROTLI_ENC_FIND_MATCH_LENGTH_H_ - +#ifndef BROTLI_ENC_FIND_MATCH_LENGTH_H_ +#define BROTLI_ENC_FIND_MATCH_LENGTH_H_ + #include "../common/platform.h" #include <brotli/types.h> - + #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif - + /* Separate implementation for little-endian 64-bit targets, for speed. */ #if defined(__GNUC__) && defined(_LP64) && defined(BROTLI_LITTLE_ENDIAN) - + static BROTLI_INLINE size_t FindMatchLengthWithLimit(const uint8_t* s1, const uint8_t* s2, size_t limit) { @@ -27,54 +27,54 @@ static BROTLI_INLINE size_t FindMatchLengthWithLimit(const uint8_t* s1, while (BROTLI_PREDICT_TRUE(--limit2)) { if (BROTLI_PREDICT_FALSE(BROTLI_UNALIGNED_LOAD64LE(s2) == BROTLI_UNALIGNED_LOAD64LE(s1 + matched))) { - s2 += 8; - matched += 8; - } else { + s2 += 8; + matched += 8; + } else { uint64_t x = BROTLI_UNALIGNED_LOAD64LE(s2) ^ BROTLI_UNALIGNED_LOAD64LE(s1 + matched); size_t matching_bits = (size_t)__builtin_ctzll(x); - matched += matching_bits >> 3; - return matched; - } - } + matched += matching_bits >> 3; + return matched; + } + } limit = (limit & 7) + 1; /* + 1 is for pre-decrement in while */ - while (--limit) { + while (--limit) { if (BROTLI_PREDICT_TRUE(s1[matched] == *s2)) { - ++s2; - ++matched; - } else { - return matched; - } - } - return matched; -} -#else + ++s2; + ++matched; + } else { + return matched; + } + } + return matched; +} +#else static BROTLI_INLINE size_t FindMatchLengthWithLimit(const uint8_t* s1, const uint8_t* s2, size_t limit) { size_t matched = 0; - const uint8_t* s2_limit = s2 + limit; - const uint8_t* s2_ptr = s2; + const uint8_t* s2_limit = s2 + limit; + const uint8_t* s2_ptr = s2; /* Find out how long the match is. We loop over the data 32 bits at a time until we find a 32-bit block that doesn't match; then we find the first non-matching bit and use that to calculate the total length of the match. */ - while (s2_ptr <= s2_limit - 4 && + while (s2_ptr <= s2_limit - 4 && BrotliUnalignedRead32(s2_ptr) == BrotliUnalignedRead32(s1 + matched)) { - s2_ptr += 4; - matched += 4; - } - while ((s2_ptr < s2_limit) && (s1[matched] == *s2_ptr)) { - ++s2_ptr; - ++matched; - } - return matched; -} -#endif - + s2_ptr += 4; + matched += 4; + } + while ((s2_ptr < s2_limit) && (s1[matched] == *s2_ptr)) { + ++s2_ptr; + ++matched; + } + return matched; +} +#endif + #if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ #endif - + #endif /* BROTLI_ENC_FIND_MATCH_LENGTH_H_ */ diff --git a/contrib/libs/brotli/enc/hash.h b/contrib/libs/brotli/enc/hash.h index c4945fb101..8c5a7bb5ad 100644 --- a/contrib/libs/brotli/enc/hash.h +++ b/contrib/libs/brotli/enc/hash.h @@ -1,5 +1,5 @@ /* Copyright 2010 Google Inc. All Rights Reserved. - + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ @@ -7,26 +7,26 @@ /* A (forgetful) hash table to the data seen by the compressor, to help create backward references to previous data. */ -#ifndef BROTLI_ENC_HASH_H_ -#define BROTLI_ENC_HASH_H_ - +#ifndef BROTLI_ENC_HASH_H_ +#define BROTLI_ENC_HASH_H_ + #include <string.h> /* memcmp, memset */ - + #include "../common/constants.h" #include "../common/dictionary.h" #include "../common/platform.h" #include <brotli/types.h> #include "./encoder_dict.h" -#include "./fast_log.h" -#include "./find_match_length.h" +#include "./fast_log.h" +#include "./find_match_length.h" #include "./memory.h" #include "./quality.h" -#include "./static_dict.h" - +#include "./static_dict.h" + #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif - + /* Pointer to hasher data. * * Excluding initialization and destruction, hasher can be passed as @@ -40,10 +40,10 @@ extern "C" { * Using "define" instead of "typedef", because on MSVC __restrict does not work * on typedef pointer types. */ #define HasherHandle uint8_t* - + typedef struct { BrotliHasherParams params; - + /* False if hasher needs to be "prepared" before use. */ BROTLI_BOOL is_prepared_; @@ -80,14 +80,14 @@ static const uint32_t kHashMul32 = 0x1E35A7BD; static const uint64_t kHashMul64 = BROTLI_MAKE_UINT64_T(0x1E35A7BD, 0x1E35A7BD); static const uint64_t kHashMul64Long = BROTLI_MAKE_UINT64_T(0x1FE35A7Bu, 0xD3579BD3u); - + static BROTLI_INLINE uint32_t Hash14(const uint8_t* data) { uint32_t h = BROTLI_UNALIGNED_LOAD32LE(data) * kHashMul32; /* The higher bits contain more mixture from the multiplication, so we take our results from there. */ return h >> (32 - 14); -} - +} + static BROTLI_INLINE void PrepareDistanceCache( int* BROTLI_RESTRICT distance_cache, const int num_distances) { if (num_distances > 4) { @@ -108,8 +108,8 @@ static BROTLI_INLINE void PrepareDistanceCache( distance_cache[15] = next_last_distance + 3; } } -} - +} + #define BROTLI_LITERAL_BYTE_SCORE 135 #define BROTLI_DISTANCE_BIT_PENALTY 30 /* Score must be positive after applying maximal penalty. */ @@ -135,19 +135,19 @@ static BROTLI_INLINE score_t BackwardReferenceScore( size_t copy_length, size_t backward_reference_offset) { return BROTLI_SCORE_BASE + BROTLI_LITERAL_BYTE_SCORE * (score_t)copy_length - BROTLI_DISTANCE_BIT_PENALTY * Log2FloorNonZero(backward_reference_offset); -} - +} + static BROTLI_INLINE score_t BackwardReferenceScoreUsingLastDistance( size_t copy_length) { return BROTLI_LITERAL_BYTE_SCORE * (score_t)copy_length + BROTLI_SCORE_BASE + 15; } - + static BROTLI_INLINE score_t BackwardReferencePenaltyUsingLastDistance( size_t distance_short_code) { return (score_t)39 + ((0x1CA10 >> (distance_short_code & 0xE)) & 0xE); } - + static BROTLI_INLINE BROTLI_BOOL TestStaticDictionaryItem( const BrotliEncoderDictionary* dictionary, size_t item, const uint8_t* data, size_t max_length, size_t max_backward, @@ -164,33 +164,33 @@ static BROTLI_INLINE BROTLI_BOOL TestStaticDictionaryItem( if (len > max_length) { return BROTLI_FALSE; } - + matchlen = FindMatchLengthWithLimit(data, &dictionary->words->data[offset], len); if (matchlen + dictionary->cutoffTransformsCount <= len || matchlen == 0) { return BROTLI_FALSE; - } + } { size_t cut = len - matchlen; size_t transform_id = (cut << 2) + (size_t)((dictionary->cutoffTransforms >> (cut * 6)) & 0x3F); backward = max_backward + 1 + word_idx + (transform_id << dictionary->words->size_bits_by_length[len]); - } + } if (backward > max_distance) { return BROTLI_FALSE; - } + } score = BackwardReferenceScore(matchlen, backward); if (score < out->score) { return BROTLI_FALSE; - } + } out->len = matchlen; out->len_code_delta = (int)len - (int)matchlen; out->distance = backward; out->score = score; return BROTLI_TRUE; } - + static BROTLI_INLINE void SearchInStaticDictionary( const BrotliEncoderDictionary* dictionary, HasherHandle handle, const uint8_t* data, size_t max_length, @@ -201,7 +201,7 @@ static BROTLI_INLINE void SearchInStaticDictionary( HasherCommon* self = GetHasherCommon(handle); if (self->dict_num_matches < (self->dict_num_lookups >> 7)) { return; - } + } key = Hash14(data) << 1; for (i = 0; i < (shallow ? 1u : 2u); ++i, ++key) { size_t item = dictionary->hash_table[key]; @@ -212,42 +212,42 @@ static BROTLI_INLINE void SearchInStaticDictionary( max_length, max_backward, max_distance, out); if (item_matches) { self->dict_num_matches++; - } - } - } + } + } + } } - + typedef struct BackwardMatch { uint32_t distance; uint32_t length_and_code; } BackwardMatch; - + static BROTLI_INLINE void InitBackwardMatch(BackwardMatch* self, size_t dist, size_t len) { self->distance = (uint32_t)dist; self->length_and_code = (uint32_t)(len << 5); } - + static BROTLI_INLINE void InitDictionaryBackwardMatch(BackwardMatch* self, size_t dist, size_t len, size_t len_code) { self->distance = (uint32_t)dist; self->length_and_code = (uint32_t)((len << 5) | (len == len_code ? 0 : len_code)); } - + static BROTLI_INLINE size_t BackwardMatchLength(const BackwardMatch* self) { return self->length_and_code >> 5; } - + static BROTLI_INLINE size_t BackwardMatchLengthCode(const BackwardMatch* self) { size_t code = self->length_and_code & 31; return code ? code : BackwardMatchLength(self); } - + #define EXPAND_CAT(a, b) CAT(a, b) #define CAT(a, b) a ## b #define FN(X) EXPAND_CAT(X, HASHER()) - + #define HASHER() H10 #define BUCKET_BITS 17 #define MAX_TREE_SEARCH_DEPTH 64 @@ -259,11 +259,11 @@ static BROTLI_INLINE size_t BackwardMatchLengthCode(const BackwardMatch* self) { #undef HASHER /* MAX_NUM_MATCHES == 64 + MAX_TREE_SEARCH_DEPTH */ #define MAX_NUM_MATCHES_H10 128 - + /* For BUCKET_SWEEP == 1, enabling the dictionary lookup makes compression a little faster (0.5% - 1%) and it compresses 0.15% better on small text and HTML inputs. */ - + #define HASHER() H2 #define BUCKET_BITS 16 #define BUCKET_SWEEP 1 @@ -273,7 +273,7 @@ static BROTLI_INLINE size_t BackwardMatchLengthCode(const BackwardMatch* self) { #undef BUCKET_SWEEP #undef USE_DICTIONARY #undef HASHER - + #define HASHER() H3 #define BUCKET_SWEEP 2 #define USE_DICTIONARY 0 @@ -282,7 +282,7 @@ static BROTLI_INLINE size_t BackwardMatchLengthCode(const BackwardMatch* self) { #undef BUCKET_SWEEP #undef BUCKET_BITS #undef HASHER - + #define HASHER() H4 #define BUCKET_BITS 17 #define BUCKET_SWEEP 4 @@ -293,17 +293,17 @@ static BROTLI_INLINE size_t BackwardMatchLengthCode(const BackwardMatch* self) { #undef BUCKET_SWEEP #undef BUCKET_BITS #undef HASHER - + #define HASHER() H5 #include "./hash_longest_match_inc.h" /* NOLINT(build/include) */ #undef HASHER - + #define HASHER() H6 #include "./hash_longest_match64_inc.h" /* NOLINT(build/include) */ #undef HASHER - + #define BUCKET_BITS 15 - + #define NUM_LAST_DISTANCES_TO_CHECK 4 #define NUM_BANKS 1 #define BANK_BITS 16 @@ -311,7 +311,7 @@ static BROTLI_INLINE size_t BackwardMatchLengthCode(const BackwardMatch* self) { #include "./hash_forgetful_chain_inc.h" /* NOLINT(build/include) */ #undef HASHER #undef NUM_LAST_DISTANCES_TO_CHECK - + #define NUM_LAST_DISTANCES_TO_CHECK 10 #define HASHER() H41 #include "./hash_forgetful_chain_inc.h" /* NOLINT(build/include) */ @@ -319,7 +319,7 @@ static BROTLI_INLINE size_t BackwardMatchLengthCode(const BackwardMatch* self) { #undef NUM_LAST_DISTANCES_TO_CHECK #undef NUM_BANKS #undef BANK_BITS - + #define NUM_LAST_DISTANCES_TO_CHECK 16 #define NUM_BANKS 512 #define BANK_BITS 9 @@ -329,9 +329,9 @@ static BROTLI_INLINE size_t BackwardMatchLengthCode(const BackwardMatch* self) { #undef NUM_LAST_DISTANCES_TO_CHECK #undef NUM_BANKS #undef BANK_BITS - + #undef BUCKET_BITS - + #define HASHER() H54 #define BUCKET_BITS 20 #define BUCKET_SWEEP 4 @@ -343,7 +343,7 @@ static BROTLI_INLINE size_t BackwardMatchLengthCode(const BackwardMatch* self) { #undef BUCKET_SWEEP #undef BUCKET_BITS #undef HASHER - + /* fast large window hashers */ #define HASHER() HROLLING_FAST @@ -420,10 +420,10 @@ static BROTLI_INLINE size_t HasherSize(const BrotliEncoderParams* params, #undef SIZE_ default: break; - } + } return result; } - + static BROTLI_INLINE void HasherSetup(MemoryManager* m, HasherHandle* handle, BrotliEncoderParams* params, const uint8_t* data, size_t position, size_t input_size, BROTLI_BOOL is_last) { @@ -448,10 +448,10 @@ static BROTLI_INLINE void HasherSetup(MemoryManager* m, HasherHandle* handle, #undef INITIALIZE_ default: break; - } + } HasherReset(*handle); - } - + } + self = *handle; common = GetHasherCommon(self); if (!common->is_prepared_) { @@ -462,16 +462,16 @@ static BROTLI_INLINE void HasherSetup(MemoryManager* m, HasherHandle* handle, break; FOR_ALL_HASHERS(PREPARE_) #undef PREPARE_ - default: break; - } + default: break; + } if (position == 0) { common->dict_num_lookups = 0; common->dict_num_matches = 0; } common->is_prepared_ = BROTLI_TRUE; - } + } } - + static BROTLI_INLINE void InitOrStitchToPreviousBlock( MemoryManager* m, HasherHandle* handle, const uint8_t* data, size_t mask, BrotliEncoderParams* params, size_t position, size_t input_size, @@ -490,9 +490,9 @@ static BROTLI_INLINE void InitOrStitchToPreviousBlock( default: break; } } - + #if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ #endif - + #endif /* BROTLI_ENC_HASH_H_ */ diff --git a/contrib/libs/brotli/enc/histogram.h b/contrib/libs/brotli/enc/histogram.h index a522ca7aa7..42af3c3f9d 100644 --- a/contrib/libs/brotli/enc/histogram.h +++ b/contrib/libs/brotli/enc/histogram.h @@ -1,14 +1,14 @@ /* Copyright 2013 Google Inc. All Rights Reserved. - + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ /* Models the histograms of literals, commands and distance codes. */ -#ifndef BROTLI_ENC_HISTOGRAM_H_ -#define BROTLI_ENC_HISTOGRAM_H_ - +#ifndef BROTLI_ENC_HISTOGRAM_H_ +#define BROTLI_ENC_HISTOGRAM_H_ + #include <string.h> /* memset */ #include "../common/constants.h" @@ -16,12 +16,12 @@ #include "../common/platform.h" #include <brotli/types.h> #include "./block_splitter.h" -#include "./command.h" - +#include "./command.h" + #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif - + /* The distance symbols effectively used by "Large Window Brotli" (32-bit). */ #define BROTLI_NUM_HISTOGRAM_DISTANCE_SYMBOLS 544 @@ -32,21 +32,21 @@ extern "C" { #undef DataType #undef DATA_SIZE #undef FN - + #define FN(X) X ## Command #define DataType uint16_t #define DATA_SIZE BROTLI_NUM_COMMAND_SYMBOLS #include "./histogram_inc.h" /* NOLINT(build/include) */ #undef DATA_SIZE #undef FN - + #define FN(X) X ## Distance #define DATA_SIZE BROTLI_NUM_HISTOGRAM_DISTANCE_SYMBOLS #include "./histogram_inc.h" /* NOLINT(build/include) */ #undef DataType #undef DATA_SIZE #undef FN - + BROTLI_INTERNAL void BrotliBuildHistogramsWithContext( const Command* cmds, const size_t num_commands, const BlockSplit* literal_split, const BlockSplit* insert_and_copy_split, @@ -55,9 +55,9 @@ BROTLI_INTERNAL void BrotliBuildHistogramsWithContext( const ContextType* context_modes, HistogramLiteral* literal_histograms, HistogramCommand* insert_and_copy_histograms, HistogramDistance* copy_dist_histograms); - + #if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ #endif - + #endif /* BROTLI_ENC_HISTOGRAM_H_ */ diff --git a/contrib/libs/brotli/enc/literal_cost.h b/contrib/libs/brotli/enc/literal_cost.h index 412c155890..8f53f39d3f 100644 --- a/contrib/libs/brotli/enc/literal_cost.h +++ b/contrib/libs/brotli/enc/literal_cost.h @@ -1,5 +1,5 @@ /* Copyright 2013 Google Inc. All Rights Reserved. - + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ @@ -7,24 +7,24 @@ /* Literal cost model to allow backward reference replacement to be efficient. */ -#ifndef BROTLI_ENC_LITERAL_COST_H_ -#define BROTLI_ENC_LITERAL_COST_H_ - +#ifndef BROTLI_ENC_LITERAL_COST_H_ +#define BROTLI_ENC_LITERAL_COST_H_ + #include "../common/platform.h" #include <brotli/types.h> - + #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif - + /* Estimates how many bits the literals in the interval [pos, pos + len) in the ring-buffer (data, mask) will take entropy coded and writes these estimates to the cost[0..len) array. */ BROTLI_INTERNAL void BrotliEstimateBitCostsForLiterals( size_t pos, size_t len, size_t mask, const uint8_t* data, float* cost); - + #if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ #endif - + #endif /* BROTLI_ENC_LITERAL_COST_H_ */ diff --git a/contrib/libs/brotli/enc/metablock.h b/contrib/libs/brotli/enc/metablock.h index add40a056c..334a79a443 100644 --- a/contrib/libs/brotli/enc/metablock.h +++ b/contrib/libs/brotli/enc/metablock.h @@ -1,5 +1,5 @@ /* Copyright 2015 Google Inc. All Rights Reserved. - + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ @@ -7,26 +7,26 @@ /* Algorithms for distributing the literals and commands of a metablock between block types and contexts. */ -#ifndef BROTLI_ENC_METABLOCK_H_ -#define BROTLI_ENC_METABLOCK_H_ - +#ifndef BROTLI_ENC_METABLOCK_H_ +#define BROTLI_ENC_METABLOCK_H_ + #include "../common/context.h" #include "../common/platform.h" #include <brotli/types.h> #include "./block_splitter.h" -#include "./command.h" -#include "./histogram.h" +#include "./command.h" +#include "./histogram.h" #include "./memory.h" #include "./quality.h" - + #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif - + typedef struct MetaBlockSplit { - BlockSplit literal_split; - BlockSplit command_split; - BlockSplit distance_split; + BlockSplit literal_split; + BlockSplit command_split; + BlockSplit distance_split; uint32_t* literal_context_map; size_t literal_context_map_size; uint32_t* distance_context_map; @@ -38,7 +38,7 @@ typedef struct MetaBlockSplit { HistogramDistance* distance_histograms; size_t distance_histograms_size; } MetaBlockSplit; - + static BROTLI_INLINE void InitMetaBlockSplit(MetaBlockSplit* mb) { BrotliInitBlockSplit(&mb->literal_split); BrotliInitBlockSplit(&mb->command_split); @@ -54,7 +54,7 @@ static BROTLI_INLINE void InitMetaBlockSplit(MetaBlockSplit* mb) { mb->distance_histograms = 0; mb->distance_histograms_size = 0; } - + static BROTLI_INLINE void DestroyMetaBlockSplit( MemoryManager* m, MetaBlockSplit* mb) { BrotliDestroyBlockSplit(m, &mb->literal_split); @@ -66,7 +66,7 @@ static BROTLI_INLINE void DestroyMetaBlockSplit( BROTLI_FREE(m, mb->command_histograms); BROTLI_FREE(m, mb->distance_histograms); } - + /* Uses the slow shortest-path block splitter and does context clustering. The distance parameters are dynamically selected based on the commands which get recomputed under the new distance parameters. The new distance @@ -82,7 +82,7 @@ BROTLI_INTERNAL void BrotliBuildMetaBlock(MemoryManager* m, size_t num_commands, ContextType literal_context_mode, MetaBlockSplit* mb); - + /* Uses a fast greedy block splitter that tries to merge current block with the last or the second last block and uses a static context clustering which is the same for all block types. */ @@ -91,10 +91,10 @@ BROTLI_INTERNAL void BrotliBuildMetaBlockGreedy( uint8_t prev_byte, uint8_t prev_byte2, ContextLut literal_context_lut, size_t num_contexts, const uint32_t* static_context_map, const Command* commands, size_t n_commands, MetaBlockSplit* mb); - + BROTLI_INTERNAL void BrotliOptimizeHistograms(uint32_t num_distance_codes, MetaBlockSplit* mb); - + BROTLI_INTERNAL void BrotliInitDistanceParams(BrotliEncoderParams* params, uint32_t npostfix, uint32_t ndirect); diff --git a/contrib/libs/brotli/enc/prefix.h b/contrib/libs/brotli/enc/prefix.h index 56b89fa466..fd359a478d 100644 --- a/contrib/libs/brotli/enc/prefix.h +++ b/contrib/libs/brotli/enc/prefix.h @@ -1,5 +1,5 @@ /* Copyright 2013 Google Inc. All Rights Reserved. - + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ @@ -7,18 +7,18 @@ /* Functions for encoding of integers into prefix codes the amount of extra bits, and the actual values of the extra bits. */ -#ifndef BROTLI_ENC_PREFIX_H_ -#define BROTLI_ENC_PREFIX_H_ - +#ifndef BROTLI_ENC_PREFIX_H_ +#define BROTLI_ENC_PREFIX_H_ + #include "../common/constants.h" #include "../common/platform.h" #include <brotli/types.h> -#include "./fast_log.h" - +#include "./fast_log.h" + #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif - + /* Here distance_code is an intermediate code, i.e. one of the special codes or the actual distance increased by BROTLI_NUM_DISTANCE_SHORT_CODES - 1. */ static BROTLI_INLINE void PrefixEncodeCopyDistance(size_t distance_code, @@ -28,8 +28,8 @@ static BROTLI_INLINE void PrefixEncodeCopyDistance(size_t distance_code, uint32_t* extra_bits) { if (distance_code < BROTLI_NUM_DISTANCE_SHORT_CODES + num_direct_codes) { *code = (uint16_t)distance_code; - *extra_bits = 0; - return; + *extra_bits = 0; + return; } else { size_t dist = ((size_t)1 << (postfix_bits + 2u)) + (distance_code - BROTLI_NUM_DISTANCE_SHORT_CODES - num_direct_codes); @@ -43,11 +43,11 @@ static BROTLI_INLINE void PrefixEncodeCopyDistance(size_t distance_code, (BROTLI_NUM_DISTANCE_SHORT_CODES + num_direct_codes + ((2 * (nbits - 1) + prefix) << postfix_bits) + postfix)); *extra_bits = (uint32_t)((dist - offset) >> postfix_bits); - } -} - + } +} + #if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ #endif - + #endif /* BROTLI_ENC_PREFIX_H_ */ diff --git a/contrib/libs/brotli/enc/ringbuffer.h b/contrib/libs/brotli/enc/ringbuffer.h index 1ee7688e54..86079a89d3 100644 --- a/contrib/libs/brotli/enc/ringbuffer.h +++ b/contrib/libs/brotli/enc/ringbuffer.h @@ -1,25 +1,25 @@ /* Copyright 2013 Google Inc. All Rights Reserved. - + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ /* Sliding window over the input data. */ -#ifndef BROTLI_ENC_RINGBUFFER_H_ -#define BROTLI_ENC_RINGBUFFER_H_ - +#ifndef BROTLI_ENC_RINGBUFFER_H_ +#define BROTLI_ENC_RINGBUFFER_H_ + #include <string.h> /* memcpy */ - + #include "../common/platform.h" #include <brotli/types.h> #include "./memory.h" #include "./quality.h" - + #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif - + /* A RingBuffer(window_bits, tail_bits) contains `1 << window_bits' bytes of data in a circular manner: writing a byte writes it to: `position() % (1 << window_bits)'. @@ -80,16 +80,16 @@ static BROTLI_INLINE void RingBufferInitBuffer( memcpy(new_data, rb->data_, 2 + rb->cur_size_ + kSlackForEightByteHashingEverywhere); BROTLI_FREE(m, rb->data_); - } + } rb->data_ = new_data; rb->cur_size_ = buflen; rb->buffer_ = rb->data_ + 2; rb->buffer_[-2] = rb->buffer_[-1] = 0; for (i = 0; i < kSlackForEightByteHashingEverywhere; ++i) { rb->buffer_[rb->cur_size_ + i] = 0; - } + } } - + static BROTLI_INLINE void RingBufferWriteTail( const uint8_t* bytes, size_t n, RingBuffer* rb) { const size_t masked_pos = rb->pos_ & rb->mask_; @@ -98,9 +98,9 @@ static BROTLI_INLINE void RingBufferWriteTail( const size_t p = rb->size_ + masked_pos; memcpy(&rb->buffer_[p], bytes, BROTLI_MIN(size_t, n, rb->tail_size_ - masked_pos)); - } + } } - + /* Push bytes into the ring buffer. */ static BROTLI_INLINE void RingBufferWrite( MemoryManager* m, const uint8_t* bytes, size_t n, RingBuffer* rb) { @@ -116,7 +116,7 @@ static BROTLI_INLINE void RingBufferWrite( if (BROTLI_IS_OOM(m)) return; memcpy(rb->buffer_, bytes, n); return; - } + } if (rb->cur_size_ < rb->total_size_) { /* Lazily allocate the full buffer. */ RingBufferInitBuffer(m, rb->total_size_, rb); @@ -142,8 +142,8 @@ static BROTLI_INLINE void RingBufferWrite( /* Copy into the beginning of the buffer */ memcpy(&rb->buffer_[0], bytes + (rb->size_ - masked_pos), n - (rb->size_ - masked_pos)); - } - } + } + } { BROTLI_BOOL not_first_lap = (rb->pos_ & (1u << 31)) != 0; uint32_t rb_pos_mask = (1u << 31) - 1; @@ -156,9 +156,9 @@ static BROTLI_INLINE void RingBufferWrite( } } } - + #if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ #endif - + #endif /* BROTLI_ENC_RINGBUFFER_H_ */ diff --git a/contrib/libs/brotli/enc/static_dict.h b/contrib/libs/brotli/enc/static_dict.h index a5e06f43c5..6b5d4eb0c9 100644 --- a/contrib/libs/brotli/enc/static_dict.h +++ b/contrib/libs/brotli/enc/static_dict.h @@ -1,26 +1,26 @@ /* Copyright 2013 Google Inc. All Rights Reserved. - + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ /* Class to model the static dictionary. */ -#ifndef BROTLI_ENC_STATIC_DICT_H_ -#define BROTLI_ENC_STATIC_DICT_H_ - +#ifndef BROTLI_ENC_STATIC_DICT_H_ +#define BROTLI_ENC_STATIC_DICT_H_ + #include "../common/dictionary.h" #include "../common/platform.h" #include <brotli/types.h> #include "./encoder_dict.h" - + #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif - + #define BROTLI_MAX_STATIC_DICTIONARY_MATCH_LEN 37 static const uint32_t kInvalidMatch = 0xFFFFFFF; - + /* Matches data against static dictionary words, and for each length l, for which a match is found, updates matches[l] to be the minimum possible (distance << 5) + len_code. @@ -32,9 +32,9 @@ BROTLI_INTERNAL BROTLI_BOOL BrotliFindAllStaticDictionaryMatches( const BrotliEncoderDictionary* dictionary, const uint8_t* data, size_t min_length, size_t max_length, uint32_t* matches); - + #if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ #endif - + #endif /* BROTLI_ENC_STATIC_DICT_H_ */ diff --git a/contrib/libs/brotli/enc/static_dict_lut.h b/contrib/libs/brotli/enc/static_dict_lut.h index aba9af4508..e299cda6d8 100644 --- a/contrib/libs/brotli/enc/static_dict_lut.h +++ b/contrib/libs/brotli/enc/static_dict_lut.h @@ -1,30 +1,30 @@ /* Copyright 2015 Google Inc. All Rights Reserved. - + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ - + /* Lookup table for static dictionary and transforms. */ - + #ifndef BROTLI_ENC_STATIC_DICT_LUT_H_ #define BROTLI_ENC_STATIC_DICT_LUT_H_ - + #include <brotli/types.h> - + #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif typedef struct DictWord { /* Highest bit is used to indicate end of bucket. */ - uint8_t len; - uint8_t transform; - uint16_t idx; + uint8_t len; + uint8_t transform; + uint16_t idx; } DictWord; - + static const int kDictNumBits = 15; static const uint32_t kDictHashMul32 = 0x1E35A7BD; - + static const uint16_t kStaticDictionaryBuckets[32768] = { 1,0,0,0,0,0,0,0,0,3,6,0,0,0,0,0,20,0,0,0,21,0,22,0,0,0,0,0,0,0,0,23,0,0,25,0,29, 0,53,0,0,0,0,0,0,55,0,0,0,0,0,0,61,76,0,0,0,94,0,0,0,0,0,0,96,0,97,0,98,0,0,0,0, @@ -5855,10 +5855,10 @@ static const DictWord kStaticDictionaryWords[31705] = { 458},{12,0,756},{132,10,420},{134,0,1504},{6,0,757},{133,11,383},{6,0,1266},{135 ,0,1735},{5,0,598},{7,0,791},{8,0,108},{9,0,123},{7,10,1570},{140,10,542},{142, 11,410},{9,11,660},{138,11,347} -}; - +}; + #if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ #endif - + #endif /* BROTLI_ENC_STATIC_DICT_LUT_H_ */ diff --git a/contrib/libs/brotli/enc/write_bits.h b/contrib/libs/brotli/enc/write_bits.h index 6f6080b5c0..36515a6893 100644 --- a/contrib/libs/brotli/enc/write_bits.h +++ b/contrib/libs/brotli/enc/write_bits.h @@ -1,23 +1,23 @@ /* Copyright 2010 Google Inc. All Rights Reserved. - + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ /* Write bits into a byte array. */ -#ifndef BROTLI_ENC_WRITE_BITS_H_ -#define BROTLI_ENC_WRITE_BITS_H_ - +#ifndef BROTLI_ENC_WRITE_BITS_H_ +#define BROTLI_ENC_WRITE_BITS_H_ + #include "../common/platform.h" #include <brotli/types.h> - + #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif - + /*#define BIT_WRITER_DEBUG */ - + /* This function writes bits into bytes in increasing addresses, and within a byte least-significant-bit first. @@ -50,36 +50,36 @@ static BROTLI_INLINE void BrotliWriteBits(size_t n_bits, (int)*pos)); BROTLI_DCHECK((bits >> n_bits) == 0); BROTLI_DCHECK(n_bits <= 56); - v |= bits << (*pos & 7); + v |= bits << (*pos & 7); BROTLI_UNALIGNED_STORE64LE(p, v); /* Set some bits. */ - *pos += n_bits; -#else + *pos += n_bits; +#else /* implicit & 0xFF is assumed for uint8_t arithmetics */ uint8_t* array_pos = &array[*pos >> 3]; const size_t bits_reserved_in_first_byte = (*pos & 7); size_t bits_left_to_write; - bits <<= bits_reserved_in_first_byte; + bits <<= bits_reserved_in_first_byte; *array_pos++ |= (uint8_t)bits; for (bits_left_to_write = n_bits + bits_reserved_in_first_byte; bits_left_to_write >= 9; - bits_left_to_write -= 8) { - bits >>= 8; + bits_left_to_write -= 8) { + bits >>= 8; *array_pos++ = (uint8_t)bits; - } - *array_pos = 0; - *pos += n_bits; -#endif -} - + } + *array_pos = 0; + *pos += n_bits; +#endif +} + static BROTLI_INLINE void BrotliWriteBitsPrepareStorage( size_t pos, uint8_t* array) { BROTLI_LOG(("WriteBitsPrepareStorage %10d\n", (int)pos)); BROTLI_DCHECK((pos & 7) == 0); - array[pos >> 3] = 0; -} - + array[pos >> 3] = 0; +} + #if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ #endif - + #endif /* BROTLI_ENC_WRITE_BITS_H_ */ diff --git a/contrib/libs/brotli/enc/ya.make b/contrib/libs/brotli/enc/ya.make index 6d415989e7..67da82ec4d 100644 --- a/contrib/libs/brotli/enc/ya.make +++ b/contrib/libs/brotli/enc/ya.make @@ -1,6 +1,6 @@ -LIBRARY() - -LICENSE(MIT) +LIBRARY() + +LICENSE(MIT) LICENSE_TEXTS(.yandex_meta/licenses.list.txt) @@ -9,19 +9,19 @@ OWNER( g:contrib g:cpp-contrib ) - -NO_UTIL() -NO_COMPILER_WARNINGS() - +NO_UTIL() + +NO_COMPILER_WARNINGS() + ADDINCL(GLOBAL contrib/libs/brotli/include) -PEERDIR( +PEERDIR( contrib/libs/brotli/common - contrib/libs/brotli/dec -) - -SRCS( + contrib/libs/brotli/dec +) + +SRCS( backward_references.c backward_references_hq.c bit_cost.c @@ -40,8 +40,8 @@ SRCS( metablock.c static_dict.c utf8_util.c -) - +) + CFLAGS(-DBROTLI_BUILD_PORTABLE) -END() +END() diff --git a/contrib/libs/brotli/ya.make b/contrib/libs/brotli/ya.make index f1b05ee869..f0941aa638 100644 --- a/contrib/libs/brotli/ya.make +++ b/contrib/libs/brotli/ya.make @@ -1,10 +1,10 @@ VERSION(1.0.1) -RECURSE( +RECURSE( common - dec - enc - tools + dec + enc + tools python java -) +) |