Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/brotli/c/enc/histogram_inc.h @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 /* NOLINT(build/header_guard) */ | |
| 2 /* Copyright 2013 Google Inc. All Rights Reserved. | |
| 3 | |
| 4 Distributed under MIT license. | |
| 5 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT | |
| 6 */ | |
| 7 | |
| 8 /* template parameters: Histogram, DATA_SIZE, DataType */ | |
| 9 | |
| 10 /* A simple container for histograms of data in blocks. */ | |
| 11 | |
| 12 typedef struct FN(Histogram) { | |
| 13 uint32_t data_[DATA_SIZE]; | |
| 14 size_t total_count_; | |
| 15 double bit_cost_; | |
| 16 } FN(Histogram); | |
| 17 | |
| 18 static BROTLI_INLINE void FN(HistogramClear)(FN(Histogram)* self) { | |
| 19 memset(self->data_, 0, sizeof(self->data_)); | |
| 20 self->total_count_ = 0; | |
| 21 self->bit_cost_ = HUGE_VAL; | |
| 22 } | |
| 23 | |
| 24 static BROTLI_INLINE void FN(ClearHistograms)( | |
| 25 FN(Histogram)* array, size_t length) { | |
| 26 size_t i; | |
| 27 for (i = 0; i < length; ++i) FN(HistogramClear)(array + i); | |
| 28 } | |
| 29 | |
| 30 static BROTLI_INLINE void FN(HistogramAdd)(FN(Histogram)* self, size_t val) { | |
| 31 ++self->data_[val]; | |
| 32 ++self->total_count_; | |
| 33 } | |
| 34 | |
| 35 static BROTLI_INLINE void FN(HistogramAddVector)(FN(Histogram)* self, | |
| 36 const DataType* p, size_t n) { | |
| 37 self->total_count_ += n; | |
| 38 n += 1; | |
| 39 while (--n) ++self->data_[*p++]; | |
| 40 } | |
| 41 | |
| 42 static BROTLI_INLINE void FN(HistogramAddHistogram)(FN(Histogram)* self, | |
| 43 const FN(Histogram)* v) { | |
| 44 size_t i; | |
| 45 self->total_count_ += v->total_count_; | |
| 46 for (i = 0; i < DATA_SIZE; ++i) { | |
| 47 self->data_[i] += v->data_[i]; | |
| 48 } | |
| 49 } | |
| 50 | |
| 51 static BROTLI_INLINE size_t FN(HistogramDataSize)(void) { return DATA_SIZE; } |
