]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/BrotliCompress/enc/histogram_inc.h
1 /* NOLINT(build/header_guard) */
2 /* Copyright 2013 Google Inc. All Rights Reserved.
4 Distributed under MIT license.
5 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
8 /* template parameters: Histogram, DATA_SIZE, DataType */
10 /* A simple container for histograms of data in blocks. */
12 typedef struct FN(Histogram
) {
13 uint32_t data_
[DATA_SIZE
];
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
;
24 static BROTLI_INLINE
void FN(ClearHistograms
)(
25 FN(Histogram
)* array
, size_t length
) {
27 for (i
= 0; i
< length
; ++i
) FN(HistogramClear
)(array
+ i
);
30 static BROTLI_INLINE
void FN(HistogramAdd
)(FN(Histogram
)* self
, size_t val
) {
35 static BROTLI_INLINE
void FN(HistogramAddVector
)(FN(Histogram
)* self
,
36 const DataType
*p
, size_t n
) {
37 self
->total_count_
+= n
;
39 while (--n
) ++self
->data_
[*p
++];
42 static BROTLI_INLINE
void FN(HistogramAddHistogram
)(FN(Histogram
)* self
,
43 const FN(Histogram
)* v
) {
45 self
->total_count_
+= v
->total_count_
;
46 for (i
= 0; i
< DATA_SIZE
; ++i
) {
47 self
->data_
[i
] += v
->data_
[i
];
51 static BROTLI_INLINE
size_t FN(HistogramDataSize
)(void) { return DATA_SIZE
; }