2015-11-27 10:27:11 +00:00
|
|
|
/* Copyright 2013 Google Inc. All Rights Reserved.
|
|
|
|
|
2015-12-11 10:11:51 +00:00
|
|
|
Distributed under MIT license.
|
2015-11-27 10:27:11 +00:00
|
|
|
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
|
|
|
*/
|
|
|
|
|
2013-10-23 11:06:13 +00:00
|
|
|
// Block split point selection utilities.
|
|
|
|
|
|
|
|
#ifndef BROTLI_ENC_BLOCK_SPLITTER_H_
|
|
|
|
#define BROTLI_ENC_BLOCK_SPLITTER_H_
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "./command.h"
|
2015-03-27 13:20:35 +00:00
|
|
|
#include "./metablock.h"
|
2015-10-01 10:08:14 +00:00
|
|
|
#include "./types.h"
|
2013-10-23 11:06:13 +00:00
|
|
|
|
|
|
|
namespace brotli {
|
|
|
|
|
|
|
|
struct BlockSplitIterator {
|
|
|
|
explicit BlockSplitIterator(const BlockSplit& split)
|
|
|
|
: split_(split), idx_(0), type_(0), length_(0) {
|
2015-03-27 13:20:35 +00:00
|
|
|
if (!split.lengths.empty()) {
|
|
|
|
length_ = split.lengths[0];
|
2013-10-23 11:06:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Next() {
|
|
|
|
if (length_ == 0) {
|
|
|
|
++idx_;
|
2015-03-27 13:20:35 +00:00
|
|
|
type_ = split_.types[idx_];
|
|
|
|
length_ = split_.lengths[idx_];
|
2013-10-23 11:06:13 +00:00
|
|
|
}
|
|
|
|
--length_;
|
|
|
|
}
|
|
|
|
|
|
|
|
const BlockSplit& split_;
|
2016-01-07 15:27:49 +00:00
|
|
|
size_t idx_;
|
|
|
|
size_t type_;
|
|
|
|
size_t length_;
|
2013-10-23 11:06:13 +00:00
|
|
|
};
|
|
|
|
|
2015-04-23 11:15:42 +00:00
|
|
|
void CopyLiteralsToByteArray(const Command* cmds,
|
|
|
|
const size_t num_commands,
|
2013-10-23 11:06:13 +00:00
|
|
|
const uint8_t* data,
|
2015-07-30 15:42:02 +00:00
|
|
|
const size_t offset,
|
|
|
|
const size_t mask,
|
2013-10-23 11:06:13 +00:00
|
|
|
std::vector<uint8_t>* literals);
|
|
|
|
|
2015-04-23 11:15:42 +00:00
|
|
|
void SplitBlock(const Command* cmds,
|
|
|
|
const size_t num_commands,
|
2013-10-23 11:06:13 +00:00
|
|
|
const uint8_t* data,
|
2015-07-30 15:42:02 +00:00
|
|
|
const size_t offset,
|
|
|
|
const size_t mask,
|
2013-10-23 11:06:13 +00:00
|
|
|
BlockSplit* literal_split,
|
|
|
|
BlockSplit* insert_and_copy_split,
|
|
|
|
BlockSplit* dist_split);
|
|
|
|
|
|
|
|
} // namespace brotli
|
|
|
|
|
|
|
|
#endif // BROTLI_ENC_BLOCK_SPLITTER_H_
|