]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/C/BrotliCompress/enc/block_encoder_inc.h
BaseTools: Copy Brotli algorithm 3rd party source code for tool
[mirror_edk2.git] / BaseTools / Source / C / BrotliCompress / enc / block_encoder_inc.h
CommitLineData
11b7501a
SB
1/* NOLINT(build/header_guard) */\r
2/* Copyright 2014 Google Inc. All Rights Reserved.\r
3\r
4 Distributed under MIT license.\r
5 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT\r
6*/\r
7\r
8/* template parameters: FN */\r
9\r
10#define HistogramType FN(Histogram)\r
11\r
12/* Creates entropy codes for all block types and stores them to the bit\r
13 stream. */\r
14static void FN(BuildAndStoreEntropyCodes)(MemoryManager* m, BlockEncoder* self,\r
15 const HistogramType* histograms, const size_t histograms_size,\r
16 HuffmanTree* tree, size_t* storage_ix, uint8_t* storage) {\r
17 const size_t alphabet_size = self->alphabet_size_;\r
18 const size_t table_size = histograms_size * alphabet_size;\r
19 self->depths_ = BROTLI_ALLOC(m, uint8_t, table_size);\r
20 self->bits_ = BROTLI_ALLOC(m, uint16_t, table_size);\r
21 if (BROTLI_IS_OOM(m)) return;\r
22\r
23 {\r
24 size_t i;\r
25 for (i = 0; i < histograms_size; ++i) {\r
26 size_t ix = i * alphabet_size;\r
27 BuildAndStoreHuffmanTree(&histograms[i].data_[0], alphabet_size, tree,\r
28 &self->depths_[ix], &self->bits_[ix], storage_ix, storage);\r
29 }\r
30 }\r
31}\r
32\r
33#undef HistogramType\r