Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(709)

Unified Diff: third_party/brotli/dec/huffman.c

Issue 2537133002: Update brotli to v1.0.0-snapshot. (Closed)
Patch Set: Fixed typo Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/brotli/dec/huffman.h ('k') | third_party/brotli/dec/port.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/brotli/dec/huffman.c
diff --git a/third_party/brotli/dec/huffman.c b/third_party/brotli/dec/huffman.c
index 3775ffe7e920f4cf1e1a5e95d1dfc7fb3d80182f..37da2a563959689bf97c658d032632d434bfef78 100644
--- a/third_party/brotli/dec/huffman.c
+++ b/third_party/brotli/dec/huffman.c
@@ -10,8 +10,9 @@
#include <string.h> /* memcpy, memset */
+#include "../common/constants.h"
+#include <brotli/types.h>
#include "./port.h"
-#include "./types.h"
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
@@ -20,7 +21,8 @@ extern "C" {
#define BROTLI_REVERSE_BITS_MAX 8
#ifdef BROTLI_RBIT
-#define BROTLI_REVERSE_BITS_BASE (32 - BROTLI_REVERSE_BITS_MAX)
+#define BROTLI_REVERSE_BITS_BASE \
+ ((sizeof(reg_t) << 3) - BROTLI_REVERSE_BITS_MAX)
#else
#define BROTLI_REVERSE_BITS_BASE 0
static uint8_t kReverseBits[1 << BROTLI_REVERSE_BITS_MAX] = {
@@ -60,12 +62,12 @@ static uint8_t kReverseBits[1 << BROTLI_REVERSE_BITS_MAX] = {
#endif /* BROTLI_RBIT */
#define BROTLI_REVERSE_BITS_LOWEST \
- (1U << (BROTLI_REVERSE_BITS_MAX - 1 + BROTLI_REVERSE_BITS_BASE))
+ ((reg_t)1 << (BROTLI_REVERSE_BITS_MAX - 1 + BROTLI_REVERSE_BITS_BASE))
/* Returns reverse(num >> BROTLI_REVERSE_BITS_BASE, BROTLI_REVERSE_BITS_MAX),
where reverse(value, len) is the bit-wise reversal of the len least
significant bits of value. */
-static BROTLI_INLINE uint32_t BrotliReverseBits(uint32_t num) {
+static BROTLI_INLINE reg_t BrotliReverseBits(reg_t num) {
#ifdef BROTLI_RBIT
return BROTLI_RBIT(num);
#else
@@ -102,13 +104,13 @@ static BROTLI_INLINE int NextTableBitSize(const uint16_t* const count,
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 */
- uint32_t key; /* prefix code */
- uint32_t key_step; /* prefix code addend */
- int step; /* step size to replicate values in current table */
- int table_size; /* size of current table */
- int sorted[18]; /* symbols sorted by code length */
+ HuffmanCode code; /* current table entry */
+ int symbol; /* symbol index in original or sorted table */
+ reg_t key; /* prefix code */
+ reg_t key_step; /* prefix code addend */
+ 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;
@@ -125,10 +127,10 @@ void BrotliBuildCodeLengthsHuffmanTable(HuffmanCode* table,
bits++;
});
/* Symbols with code length 0 are placed after all other symbols. */
- offset[0] = 17;
+ offset[0] = BROTLI_CODE_LENGTH_CODES - 1;
/* sort symbols by length, by symbol order within each length */
- symbol = 18;
+ symbol = BROTLI_CODE_LENGTH_CODES;
do {
BROTLI_REPEAT(6, {
symbol--;
@@ -142,7 +144,7 @@ void BrotliBuildCodeLengthsHuffmanTable(HuffmanCode* table,
if (offset[0] == 0) {
code.bits = 0;
code.value = (uint16_t)sorted[0];
- for (key = 0; key < (uint32_t)table_size; ++key) {
+ for (key = 0; key < (reg_t)table_size; ++key) {
table[key] = code;
}
return;
@@ -170,18 +172,18 @@ uint32_t BrotliBuildHuffmanTable(HuffmanCode* root_table,
int root_bits,
const uint16_t* const symbol_lists,
uint16_t* count) {
- HuffmanCode code; /* current table entry */
- HuffmanCode* table; /* next available space in table */
- int len; /* current code length */
- int symbol; /* symbol index in original or sorted table */
- uint32_t key; /* prefix code */
- uint32_t key_step; /* prefix code addend */
- uint32_t sub_key; /* 2nd level table prefix code */
- uint32_t sub_key_step; /* 2nd level table prefix code addend */
- int step; /* step size to replicate values in current 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 */
+ HuffmanCode code; /* current table entry */
+ HuffmanCode* table; /* next available space in table */
+ int len; /* current code length */
+ int symbol; /* symbol index in original or sorted table */
+ reg_t key; /* prefix code */
+ reg_t key_step; /* prefix code addend */
+ reg_t sub_key; /* 2nd level table prefix code */
+ reg_t sub_key_step; /* 2nd level table prefix code addend */
+ int step; /* step size to replicate values in current 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;
« no previous file with comments | « third_party/brotli/dec/huffman.h ('k') | third_party/brotli/dec/port.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698