forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Commit migrated from dotnet/corefx@f8f075b
- Loading branch information
1 parent
762b637
commit 421ba1d
Showing
82 changed files
with
34,252 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* Copyright 2016 Google Inc. All Rights Reserved. | ||
Distributed under MIT license. | ||
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT | ||
*/ | ||
|
||
#ifndef BROTLI_COMMON_CONSTANTS_H_ | ||
#define BROTLI_COMMON_CONSTANTS_H_ | ||
|
||
/* Specification: 7.3. Encoding of the context map */ | ||
#define BROTLI_CONTEXT_MAP_MAX_RLE 16 | ||
|
||
/* Specification: 2. Compressed representation overview */ | ||
#define BROTLI_MAX_NUMBER_OF_BLOCK_TYPES 256 | ||
|
||
/* Specification: 3.3. Alphabet sizes: insert-and-copy length */ | ||
#define BROTLI_NUM_LITERAL_SYMBOLS 256 | ||
#define BROTLI_NUM_COMMAND_SYMBOLS 704 | ||
#define BROTLI_NUM_BLOCK_LEN_SYMBOLS 26 | ||
#define BROTLI_MAX_CONTEXT_MAP_SYMBOLS (BROTLI_MAX_NUMBER_OF_BLOCK_TYPES + \ | ||
BROTLI_CONTEXT_MAP_MAX_RLE) | ||
#define BROTLI_MAX_BLOCK_TYPE_SYMBOLS (BROTLI_MAX_NUMBER_OF_BLOCK_TYPES + 2) | ||
|
||
/* Specification: 3.5. Complex prefix codes */ | ||
#define BROTLI_REPEAT_PREVIOUS_CODE_LENGTH 16 | ||
#define BROTLI_REPEAT_ZERO_CODE_LENGTH 17 | ||
#define BROTLI_CODE_LENGTH_CODES (BROTLI_REPEAT_ZERO_CODE_LENGTH + 1) | ||
/* "code length of 8 is repeated" */ | ||
#define BROTLI_INITIAL_REPEATED_CODE_LENGTH 8 | ||
|
||
/* Specification: 4. Encoding of distances */ | ||
#define BROTLI_NUM_DISTANCE_SHORT_CODES 16 | ||
#define BROTLI_MAX_NPOSTFIX 3 | ||
#define BROTLI_MAX_NDIRECT 120 | ||
#define BROTLI_MAX_DISTANCE_BITS 24U | ||
/* BROTLI_NUM_DISTANCE_SYMBOLS == 520 */ | ||
#define BROTLI_NUM_DISTANCE_SYMBOLS (BROTLI_NUM_DISTANCE_SHORT_CODES + \ | ||
BROTLI_MAX_NDIRECT + \ | ||
(BROTLI_MAX_DISTANCE_BITS << \ | ||
(BROTLI_MAX_NPOSTFIX + 1))) | ||
/* Distance that is guaranteed to be representable in any stream. */ | ||
#define BROTLI_MAX_DISTANCE 0x3FFFFFC | ||
|
||
/* 7.1. Context modes and context ID lookup for literals */ | ||
/* "context IDs for literals are in the range of 0..63" */ | ||
#define BROTLI_LITERAL_CONTEXT_BITS 6 | ||
|
||
/* 7.2. Context ID for distances */ | ||
#define BROTLI_DISTANCE_CONTEXT_BITS 2 | ||
|
||
/* 9.1. Format of the Stream Header */ | ||
/* Number of slack bytes for window size. Don't confuse | ||
with BROTLI_NUM_DISTANCE_SHORT_CODES. */ | ||
#define BROTLI_WINDOW_GAP 16 | ||
#define BROTLI_MAX_BACKWARD_LIMIT(W) (((size_t)1 << (W)) - BROTLI_WINDOW_GAP) | ||
|
||
#endif /* BROTLI_COMMON_CONSTANTS_H_ */ |
432 changes: 432 additions & 0 deletions
432
src/libraries/Native/AnyOS/brotli/common/dictionary.bin
Large diffs are not rendered by default.
Oops, something went wrong.
5,905 changes: 5,905 additions & 0 deletions
5,905
src/libraries/Native/AnyOS/brotli/common/dictionary.c
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* Copyright 2013 Google Inc. All Rights Reserved. | ||
Distributed under MIT license. | ||
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT | ||
*/ | ||
|
||
/* Collection of static dictionary words. */ | ||
|
||
#ifndef BROTLI_COMMON_DICTIONARY_H_ | ||
#define BROTLI_COMMON_DICTIONARY_H_ | ||
|
||
#include <brotli/port.h> | ||
#include <brotli/types.h> | ||
|
||
#if defined(__cplusplus) || defined(c_plusplus) | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct BrotliDictionary { | ||
/** | ||
* Number of bits to encode index of dictionary word in a bucket. | ||
* | ||
* Specification: Appendix A. Static Dictionary Data | ||
* | ||
* Words in a dictionary are bucketed by length. | ||
* @c 0 means that there are no words of a given length. | ||
* Dictionary consists of words with length of [4..24] bytes. | ||
* Values at [0..3] and [25..31] indices should not be addressed. | ||
*/ | ||
uint8_t size_bits_by_length[32]; | ||
|
||
/* assert(offset[i + 1] == offset[i] + (bits[i] ? (i << bits[i]) : 0)) */ | ||
uint32_t offsets_by_length[32]; | ||
|
||
/* assert(data_size == offsets_by_length[31]) */ | ||
size_t data_size; | ||
|
||
/* Data array is not bound, and should obey to size_bits_by_length values. | ||
Specified size matches default (RFC 7932) dictionary. Its size is | ||
defined by data_size */ | ||
const uint8_t* data; | ||
} BrotliDictionary; | ||
|
||
BROTLI_COMMON_API extern const BrotliDictionary* BrotliGetDictionary(void); | ||
|
||
/** | ||
* Sets dictionary data. | ||
* | ||
* When dictionary data is already set / present, this method is no-op. | ||
* | ||
* Dictionary data MUST be provided before BrotliGetDictionary is invoked. | ||
* This method is used ONLY in multi-client environment (e.g. C + Java), | ||
* to reduce storage by sharing single dictionary between implementations. | ||
*/ | ||
BROTLI_COMMON_API void BrotliSetDictionaryData(const uint8_t* data); | ||
|
||
#define BROTLI_MIN_DICTIONARY_WORD_LENGTH 4 | ||
#define BROTLI_MAX_DICTIONARY_WORD_LENGTH 24 | ||
|
||
#if defined(__cplusplus) || defined(c_plusplus) | ||
} /* extern "C" */ | ||
#endif | ||
|
||
#endif /* BROTLI_COMMON_DICTIONARY_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* Copyright 2016 Google Inc. All Rights Reserved. | ||
Distributed under MIT license. | ||
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT | ||
*/ | ||
|
||
/* Version definition. */ | ||
|
||
#ifndef BROTLI_COMMON_VERSION_H_ | ||
#define BROTLI_COMMON_VERSION_H_ | ||
|
||
/* This macro should only be used when library is compiled together with client. | ||
If library is dynamically linked, use BrotliDecoderVersion and | ||
BrotliEncoderVersion methods. */ | ||
|
||
/* Semantic version, calculated as (MAJOR << 24) | (MINOR << 12) | PATCH */ | ||
#define BROTLI_VERSION 0x1000001 | ||
|
||
#endif /* BROTLI_COMMON_VERSION_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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 | ||
*/ | ||
|
||
/* Bit reading helpers */ | ||
|
||
#include "./bit_reader.h" | ||
|
||
#include <brotli/types.h> | ||
#include "./port.h" | ||
|
||
#if defined(__cplusplus) || defined(c_plusplus) | ||
extern "C" { | ||
#endif | ||
|
||
void BrotliInitBitReader(BrotliBitReader* const br) { | ||
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 | ||
overflow. If unalignment is caused by BrotliSafeReadBits, then there is | ||
enough space in accumulator to fix alignment. */ | ||
if (!BROTLI_ALIGNED_READ) { | ||
aligned_read_mask = 0; | ||
} | ||
if (BrotliGetAvailableBits(br) == 0) { | ||
if (!BrotliPullByte(br)) { | ||
return BROTLI_FALSE; | ||
} | ||
} | ||
|
||
while ((((size_t)br->next_in) & aligned_read_mask) != 0) { | ||
if (!BrotliPullByte(br)) { | ||
/* If we consumed all the input, we don't care about the alignment. */ | ||
return BROTLI_TRUE; | ||
} | ||
} | ||
return BROTLI_TRUE; | ||
} | ||
|
||
#if defined(__cplusplus) || defined(c_plusplus) | ||
} /* extern "C" */ | ||
#endif |
Oops, something went wrong.