diff options
-rw-r--r-- | enc/backward_references.cc | 20 | ||||
-rw-r--r-- | enc/backward_references.h | 2 | ||||
-rw-r--r-- | enc/bit_cost.h | 2 | ||||
-rw-r--r-- | enc/block_splitter.h | 3 | ||||
-rw-r--r-- | enc/brotli_bit_stream.cc | 2 | ||||
-rw-r--r-- | enc/brotli_bit_stream.h | 3 | ||||
-rw-r--r-- | enc/cluster.h | 4 | ||||
-rw-r--r-- | enc/command.h | 2 | ||||
-rw-r--r-- | enc/context.h | 2 | ||||
-rw-r--r-- | enc/dictionary.h | 2 | ||||
-rw-r--r-- | enc/dictionary_hash.h | 2 | ||||
-rw-r--r-- | enc/encode.cc | 44 | ||||
-rw-r--r-- | enc/encode.h | 13 | ||||
-rw-r--r-- | enc/encode_parallel.cc | 5 | ||||
-rw-r--r-- | enc/encode_parallel.h | 3 | ||||
-rw-r--r-- | enc/entropy_encode.cc | 2 | ||||
-rw-r--r-- | enc/entropy_encode.h | 2 | ||||
-rw-r--r-- | enc/fast_log.h | 3 | ||||
-rw-r--r-- | enc/find_match_length.h | 4 | ||||
-rw-r--r-- | enc/hash.h | 72 | ||||
-rw-r--r-- | enc/histogram.cc | 1 | ||||
-rw-r--r-- | enc/histogram.h | 2 | ||||
-rw-r--r-- | enc/literal_cost.cc | 2 | ||||
-rw-r--r-- | enc/literal_cost.h | 3 | ||||
-rw-r--r-- | enc/port.h | 1 | ||||
-rw-r--r-- | enc/prefix.h | 2 | ||||
-rw-r--r-- | enc/ringbuffer.h | 3 | ||||
-rw-r--r-- | enc/static_dict.h | 2 | ||||
-rw-r--r-- | enc/static_dict_lut.h | 2 | ||||
-rw-r--r-- | enc/streams.h | 13 | ||||
-rw-r--r-- | enc/types.h | 36 | ||||
-rw-r--r-- | enc/write_bits.h | 2 | ||||
-rw-r--r-- | setup.py | 1 |
33 files changed, 159 insertions, 103 deletions
diff --git a/enc/backward_references.cc b/enc/backward_references.cc index 283aee7..8ce653e 100644 --- a/enc/backward_references.cc +++ b/enc/backward_references.cc @@ -636,7 +636,7 @@ void CreateBackwardReferences(size_t num_bytes, int* num_literals) { bool zopflify = quality > 9; if (zopflify) { - Hashers::H9* hasher = hashers->hash_h9.get(); + Hashers::H9* hasher = hashers->hash_h9; if (num_bytes >= 3 && position >= 3) { // Prepare the hashes for three last bytes of the last write. // These could not be calculated before, since they require knowledge @@ -710,55 +710,55 @@ void CreateBackwardReferences(size_t num_bytes, case 1: CreateBackwardReferences<Hashers::H1>( num_bytes, position, ringbuffer, ringbuffer_mask, max_backward_limit, - quality, hashers->hash_h1.get(), dist_cache, last_insert_len, + quality, hashers->hash_h1, dist_cache, last_insert_len, commands, num_commands, num_literals); break; case 2: CreateBackwardReferences<Hashers::H2>( num_bytes, position, ringbuffer, ringbuffer_mask, max_backward_limit, - quality, hashers->hash_h2.get(), dist_cache, last_insert_len, + quality, hashers->hash_h2, dist_cache, last_insert_len, commands, num_commands, num_literals); break; case 3: CreateBackwardReferences<Hashers::H3>( num_bytes, position, ringbuffer, ringbuffer_mask, max_backward_limit, - quality, hashers->hash_h3.get(), dist_cache, last_insert_len, + quality, hashers->hash_h3, dist_cache, last_insert_len, commands, num_commands, num_literals); break; case 4: CreateBackwardReferences<Hashers::H4>( num_bytes, position, ringbuffer, ringbuffer_mask, max_backward_limit, - quality, hashers->hash_h4.get(), dist_cache, last_insert_len, + quality, hashers->hash_h4, dist_cache, last_insert_len, commands, num_commands, num_literals); break; case 5: CreateBackwardReferences<Hashers::H5>( num_bytes, position, ringbuffer, ringbuffer_mask, max_backward_limit, - quality, hashers->hash_h5.get(), dist_cache, last_insert_len, + quality, hashers->hash_h5, dist_cache, last_insert_len, commands, num_commands, num_literals); break; case 6: CreateBackwardReferences<Hashers::H6>( num_bytes, position, ringbuffer, ringbuffer_mask, max_backward_limit, - quality, hashers->hash_h6.get(), dist_cache, last_insert_len, + quality, hashers->hash_h6, dist_cache, last_insert_len, commands, num_commands, num_literals); break; case 7: CreateBackwardReferences<Hashers::H7>( num_bytes, position, ringbuffer, ringbuffer_mask, max_backward_limit, - quality, hashers->hash_h7.get(), dist_cache, last_insert_len, + quality, hashers->hash_h7, dist_cache, last_insert_len, commands, num_commands, num_literals); break; case 8: CreateBackwardReferences<Hashers::H8>( num_bytes, position, ringbuffer, ringbuffer_mask, max_backward_limit, - quality, hashers->hash_h8.get(), dist_cache, last_insert_len, + quality, hashers->hash_h8, dist_cache, last_insert_len, commands, num_commands, num_literals); break; case 9: CreateBackwardReferences<Hashers::H9>( num_bytes, position, ringbuffer, ringbuffer_mask, max_backward_limit, - quality, hashers->hash_h9.get(), dist_cache, last_insert_len, + quality, hashers->hash_h9, dist_cache, last_insert_len, commands, num_commands, num_literals); break; default: diff --git a/enc/backward_references.h b/enc/backward_references.h index 64bc7e8..cc40835 100644 --- a/enc/backward_references.h +++ b/enc/backward_references.h @@ -17,11 +17,11 @@ #ifndef BROTLI_ENC_BACKWARD_REFERENCES_H_ #define BROTLI_ENC_BACKWARD_REFERENCES_H_ -#include <stdint.h> #include <vector> #include "./hash.h" #include "./command.h" +#include "./types.h" namespace brotli { diff --git a/enc/bit_cost.h b/enc/bit_cost.h index 0e42220..922be3b 100644 --- a/enc/bit_cost.h +++ b/enc/bit_cost.h @@ -18,10 +18,10 @@ #define BROTLI_ENC_BIT_COST_H_ -#include <stdint.h> #include "./entropy_encode.h" #include "./fast_log.h" +#include "./types.h" namespace brotli { diff --git a/enc/block_splitter.h b/enc/block_splitter.h index 7ea80ea..0d24b39 100644 --- a/enc/block_splitter.h +++ b/enc/block_splitter.h @@ -17,14 +17,13 @@ #ifndef BROTLI_ENC_BLOCK_SPLITTER_H_ #define BROTLI_ENC_BLOCK_SPLITTER_H_ -#include <stddef.h> -#include <stdint.h> #include <string.h> #include <vector> #include <utility> #include "./command.h" #include "./metablock.h" +#include "./types.h" namespace brotli { diff --git a/enc/brotli_bit_stream.cc b/enc/brotli_bit_stream.cc index 23c2b9f..1990192 100644 --- a/enc/brotli_bit_stream.cc +++ b/enc/brotli_bit_stream.cc @@ -28,7 +28,6 @@ #include "./fast_log.h" #include "./prefix.h" #include "./write_bits.h" - namespace brotli { // returns false if fail @@ -275,6 +274,7 @@ void StoreHuffmanTree(const uint8_t* depths, size_t num, storage_ix, storage); } + void BuildAndStoreHuffmanTree(const int *histogram, const int length, uint8_t* depth, diff --git a/enc/brotli_bit_stream.h b/enc/brotli_bit_stream.h index 76e9976..2cf0655 100644 --- a/enc/brotli_bit_stream.h +++ b/enc/brotli_bit_stream.h @@ -24,11 +24,10 @@ #ifndef BROTLI_ENC_BROTLI_BIT_STREAM_H_ #define BROTLI_ENC_BROTLI_BIT_STREAM_H_ -#include <stddef.h> -#include <stdint.h> #include <vector> #include "./metablock.h" +#include "./types.h" namespace brotli { diff --git a/enc/cluster.h b/enc/cluster.h index 5bdbafd..ab46559 100644 --- a/enc/cluster.h +++ b/enc/cluster.h @@ -18,7 +18,6 @@ #define BROTLI_ENC_CLUSTER_H_ #include <math.h> -#include <stdint.h> #include <stdio.h> #include <algorithm> #include <complex> @@ -31,6 +30,7 @@ #include "./entropy_encode.h" #include "./fast_log.h" #include "./histogram.h" +#include "./types.h" namespace brotli { @@ -264,6 +264,7 @@ void ClusterHistograms(const std::vector<HistogramType>& in, (*histogram_symbols)[i] = i; } + const int max_input_histograms = 64; for (int i = 0; i < in_size; i += max_input_histograms) { int num_to_combine = std::min(in_size - i, max_input_histograms); @@ -282,6 +283,7 @@ void ClusterHistograms(const std::vector<HistogramType>& in, // Convert the context map to a canonical form. HistogramReindex(out, histogram_symbols); + } diff --git a/enc/command.h b/enc/command.h index db34f23..b2648db 100644 --- a/enc/command.h +++ b/enc/command.h @@ -17,9 +17,9 @@ #ifndef BROTLI_ENC_COMMAND_H_ #define BROTLI_ENC_COMMAND_H_ -#include <stdint.h> #include "./fast_log.h" #include "./prefix.h" +#include "./types.h" namespace brotli { diff --git a/enc/context.h b/enc/context.h index 5a8945f..3d7dc71 100644 --- a/enc/context.h +++ b/enc/context.h @@ -17,7 +17,7 @@ #ifndef BROTLI_ENC_CONTEXT_H_ #define BROTLI_ENC_CONTEXT_H_ -#include <stdint.h> +#include "./types.h" namespace brotli { diff --git a/enc/dictionary.h b/enc/dictionary.h index 2c0624e..4f3f49e 100644 --- a/enc/dictionary.h +++ b/enc/dictionary.h @@ -17,7 +17,7 @@ #ifndef BROTLI_ENC_DICTIONARY_H_ #define BROTLI_ENC_DICTIONARY_H_ -#include <stdint.h> +#include "./types.h" static const uint8_t kBrotliDictionary[] = { 0x74, 0x69, 0x6d, 0x65, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x69, 0x66, 0x65, 0x6c, diff --git a/enc/dictionary_hash.h b/enc/dictionary_hash.h index 0bc2762..2ce6ced 100644 --- a/enc/dictionary_hash.h +++ b/enc/dictionary_hash.h @@ -17,7 +17,7 @@ #ifndef BROTLI_ENC_DICTIONARY_HASH_H_ #define BROTLI_ENC_DICTIONARY_HASH_H_ -#include <stdint.h> +#include "./types.h" namespace brotli { diff --git a/enc/encode.cc b/enc/encode.cc index 4720adb..d4c73f9 100644 --- a/enc/encode.cc +++ b/enc/encode.cc @@ -125,16 +125,18 @@ void RecomputeDistancePrefixes(Command* cmds, uint8_t* BrotliCompressor::GetBrotliStorage(size_t size) { if (storage_size_ < size) { - storage_.reset(new uint8_t[size]); + delete[] storage_; + storage_ = new uint8_t[size]; storage_size_ = size; } - return &storage_[0]; + return storage_; } BrotliCompressor::BrotliCompressor(BrotliParams params) : params_(params), hashers_(new Hashers()), input_pos_(0), + literal_cost_(0), num_commands_(0), num_literals_(0), last_insert_len_(0), @@ -142,7 +144,8 @@ BrotliCompressor::BrotliCompressor(BrotliParams params) last_processed_pos_(0), prev_byte_(0), prev_byte2_(0), - storage_size_(0) { + storage_size_(0), + storage_(0) { // Sanitize params. params_.quality = std::max(1, params_.quality); if (params_.lgwin < kMinWindowBits) { @@ -169,15 +172,15 @@ BrotliCompressor::BrotliCompressor(BrotliParams params) // read_block_size_bits + 1 bits because the copy tail length needs to be // smaller than ringbuffer size. int ringbuffer_bits = std::max(params_.lgwin + 1, params_.lgblock + 1); - ringbuffer_.reset(new RingBuffer(ringbuffer_bits, params_.lgblock)); + ringbuffer_ = new RingBuffer(ringbuffer_bits, params_.lgblock); if (params_.quality > 9) { literal_cost_mask_ = (1 << params_.lgblock) - 1; - literal_cost_.reset(new float[literal_cost_mask_ + 1]); + literal_cost_ = new float[literal_cost_mask_ + 1]; } // Allocate command buffer. cmd_buffer_size_ = std::max(1 << 18, 1 << params_.lgblock); - commands_.reset(new brotli::Command[cmd_buffer_size_]); + commands_ = new brotli::Command[cmd_buffer_size_]; // Initialize last byte with stream header. if (params_.lgwin == 16) { @@ -209,6 +212,11 @@ BrotliCompressor::BrotliCompressor(BrotliParams params) } BrotliCompressor::~BrotliCompressor() { + delete[] storage_; + delete[] literal_cost_; + delete[] commands_; + delete ringbuffer_; + delete hashers_; } void BrotliCompressor::CopyInputToRingBuffer(const size_t input_size, @@ -292,23 +300,23 @@ bool BrotliCompressor::WriteBrotliData(const bool is_last, params_.quality >= 9 && IsMostlyUTF8(&data[last_processed_pos_ & mask], bytes, kMinUTF8Ratio); - if (literal_cost_.get()) { + if (literal_cost_) { if (utf8_mode) { EstimateBitCostsForLiteralsUTF8(last_processed_pos_, bytes, mask, literal_cost_mask_, data, - literal_cost_.get()); + literal_cost_); } else { EstimateBitCostsForLiterals(last_processed_pos_, bytes, mask, literal_cost_mask_, - data, literal_cost_.get()); + data, literal_cost_); } } CreateBackwardReferences(bytes, last_processed_pos_, data, mask, - literal_cost_.get(), + literal_cost_, literal_cost_mask_, max_backward_distance_, params_.quality, - hashers_.get(), + hashers_, hash_type_, dist_cache_, &last_insert_len_, @@ -489,14 +497,14 @@ bool BrotliCompressor::WriteMetaBlockInternal(const bool is_last, if (params_.quality > 9 && params_.mode == BrotliParams::MODE_FONT) { num_direct_distance_codes = 12; distance_postfix_bits = 1; - RecomputeDistancePrefixes(commands_.get(), + RecomputeDistancePrefixes(commands_, num_commands_, num_direct_distance_codes, distance_postfix_bits); } if (params_.quality < kMinQualityForBlockSplit) { if (!StoreMetaBlockTrivial(data, last_flush_pos_, bytes, mask, is_last, - commands_.get(), num_commands_, + commands_, num_commands_, &storage_ix, &storage[0])) { return false; @@ -514,7 +522,7 @@ bool BrotliCompressor::WriteMetaBlockInternal(const bool is_last, &literal_context_map); if (literal_context_map == NULL) { BuildMetaBlockGreedy(data, last_flush_pos_, mask, - commands_.get(), num_commands_, + commands_, num_commands_, &mb); } else { BuildMetaBlockGreedyWithContexts(data, last_flush_pos_, mask, @@ -522,13 +530,13 @@ bool BrotliCompressor::WriteMetaBlockInternal(const bool is_last, literal_context_mode, num_literal_contexts, literal_context_map, - commands_.get(), num_commands_, + commands_, num_commands_, &mb); } } else { BuildMetaBlock(data, last_flush_pos_, mask, prev_byte_, prev_byte2_, - commands_.get(), num_commands_, + commands_, num_commands_, literal_context_mode, &mb); } @@ -543,7 +551,7 @@ bool BrotliCompressor::WriteMetaBlockInternal(const bool is_last, num_direct_distance_codes, distance_postfix_bits, literal_context_mode, - commands_.get(), num_commands_, + commands_, num_commands_, mb, &storage_ix, &storage[0])) { @@ -686,7 +694,7 @@ bool BrotliInIsFinished(BrotliIn* r) { } int BrotliCompress(BrotliParams params, BrotliIn* in, BrotliOut* out) { - return BrotliCompressWithCustomDictionary(0, nullptr, params, in, out); + return BrotliCompressWithCustomDictionary(0, 0, params, in, out); } int BrotliCompressWithCustomDictionary(size_t dictsize, const uint8_t* dict, diff --git a/enc/encode.h b/enc/encode.h index ac1acae..49e32dd 100644 --- a/enc/encode.h +++ b/enc/encode.h @@ -17,8 +17,6 @@ #ifndef BROTLI_ENC_ENCODE_H_ #define BROTLI_ENC_ENCODE_H_ -#include <stddef.h> -#include <stdint.h> #include <string> #include <vector> #include "./command.h" @@ -26,6 +24,7 @@ #include "./ringbuffer.h" #include "./static_dict.h" #include "./streams.h" +#include "./types.h" namespace brotli { @@ -149,14 +148,14 @@ class BrotliCompressor { BrotliParams params_; int max_backward_distance_; - std::unique_ptr<Hashers> hashers_; + Hashers* hashers_; int hash_type_; size_t input_pos_; - std::unique_ptr<RingBuffer> ringbuffer_; - std::unique_ptr<float[]> literal_cost_; + RingBuffer* ringbuffer_; + float* literal_cost_; size_t literal_cost_mask_; size_t cmd_buffer_size_; - std::unique_ptr<Command[]> commands_; + Command* commands_; int num_commands_; int num_literals_; int last_insert_len_; @@ -169,7 +168,7 @@ class BrotliCompressor { uint8_t prev_byte_; uint8_t prev_byte2_; int storage_size_; - std::unique_ptr<uint8_t[]> storage_; + uint8_t* storage_; }; // Compresses the data in input_buffer into encoded_buffer, and sets diff --git a/enc/encode_parallel.cc b/enc/encode_parallel.cc index 4667c68..0ed93f6 100644 --- a/enc/encode_parallel.cc +++ b/enc/encode_parallel.cc @@ -167,7 +167,7 @@ bool WriteMetaBlockParallel(const BrotliParams& params, // Initialize hashers. int hash_type = std::min(9, params.quality); - std::unique_ptr<Hashers> hashers(new Hashers()); + Hashers* hashers = new Hashers(); hashers->Init(hash_type); // Compute backward references. @@ -183,13 +183,14 @@ bool WriteMetaBlockParallel(const BrotliParams& params, &literal_cost[0], mask, max_backward_distance, params.quality, - hashers.get(), + hashers, hash_type, dist_cache, &last_insert_len, &commands[0], &num_commands, &num_literals); + delete hashers; commands.resize(num_commands); if (last_insert_len > 0) { commands.push_back(Command(last_insert_len)); diff --git a/enc/encode_parallel.h b/enc/encode_parallel.h index 75dba52..d7359b1 100644 --- a/enc/encode_parallel.h +++ b/enc/encode_parallel.h @@ -19,10 +19,9 @@ #ifndef BROTLI_ENC_ENCODE_PARALLEL_H_ #define BROTLI_ENC_ENCODE_PARALLEL_H_ -#include <stddef.h> -#include <stdint.h> #include "./encode.h" +#include "./types.h" namespace brotli { diff --git a/enc/entropy_encode.cc b/enc/entropy_encode.cc index 27924db..b1dca5c 100644 --- a/enc/entropy_encode.cc +++ b/enc/entropy_encode.cc @@ -16,13 +16,13 @@ #include "./entropy_encode.h" -#include <stdint.h> #include <algorithm> #include <limits> #include <vector> #include <cstdlib> #include "./histogram.h" +#include "./types.h" namespace brotli { diff --git a/enc/entropy_encode.h b/enc/entropy_encode.h index 30652c0..352f462 100644 --- a/enc/entropy_encode.h +++ b/enc/entropy_encode.h @@ -17,11 +17,11 @@ #ifndef BROTLI_ENC_ENTROPY_ENCODE_H_ #define BROTLI_ENC_ENTROPY_ENCODE_H_ -#include <stdint.h> #include <string.h> #include <vector> #include "./histogram.h" #include "./prefix.h" +#include "./types.h" namespace brotli { diff --git a/enc/fast_log.h b/enc/fast_log.h index 19b66f3..e5692dd 100644 --- a/enc/fast_log.h +++ b/enc/fast_log.h @@ -19,7 +19,8 @@ #include <assert.h> #include <math.h> -#include <stdint.h> + +#include "./types.h" namespace brotli { diff --git a/enc/find_match_length.h b/enc/find_match_length.h index 55fd5a3..f9ea059 100644 --- a/enc/find_match_length.h +++ b/enc/find_match_length.h @@ -17,11 +17,9 @@ #ifndef BROTLI_ENC_FIND_MATCH_LENGTH_H_ #define BROTLI_ENC_FIND_MATCH_LENGTH_H_ -#include <stdint.h> - -#include <stddef.h> #include "./port.h" +#include "./types.h" namespace brotli { @@ -18,8 +18,6 @@ #ifndef BROTLI_ENC_HASH_H_ #define BROTLI_ENC_HASH_H_ -#include <stddef.h> -#include <stdint.h> #include <string.h> #include <sys/types.h> #include <algorithm> @@ -34,6 +32,7 @@ #include "./prefix.h" #include "./static_dict.h" #include "./transform.h" +#include "./types.h" namespace brotli { @@ -622,17 +621,32 @@ struct Hashers { typedef HashLongestMatch<15, 7, 10> H8; typedef HashLongestMatch<15, 8, 16> H9; + Hashers() : hash_h1(0), hash_h2(0), hash_h3(0), hash_h4(0), hash_h5(0), + hash_h6(0), hash_h7(0), hash_h8(0), hash_h9(0) {} + + ~Hashers() { + delete hash_h1; + delete hash_h2; + delete hash_h3; + delete hash_h4; + delete hash_h5; + delete hash_h6; + delete hash_h7; + delete hash_h8; + delete hash_h9; + } + void Init(int type) { switch (type) { - case 1: hash_h1.reset(new H1); break; - case 2: hash_h2.reset(new H2); break; - case 3: hash_h3.reset(new H3); break; - case 4: hash_h4.reset(new H4); break; - case 5: hash_h5.reset(new H5); break; - case 6: hash_h6.reset(new H6); break; - case 7: hash_h7.reset(new H7); break; - case 8: hash_h8.reset(new H8); break; - case 9: hash_h9.reset(new H9); break; + case 1: hash_h1 = new H1; break; + case 2: hash_h2 = new H2; break; + case 3: hash_h3 = new H3; break; + case 4: hash_h4 = new H4; break; + case 5: hash_h5 = new H5; break; + case 6: hash_h6 = new H6; break; + case 7: hash_h7 = new H7; break; + case 8: hash_h8 = new H8; break; + case 9: hash_h9 = new H9; break; default: break; } } @@ -648,28 +662,28 @@ struct Hashers { void PrependCustomDictionary( int type, const size_t size, const uint8_t* dict) { switch (type) { - case 1: WarmupHash(size, dict, hash_h1.get()); break; - case 2: WarmupHash(size, dict, hash_h2.get()); break; - case 3: WarmupHash(size, dict, hash_h3.get()); break; - case 4: WarmupHash(size, dict, hash_h4.get()); break; - case 5: WarmupHash(size, dict, hash_h5.get()); break; - case 6: WarmupHash(size, dict, hash_h6.get()); break; - case 7: WarmupHash(size, dict, hash_h7.get()); break; - case 8: WarmupHash(size, dict, hash_h8.get()); break; - case 9: WarmupHash(size, dict, hash_h9.get()); break; + case 1: WarmupHash(size, dict, hash_h1); break; + case 2: WarmupHash(size, dict, hash_h2); break; + case 3: WarmupHash(size, dict, hash_h3); break; + case 4: WarmupHash(size, dict, hash_h4); break; + case 5: WarmupHash(size, dict, hash_h5); break; + case 6: WarmupHash(size, dict, hash_h6); break; + case 7: WarmupHash(size, dict, hash_h7); break; + case 8: WarmupHash(size, dict, hash_h8); break; + case 9: WarmupHash(size, dict, hash_h9); break; default: break; } } - std::unique_ptr<H1> hash_h1; - std::unique_ptr<H2> hash_h2; - std::unique_ptr<H3> hash_h3; - std::unique_ptr<H4> hash_h4; - std::unique_ptr<H5> hash_h5; - std::unique_ptr<H6> hash_h6; - std::unique_ptr<H7> hash_h7; - std::unique_ptr<H8> hash_h8; - std::unique_ptr<H9> hash_h9; + H1* hash_h1; + H2* hash_h2; + H3* hash_h3; + H4* hash_h4; + H5* hash_h5; + H6* hash_h6; + H7* hash_h7; + H8* hash_h8; + H9* hash_h9; }; } // namespace brotli diff --git a/enc/histogram.cc b/enc/histogram.cc index ac590aa..27fe174 100644 --- a/enc/histogram.cc +++ b/enc/histogram.cc @@ -16,7 +16,6 @@ #include "./histogram.h" -#include <stdint.h> #include <cmath> #include "./block_splitter.h" diff --git a/enc/histogram.h b/enc/histogram.h index 9bc46fd..d513c66 100644 --- a/enc/histogram.h +++ b/enc/histogram.h @@ -17,13 +17,13 @@ #ifndef BROTLI_ENC_HISTOGRAM_H_ #define BROTLI_ENC_HISTOGRAM_H_ -#include <stdint.h> #include <string.h> #include <vector> #include <utility> #include "./command.h" #include "./fast_log.h" #include "./prefix.h" +#include "./types.h" namespace brotli { diff --git a/enc/literal_cost.cc b/enc/literal_cost.cc index d02a9e0..8ca81ec 100644 --- a/enc/literal_cost.cc +++ b/enc/literal_cost.cc @@ -17,10 +17,10 @@ #include "./literal_cost.h" #include <math.h> -#include <stdint.h> #include <algorithm> #include "./fast_log.h" +#include "./types.h" namespace brotli { diff --git a/enc/literal_cost.h b/enc/literal_cost.h index 5c1eca4..f511c4d 100644 --- a/enc/literal_cost.h +++ b/enc/literal_cost.h @@ -17,8 +17,7 @@ #ifndef BROTLI_ENC_LITERAL_COST_H_ #define BROTLI_ENC_LITERAL_COST_H_ -#include <stddef.h> -#include <stdint.h> +#include "./types.h" namespace brotli { @@ -18,6 +18,7 @@ #define BROTLI_ENC_PORT_H_ #include <string.h> +#include "./types.h" #if defined OS_LINUX || defined OS_CYGWIN #include <endian.h> diff --git a/enc/prefix.h b/enc/prefix.h index 552788f..b8fd9bc 100644 --- a/enc/prefix.h +++ b/enc/prefix.h @@ -18,8 +18,8 @@ #ifndef BROTLI_ENC_PREFIX_H_ #define BROTLI_ENC_PREFIX_H_ -#include <stdint.h> #include "./fast_log.h" +#include "./types.h" namespace brotli { diff --git a/enc/ringbuffer.h b/enc/ringbuffer.h index b7ff318..e1693e6 100644 --- a/enc/ringbuffer.h +++ b/enc/ringbuffer.h @@ -17,10 +17,9 @@ #ifndef BROTLI_ENC_RINGBUFFER_H_ #define BROTLI_ENC_RINGBUFFER_H_ -#include <stddef.h> -#include <stdint.h> #include "./port.h" +#include "./types.h" namespace brotli { diff --git a/enc/static_dict.h b/enc/static_dict.h index 2a890fb..08447c9 100644 --- a/enc/static_dict.h +++ b/enc/static_dict.h @@ -17,7 +17,7 @@ #ifndef BROTLI_ENC_STATIC_DICT_H_ #define BROTLI_ENC_STATIC_DICT_H_ -#include <stdint.h> +#include "./types.h" namespace brotli { diff --git a/enc/static_dict_lut.h b/enc/static_dict_lut.h index 7281d2e..1bdbebf 100644 --- a/enc/static_dict_lut.h +++ b/enc/static_dict_lut.h @@ -17,7 +17,7 @@ #ifndef BROTLI_ENC_DICTIONARY_LUT_H_ #define BROTLI_ENC_DICTIONARY_LUT_H_ -#include <stdint.h> +#include "./types.h" namespace brotli { diff --git a/enc/streams.h b/enc/streams.h index 149099e..5f8ef2d 100644 --- a/enc/streams.h +++ b/enc/streams.h @@ -17,9 +17,10 @@ #ifndef BROTLI_ENC_STREAMS_H_ #define BROTLI_ENC_STREAMS_H_ -#include <stddef.h> #include <stdio.h> #include <string> +#include "./port.h" +#include "./types.h" namespace brotli { @@ -56,7 +57,7 @@ class BrotliMemIn : public BrotliIn { // returns the amount of data consumed int position() const { return pos_; } - const void* Read(size_t n, size_t* OUTPUT) override; + const void* Read(size_t n, size_t* OUTPUT); private: const void* buf_; // start of input buffer @@ -74,7 +75,7 @@ class BrotliMemOut : public BrotliOut { // returns the amount of data written int position() const { return pos_; } - bool Write(const void* buf, size_t n) override; + bool Write(const void* buf, size_t n); private: void* buf_; // start of output buffer @@ -92,7 +93,7 @@ class BrotliStringOut : public BrotliOut { void Reset(std::string* buf, int max_len); - bool Write(const void* buf, size_t n) override; + bool Write(const void* buf, size_t n); private: std::string* buf_; // start of output buffer @@ -105,7 +106,7 @@ class BrotliFileIn : public BrotliIn { BrotliFileIn(FILE* f, size_t max_read_size); ~BrotliFileIn(); - const void* Read(size_t n, size_t* bytes_read) override; + const void* Read(size_t n, size_t* bytes_read); private: FILE* f_; @@ -118,7 +119,7 @@ class BrotliFileOut : public BrotliOut { public: explicit BrotliFileOut(FILE* f); - bool Write(const void* buf, size_t n) override; + bool Write(const void* buf, size_t n); private: FILE* f_; }; diff --git a/enc/types.h b/enc/types.h new file mode 100644 index 0000000..96e7737 --- /dev/null +++ b/enc/types.h @@ -0,0 +1,36 @@ +/* Copyright 2013 Google Inc. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/* Common types */ + +#ifndef BROTLI_ENC_TYPES_H_ +#define BROTLI_ENC_TYPES_H_ + +#include <stddef.h> /* for size_t */ + +#if defined(_MSC_VER) && (_MSC_VER < 1600) +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef unsigned long long int uint64_t; +typedef long long int int64_t; +#else +#include <stdint.h> +#endif /* defined(_MSC_VER) && (_MSC_VER < 1600) */ + +#endif /* BROTLI_ENC_TYPES_H_ */ diff --git a/enc/write_bits.h b/enc/write_bits.h index c3140c1..8978922 100644 --- a/enc/write_bits.h +++ b/enc/write_bits.h @@ -18,10 +18,10 @@ #define BROTLI_ENC_WRITE_BITS_H_ #include <assert.h> -#include <stdint.h> #include <stdio.h> #include "./port.h" +#include "./types.h" namespace brotli { @@ -176,6 +176,7 @@ brotli = Extension("brotli", "enc/static_dict_lut.h", "enc/streams.h", "enc/transform.h", + "enc/types.h", "enc/write_bits.h", "dec/bit_reader.h", "dec/context.h", |