update brotli to 0.5.0
This commit is contained in:
@@ -90,9 +90,9 @@ vars = {
|
||||
"libpng_src": "https://github.com/glennrp/libpng.git",
|
||||
"libpng_revision": "@a36c4f3f165fb2dd1772603da7f996eb40326621",
|
||||
|
||||
# Brotli v0.3.0
|
||||
# Brotli v0.5.0-snapshot
|
||||
"brotli_src": "https://github.com/google/brotli.git",
|
||||
"brotli_revision": "@98ed7a23a83d64133b0a36a884e489bffb0eb864",
|
||||
"brotli_revision": "@e4c891420c004581cba43d918e73f446affdbbbb",
|
||||
|
||||
"proto_src": "https://github.com/google/protobuf.git",
|
||||
"protobuf_revision": "v3.0.0-beta-2",
|
||||
|
||||
@@ -24,16 +24,11 @@
|
||||
#include "base/logging.h"
|
||||
#include "third_party/brotli/src/dec/decode.h"
|
||||
#include "third_party/brotli/src/enc/encode.h"
|
||||
#include "third_party/brotli/src/enc/streams.h"
|
||||
#include "pagespeed/kernel/base/message_handler.h"
|
||||
#include "pagespeed/kernel/base/string.h"
|
||||
#include "pagespeed/kernel/base/stack_buffer.h"
|
||||
#include "pagespeed/kernel/base/writer.h"
|
||||
|
||||
using brotli::BrotliMemIn;
|
||||
using brotli::BrotliParams;
|
||||
using brotli::BrotliStringOut;
|
||||
|
||||
namespace net_instaweb {
|
||||
|
||||
BrotliInflater::BrotliInflater()
|
||||
@@ -52,18 +47,19 @@ void BrotliInflater::ResetState() {
|
||||
|
||||
bool BrotliInflater::Compress(StringPiece in, int compression_level,
|
||||
MessageHandler* handler, Writer* writer) {
|
||||
// For creating a BrotliStringOut.
|
||||
GoogleString out_str;
|
||||
// Set the compression level ("quality" in brotli terms).
|
||||
BrotliParams params;
|
||||
params.quality = compression_level;
|
||||
BrotliMemIn brotli_input(in.data(), in.length());
|
||||
BrotliStringOut brotli_output(&out_str, std::numeric_limits<int>::max());
|
||||
size_t compressed_size = BrotliEncoderMaxCompressedSize(in.length());
|
||||
uint8_t* compressed = new uint8_t[compressed_size];
|
||||
// Compress in one shot with BrotliCompress.
|
||||
if (BrotliCompress(params, &brotli_input, &brotli_output)) {
|
||||
return writer->Write(out_str, handler);
|
||||
bool result = false;
|
||||
if (BrotliEncoderCompress(compression_level, BROTLI_DEFAULT_WINDOW,
|
||||
BROTLI_DEFAULT_MODE, in.length(),
|
||||
reinterpret_cast<const uint8_t*>(in.data()),
|
||||
&compressed_size, compressed)) {
|
||||
StringPiece chunk(reinterpret_cast<char*>(compressed), compressed_size);
|
||||
result = writer->Write(chunk, handler);
|
||||
}
|
||||
return false;
|
||||
delete[] compressed;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool BrotliInflater::Compress(StringPiece in, MessageHandler* handler,
|
||||
@@ -108,12 +104,8 @@ bool BrotliInflater::DecompressHelper(StringPiece in, MessageHandler* handler,
|
||||
// Decompression succeeded, write out the last chunk if needed.
|
||||
break;
|
||||
case BROTLI_RESULT_ERROR:
|
||||
#ifdef BROTLI_ERROR_CODES_LIST
|
||||
handler->Message(kError, "%s",
|
||||
BrotliErrorString(BrotliGetErrorCode(brotli_state_.get())));
|
||||
#else
|
||||
handler->Message(kError, "BROTLI_RESULT_ERROR");
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
StringPiece chunk(output, sizeof(output) - available_out);
|
||||
|
||||
Vendored
+48
-22
@@ -2,9 +2,26 @@
|
||||
# all files in the enc directory go into brotli_enc.
|
||||
{
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'brotli_common',
|
||||
'type': 'static_library',
|
||||
'include_dirs': [
|
||||
'src/common',
|
||||
],
|
||||
'sources': [
|
||||
'src/common/constants.h',
|
||||
'src/common/dictionary.c',
|
||||
'src/common/dictionary.h',
|
||||
'src/common/port.h',
|
||||
'src/common/types.h',
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'brotli_dec',
|
||||
'type': 'static_library',
|
||||
'dependencies': [
|
||||
'brotli_common',
|
||||
],
|
||||
'include_dirs': [
|
||||
'src/dec',
|
||||
],
|
||||
@@ -14,65 +31,74 @@
|
||||
'src/dec/context.h',
|
||||
'src/dec/decode.c',
|
||||
'src/dec/decode.h',
|
||||
'src/dec/dictionary.h',
|
||||
'src/dec/huffman.c',
|
||||
'src/dec/huffman.h',
|
||||
'src/dec/port.h',
|
||||
'src/dec/prefix.h',
|
||||
'src/dec/state.c',
|
||||
'src/dec/state.h',
|
||||
'src/dec/streams.c',
|
||||
'src/dec/streams.h',
|
||||
'src/dec/transform.h',
|
||||
'src/dec/types.h',
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'brotli_enc',
|
||||
'type': 'static_library',
|
||||
'dependencies': [
|
||||
'brotli_common',
|
||||
],
|
||||
'include_dirs': [
|
||||
'src/enc',
|
||||
],
|
||||
'sources': [
|
||||
'src/enc/backward_references.cc',
|
||||
'src/enc/backward_references.c',
|
||||
'src/enc/backward_references.h',
|
||||
'src/enc/backward_references_inc.h',
|
||||
'src/enc/bit_cost.c',
|
||||
'src/enc/bit_cost.h',
|
||||
'src/enc/block_splitter.cc',
|
||||
'src/enc/bit_cost_inc.h',
|
||||
'src/enc/block_encoder_inc.h',
|
||||
'src/enc/block_splitter.c',
|
||||
'src/enc/block_splitter.h',
|
||||
'src/enc/brotli_bit_stream.cc',
|
||||
'src/enc/block_splitter_inc.h',
|
||||
'src/enc/brotli_bit_stream.c',
|
||||
'src/enc/brotli_bit_stream.h',
|
||||
'src/enc/cluster.c',
|
||||
'src/enc/cluster.h',
|
||||
'src/enc/cluster_inc.h',
|
||||
'src/enc/command.h',
|
||||
'src/enc/compress_fragment.c',
|
||||
'src/enc/compress_fragment.h',
|
||||
'src/enc/compress_fragment_two_pass.c',
|
||||
'src/enc/compress_fragment_two_pass.h',
|
||||
'src/enc/context.h',
|
||||
'src/enc/dictionary.cc',
|
||||
'src/enc/dictionary.h',
|
||||
'src/enc/dictionary_hash.h',
|
||||
'src/enc/encode.cc',
|
||||
'src/enc/encode.c',
|
||||
'src/enc/encode.h',
|
||||
'src/enc/encode_parallel.cc',
|
||||
'src/enc/encode_parallel.h',
|
||||
'src/enc/entropy_encode.cc',
|
||||
'src/enc/entropy_encode.c',
|
||||
'src/enc/entropy_encode.h',
|
||||
'src/enc/entropy_encode_static.h',
|
||||
'src/enc/fast_log.h',
|
||||
'src/enc/find_match_length.h',
|
||||
'src/enc/hash.h',
|
||||
'src/enc/histogram.cc',
|
||||
'src/enc/hash_longest_match_inc.h',
|
||||
'src/enc/hash_longest_match_quickly_inc.h',
|
||||
'src/enc/histogram.c',
|
||||
'src/enc/histogram.h',
|
||||
'src/enc/literal_cost.cc',
|
||||
'src/enc/histogram_inc.h',
|
||||
'src/enc/literal_cost.c',
|
||||
'src/enc/literal_cost.h',
|
||||
'src/enc/metablock.cc',
|
||||
'src/enc/memory.c',
|
||||
'src/enc/memory.h',
|
||||
'src/enc/metablock.c',
|
||||
'src/enc/metablock.h',
|
||||
'src/enc/metablock_inc.h',
|
||||
'src/enc/port.h',
|
||||
'src/enc/prefix.h',
|
||||
'src/enc/ringbuffer.h',
|
||||
'src/enc/static_dict.cc',
|
||||
'src/enc/static_dict.c',
|
||||
'src/enc/static_dict.h',
|
||||
'src/enc/static_dict_lut.h',
|
||||
'src/enc/streams.cc',
|
||||
'src/enc/streams.h',
|
||||
'src/enc/transform.h',
|
||||
'src/enc/types.h',
|
||||
'src/enc/utf8_util.cc',
|
||||
'src/enc/utf8_util.c',
|
||||
'src/enc/utf8_util.h',
|
||||
'src/enc/write_bits.h',
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user