/src/brunsli/c/common/histogram.h
Line | Count | Source |
1 | | // Copyright (c) Google LLC 2019 |
2 | | // |
3 | | // Use of this source code is governed by an MIT-style |
4 | | // license that can be found in the LICENSE file or at |
5 | | // https://opensource.org/licenses/MIT. |
6 | | |
7 | | #ifndef BRUNSLI_COMMON_HISTOGRAM_H_ |
8 | | #define BRUNSLI_COMMON_HISTOGRAM_H_ |
9 | | |
10 | | #include <brunsli/types.h> |
11 | | |
12 | | namespace brunsli { |
13 | | |
14 | | // Returns the precision (number of bits) that should be used to store |
15 | | // a histogram count such that Log2Floor(count) == logcount. |
16 | 21.1k | inline uint32_t GetPopulationCountPrecision(uint32_t logcount) { |
17 | 21.1k | return (logcount + 1) >> 1; |
18 | 21.1k | } |
19 | | |
20 | | } // namespace brunsli |
21 | | |
22 | | #endif // BRUNSLI_COMMON_HISTOGRAM_H_ |