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

Side by Side Diff: third_party/brotli/enc/histogram_inc.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 unified diff | Download patch
« no previous file with comments | « third_party/brotli/enc/histogram.cc ('k') | third_party/brotli/enc/literal_cost.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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; }
OLDNEW
« no previous file with comments | « third_party/brotli/enc/histogram.cc ('k') | third_party/brotli/enc/literal_cost.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698