Coverage Report

Created: 2026-09-01 06:23

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/brunsli/c/dec/ans_decode.cc
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
#include "./ans_decode.h"
8
9
#include <brunsli/types.h>
10
11
#include <vector>
12
13
#include "../common/ans_params.h"
14
15
namespace brunsli {
16
17
21.6k
bool ANSDecodingData::Init(const std::vector<uint32_t>& counts) {
18
21.6k
  size_t pos = 0;
19
410k
  for (size_t i = 0; i < counts.size(); ++i) {
20
22.5M
    for (size_t j = 0; j < counts[i]; ++j, ++pos) {
21
22.1M
      map_[pos].symbol_ = static_cast<uint8_t>(i);
22
22.1M
      map_[pos].freq_ = static_cast<uint16_t>(counts[i]);
23
22.1M
      map_[pos].offset_ = static_cast<uint16_t>(j);
24
22.1M
    }
25
388k
  }
26
21.6k
  return (pos == BRUNSLI_ANS_TAB_SIZE);
27
21.6k
}
28
29
}  // namespace brunsli