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

Unified Diff: third_party/brotli/enc/histogram.h

Issue 2537133002: Update brotli to v1.0.0-snapshot. (Closed)
Patch Set: Fixed typo Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/brotli/enc/hash_longest_match_quickly_inc.h ('k') | third_party/brotli/enc/histogram.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/brotli/enc/histogram.h
diff --git a/third_party/brotli/enc/histogram.h b/third_party/brotli/enc/histogram.h
index a1153c859a471ef2ac124a69ed53dd9ba8c8e84b..2161574b3bbca9181667b7a76c36be022147a77f 100644
--- a/third_party/brotli/enc/histogram.h
+++ b/third_party/brotli/enc/histogram.h
@@ -4,91 +4,57 @@
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/
-// Models the histograms of literals, commands and distance codes.
+/* Models the histograms of literals, commands and distance codes. */
#ifndef BROTLI_ENC_HISTOGRAM_H_
#define BROTLI_ENC_HISTOGRAM_H_
-#include <cstring>
-#include <limits>
-#include <vector>
-#include "./context.h"
-#include "./command.h"
-#include "./fast_log.h"
-#include "./prefix.h"
-#include "./types.h"
-
-namespace brotli {
-
-struct BlockSplit;
-
-// A simple container for histograms of data in blocks.
-template<int kDataSize>
-struct Histogram {
- Histogram(void) {
- Clear();
- }
- void Clear(void) {
- memset(data_, 0, sizeof(data_));
- total_count_ = 0;
- bit_cost_ = std::numeric_limits<double>::infinity();
- }
- void Add(size_t val) {
- ++data_[val];
- ++total_count_;
- }
- void Remove(size_t val) {
- --data_[val];
- --total_count_;
- }
- template<typename DataType>
- void Add(const DataType *p, size_t n) {
- total_count_ += n;
- n += 1;
- while(--n) ++data_[*p++];
- }
- void AddHistogram(const Histogram& v) {
- total_count_ += v.total_count_;
- for (size_t i = 0; i < kDataSize; ++i) {
- data_[i] += v.data_[i];
- }
- }
-
- uint32_t data_[kDataSize];
- size_t total_count_;
- double bit_cost_;
-};
+#include <string.h> /* memset */
-// Literal histogram.
-typedef Histogram<256> HistogramLiteral;
-// Prefix histograms.
-typedef Histogram<kNumCommandPrefixes> HistogramCommand;
-typedef Histogram<kNumDistancePrefixes> HistogramDistance;
-typedef Histogram<kNumBlockLenPrefixes> HistogramBlockLength;
-// Context map histogram, 256 Huffman tree indexes + 16 run length codes.
-typedef Histogram<272> HistogramContextMap;
-// Block type histogram, 256 block types + 2 special symbols.
-typedef Histogram<258> HistogramBlockType;
-
-static const size_t kLiteralContextBits = 6;
-static const size_t kDistanceContextBits = 2;
-
-void BuildHistograms(
- const Command* cmds,
- const size_t num_commands,
- const BlockSplit& literal_split,
- const BlockSplit& insert_and_copy_split,
- const BlockSplit& dist_split,
- const uint8_t* ringbuffer,
- size_t pos,
- size_t mask,
- uint8_t prev_byte,
- uint8_t prev_byte2,
- const std::vector<ContextType>& context_modes,
- std::vector<HistogramLiteral>* literal_histograms,
- std::vector<HistogramCommand>* insert_and_copy_histograms,
- std::vector<HistogramDistance>* copy_dist_histograms);
-
-} // namespace brotli
-
-#endif // BROTLI_ENC_HISTOGRAM_H_
+#include "../common/constants.h"
+#include <brotli/types.h>
+#include "./block_splitter.h"
+#include "./command.h"
+#include "./context.h"
+#include "./port.h"
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+#define FN(X) X ## Literal
+#define DATA_SIZE BROTLI_NUM_LITERAL_SYMBOLS
+#define DataType uint8_t
+#include "./histogram_inc.h" /* NOLINT(build/include) */
+#undef DataType
+#undef DATA_SIZE
+#undef FN
+
+#define FN(X) X ## Command
+#define DataType uint16_t
+#define DATA_SIZE BROTLI_NUM_COMMAND_SYMBOLS
+#include "./histogram_inc.h" /* NOLINT(build/include) */
+#undef DATA_SIZE
+#undef FN
+
+#define FN(X) X ## Distance
+#define DATA_SIZE BROTLI_NUM_DISTANCE_SYMBOLS
+#include "./histogram_inc.h" /* NOLINT(build/include) */
+#undef DataType
+#undef DATA_SIZE
+#undef FN
+
+BROTLI_INTERNAL void BrotliBuildHistogramsWithContext(
+ const Command* cmds, const size_t num_commands,
+ const BlockSplit* literal_split, const BlockSplit* insert_and_copy_split,
+ const BlockSplit* dist_split, const uint8_t* ringbuffer, size_t pos,
+ size_t mask, uint8_t prev_byte, uint8_t prev_byte2,
+ const ContextType* context_modes, HistogramLiteral* literal_histograms,
+ HistogramCommand* insert_and_copy_histograms,
+ HistogramDistance* copy_dist_histograms);
+
+#if defined(__cplusplus) || defined(c_plusplus)
+} /* extern "C" */
+#endif
+
+#endif /* BROTLI_ENC_HISTOGRAM_H_ */
« no previous file with comments | « third_party/brotli/enc/hash_longest_match_quickly_inc.h ('k') | third_party/brotli/enc/histogram.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698