+++ /dev/null
-/* NOLINT(build/header_guard) */\r
-/* Copyright 2013 Google Inc. All Rights Reserved.\r
-\r
- Distributed under MIT license.\r
- See file LICENSE for detail or copy at https://opensource.org/licenses/MIT\r
-*/\r
-\r
-/* template parameters: Histogram, DATA_SIZE, DataType */\r
-\r
-/* A simple container for histograms of data in blocks. */\r
-\r
-typedef struct FN(Histogram) {\r
- uint32_t data_[DATA_SIZE];\r
- size_t total_count_;\r
- double bit_cost_;\r
-} FN(Histogram);\r
-\r
-static BROTLI_INLINE void FN(HistogramClear)(FN(Histogram)* self) {\r
- memset(self->data_, 0, sizeof(self->data_));\r
- self->total_count_ = 0;\r
- self->bit_cost_ = HUGE_VAL;\r
-}\r
-\r
-static BROTLI_INLINE void FN(ClearHistograms)(\r
- FN(Histogram)* array, size_t length) {\r
- size_t i;\r
- for (i = 0; i < length; ++i) FN(HistogramClear)(array + i);\r
-}\r
-\r
-static BROTLI_INLINE void FN(HistogramAdd)(FN(Histogram)* self, size_t val) {\r
- ++self->data_[val];\r
- ++self->total_count_;\r
-}\r
-\r
-static BROTLI_INLINE void FN(HistogramAddVector)(FN(Histogram)* self,\r
- const DataType* p, size_t n) {\r
- self->total_count_ += n;\r
- n += 1;\r
- while (--n) ++self->data_[*p++];\r
-}\r
-\r
-static BROTLI_INLINE void FN(HistogramAddHistogram)(FN(Histogram)* self,\r
- const FN(Histogram)* v) {\r
- size_t i;\r
- self->total_count_ += v->total_count_;\r
- for (i = 0; i < DATA_SIZE; ++i) {\r
- self->data_[i] += v->data_[i];\r
- }\r
-}\r
-\r
-static BROTLI_INLINE size_t FN(HistogramDataSize)(void) { return DATA_SIZE; }\r