| Index: third_party/brotli/enc/metablock.h
|
| diff --git a/third_party/brotli/enc/metablock.h b/third_party/brotli/enc/metablock.h
|
| index d19288505906e7c0011b7f4bbc7c7672826f0b5e..da29d8135490165dfae257cd9390710e4872e626 100644
|
| --- a/third_party/brotli/enc/metablock.h
|
| +++ b/third_party/brotli/enc/metablock.h
|
| @@ -4,77 +4,107 @@
|
| See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
| */
|
|
|
| -// Algorithms for distributing the literals and commands of a metablock between
|
| -// block types and contexts.
|
| +/* Algorithms for distributing the literals and commands of a metablock between
|
| + block types and contexts. */
|
|
|
| #ifndef BROTLI_ENC_METABLOCK_H_
|
| #define BROTLI_ENC_METABLOCK_H_
|
|
|
| -#include <vector>
|
| -
|
| +#include <brotli/types.h>
|
| +#include "./block_splitter.h"
|
| #include "./command.h"
|
| +#include "./context.h"
|
| #include "./histogram.h"
|
| +#include "./memory.h"
|
| +#include "./port.h"
|
| +#include "./quality.h"
|
|
|
| -namespace brotli {
|
| -
|
| -struct BlockSplit {
|
| - BlockSplit(void) : num_types(0) {}
|
| -
|
| - size_t num_types;
|
| - std::vector<uint8_t> types;
|
| - std::vector<uint32_t> lengths;
|
| -};
|
| +#if defined(__cplusplus) || defined(c_plusplus)
|
| +extern "C" {
|
| +#endif
|
|
|
| -struct MetaBlockSplit {
|
| +typedef struct MetaBlockSplit {
|
| BlockSplit literal_split;
|
| BlockSplit command_split;
|
| BlockSplit distance_split;
|
| - std::vector<uint32_t> literal_context_map;
|
| - std::vector<uint32_t> distance_context_map;
|
| - std::vector<HistogramLiteral> literal_histograms;
|
| - std::vector<HistogramCommand> command_histograms;
|
| - std::vector<HistogramDistance> distance_histograms;
|
| -};
|
| + uint32_t* literal_context_map;
|
| + size_t literal_context_map_size;
|
| + uint32_t* distance_context_map;
|
| + size_t distance_context_map_size;
|
| + HistogramLiteral* literal_histograms;
|
| + size_t literal_histograms_size;
|
| + HistogramCommand* command_histograms;
|
| + size_t command_histograms_size;
|
| + HistogramDistance* distance_histograms;
|
| + size_t distance_histograms_size;
|
| +} MetaBlockSplit;
|
| +
|
| +static BROTLI_INLINE void InitMetaBlockSplit(MetaBlockSplit* mb) {
|
| + BrotliInitBlockSplit(&mb->literal_split);
|
| + BrotliInitBlockSplit(&mb->command_split);
|
| + BrotliInitBlockSplit(&mb->distance_split);
|
| + mb->literal_context_map = 0;
|
| + mb->literal_context_map_size = 0;
|
| + mb->distance_context_map = 0;
|
| + mb->distance_context_map_size = 0;
|
| + mb->literal_histograms = 0;
|
| + mb->literal_histograms_size = 0;
|
| + mb->command_histograms = 0;
|
| + mb->command_histograms_size = 0;
|
| + mb->distance_histograms = 0;
|
| + mb->distance_histograms_size = 0;
|
| +}
|
| +
|
| +static BROTLI_INLINE void DestroyMetaBlockSplit(
|
| + MemoryManager* m, MetaBlockSplit* mb) {
|
| + BrotliDestroyBlockSplit(m, &mb->literal_split);
|
| + BrotliDestroyBlockSplit(m, &mb->command_split);
|
| + BrotliDestroyBlockSplit(m, &mb->distance_split);
|
| + BROTLI_FREE(m, mb->literal_context_map);
|
| + BROTLI_FREE(m, mb->distance_context_map);
|
| + BROTLI_FREE(m, mb->literal_histograms);
|
| + BROTLI_FREE(m, mb->command_histograms);
|
| + BROTLI_FREE(m, mb->distance_histograms);
|
| +}
|
|
|
| -// Uses the slow shortest-path block splitter and does context clustering.
|
| -void BuildMetaBlock(const uint8_t* ringbuffer,
|
| - const size_t pos,
|
| - const size_t mask,
|
| - uint8_t prev_byte,
|
| - uint8_t prev_byte2,
|
| - const Command* cmds,
|
| - size_t num_commands,
|
| - ContextType literal_context_mode,
|
| - MetaBlockSplit* mb);
|
| +/* Uses the slow shortest-path block splitter and does context clustering. */
|
| +BROTLI_INTERNAL void BrotliBuildMetaBlock(MemoryManager* m,
|
| + const uint8_t* ringbuffer,
|
| + const size_t pos,
|
| + const size_t mask,
|
| + const BrotliEncoderParams* params,
|
| + uint8_t prev_byte,
|
| + uint8_t prev_byte2,
|
| + const Command* cmds,
|
| + size_t num_commands,
|
| + ContextType literal_context_mode,
|
| + MetaBlockSplit* mb);
|
|
|
| -// Uses a fast greedy block splitter that tries to merge current block with the
|
| -// last or the second last block and does not do any context modeling.
|
| -void BuildMetaBlockGreedy(const uint8_t* ringbuffer,
|
| - size_t pos,
|
| - size_t mask,
|
| - const Command *commands,
|
| - size_t n_commands,
|
| - MetaBlockSplit* mb);
|
| +/* Uses a fast greedy block splitter that tries to merge current block with the
|
| + last or the second last block and does not do any context modeling. */
|
| +BROTLI_INTERNAL void BrotliBuildMetaBlockGreedy(MemoryManager* m,
|
| + const uint8_t* ringbuffer,
|
| + size_t pos,
|
| + size_t mask,
|
| + const Command* commands,
|
| + size_t n_commands,
|
| + MetaBlockSplit* mb);
|
|
|
| -// Uses a fast greedy block splitter that tries to merge current block with the
|
| -// last or the second last block and uses a static context clustering which
|
| -// is the same for all block types.
|
| -void BuildMetaBlockGreedyWithContexts(const uint8_t* ringbuffer,
|
| - size_t pos,
|
| - size_t mask,
|
| - uint8_t prev_byte,
|
| - uint8_t prev_byte2,
|
| - ContextType literal_context_mode,
|
| - size_t num_contexts,
|
| - const uint32_t* static_context_map,
|
| - const Command *commands,
|
| - size_t n_commands,
|
| - MetaBlockSplit* mb);
|
| +/* Uses a fast greedy block splitter that tries to merge current block with the
|
| + last or the second last block and uses a static context clustering which
|
| + is the same for all block types. */
|
| +BROTLI_INTERNAL void BrotliBuildMetaBlockGreedyWithContexts(
|
| + MemoryManager* m, const uint8_t* ringbuffer, size_t pos, size_t mask,
|
| + uint8_t prev_byte, uint8_t prev_byte2, ContextType literal_context_mode,
|
| + size_t num_contexts, const uint32_t* static_context_map,
|
| + const Command* commands, size_t n_commands, MetaBlockSplit* mb);
|
|
|
| -void OptimizeHistograms(size_t num_direct_distance_codes,
|
| - size_t distance_postfix_bits,
|
| - MetaBlockSplit* mb);
|
| +BROTLI_INTERNAL void BrotliOptimizeHistograms(size_t num_direct_distance_codes,
|
| + size_t distance_postfix_bits,
|
| + MetaBlockSplit* mb);
|
|
|
| -} // namespace brotli
|
| +#if defined(__cplusplus) || defined(c_plusplus)
|
| +} /* extern "C" */
|
| +#endif
|
|
|
| -#endif // BROTLI_ENC_METABLOCK_H_
|
| +#endif /* BROTLI_ENC_METABLOCK_H_ */
|
|
|