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

Side by Side Diff: third_party/brotli/enc/encode.cc

Issue 1995193003: Update brotli 11 May 2016 (4cc756) -> 20 May 2016 (4836af) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months 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 unified diff | Download patch
« no previous file with comments | « third_party/brotli/enc/encode.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright 2013 Google Inc. All Rights Reserved. 1 /* Copyright 2013 Google Inc. All Rights Reserved.
2 2
3 Distributed under MIT license. 3 Distributed under MIT license.
4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5 */ 5 */
6 6
7 // Implementation of Brotli compressor. 7 // Implementation of Brotli compressor.
8 8
9 #include "./encode.h" 9 #include "./encode.h"
10 10
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 last_insert_len_(0), 435 last_insert_len_(0),
436 last_flush_pos_(0), 436 last_flush_pos_(0),
437 last_processed_pos_(0), 437 last_processed_pos_(0),
438 prev_byte_(0), 438 prev_byte_(0),
439 prev_byte2_(0), 439 prev_byte2_(0),
440 storage_size_(0), 440 storage_size_(0),
441 storage_(0), 441 storage_(0),
442 large_table_(NULL), 442 large_table_(NULL),
443 cmd_code_numbits_(0), 443 cmd_code_numbits_(0),
444 command_buf_(NULL), 444 command_buf_(NULL),
445 literal_buf_(NULL) { 445 literal_buf_(NULL),
446 is_last_block_emitted_(0) {
446 // Sanitize params. 447 // Sanitize params.
447 params_.quality = std::max(0, params_.quality); 448 params_.quality = std::max(0, params_.quality);
448 if (params_.lgwin < kMinWindowBits) { 449 if (params_.lgwin < kMinWindowBits) {
449 params_.lgwin = kMinWindowBits; 450 params_.lgwin = kMinWindowBits;
450 } else if (params_.lgwin > kMaxWindowBits) { 451 } else if (params_.lgwin > kMaxWindowBits) {
451 params_.lgwin = kMaxWindowBits; 452 params_.lgwin = kMaxWindowBits;
452 } 453 }
453 if (params_.quality <= 1) { 454 if (params_.quality <= 1) {
454 params_.lgblock = params_.lgwin; 455 params_.lgblock = params_.lgwin;
455 } else if (params_.quality < kMinQualityForBlockSplit) { 456 } else if (params_.quality < kMinQualityForBlockSplit) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 } 577 }
577 578
578 bool BrotliCompressor::WriteBrotliData(const bool is_last, 579 bool BrotliCompressor::WriteBrotliData(const bool is_last,
579 const bool force_flush, 580 const bool force_flush,
580 size_t* out_size, 581 size_t* out_size,
581 uint8_t** output) { 582 uint8_t** output) {
582 const uint64_t delta = input_pos_ - last_processed_pos_; 583 const uint64_t delta = input_pos_ - last_processed_pos_;
583 const uint8_t* data = ringbuffer_->start(); 584 const uint8_t* data = ringbuffer_->start();
584 const uint32_t mask = ringbuffer_->mask(); 585 const uint32_t mask = ringbuffer_->mask();
585 586
587 /* Adding more blocks after "last" block is forbidden. */
588 if (is_last_block_emitted_) return false;
589 if (is_last) is_last_block_emitted_ = 1;
590
586 if (delta > input_block_size()) { 591 if (delta > input_block_size()) {
587 return false; 592 return false;
588 } 593 }
589 const uint32_t bytes = static_cast<uint32_t>(delta); 594 const uint32_t bytes = static_cast<uint32_t>(delta);
590 595
591 if (params_.quality <= 1) { 596 if (params_.quality <= 1) {
592 if (delta == 0 && !is_last) { 597 if (delta == 0 && !is_last) {
593 // We have no new input data and we don't have to finish the stream, so 598 // We have no new input data and we don't have to finish the stream, so
594 // nothing to do. 599 // nothing to do.
595 *out_size = 0; 600 *out_size = 0;
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 } 1171 }
1167 if (out_bytes > 0 && !out->Write(output, out_bytes)) { 1172 if (out_bytes > 0 && !out->Write(output, out_bytes)) {
1168 return false; 1173 return false;
1169 } 1174 }
1170 } 1175 }
1171 return true; 1176 return true;
1172 } 1177 }
1173 1178
1174 1179
1175 } // namespace brotli 1180 } // namespace brotli
OLDNEW
« no previous file with comments | « third_party/brotli/enc/encode.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698