Grok 20.3.2
PacketProgressionState.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016-2026 Grok Image Compression Inc.
3 *
4 * This source code is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License, version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This source code is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Affero General Public License for more details.
12 *
13 * You should have received a copy of the GNU Affero General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#pragma once
19
20#include <vector>
21
22namespace grk
23{
24
32{
41 explicit PacketProgressionState(uint8_t totalResolutions)
42 : totalResolutions_(totalResolutions), resLayers_(totalResolutions, 0)
43 {}
44
49 uint8_t numResolutionsRead(void) const
50 {
51 // Start by assuming no non-zero element is found
52 int maxIndex = -1;
53
54 // Iterate over the vector to find the last non-zero element's index
55 for(uint8_t i = 0; i < resLayers_.size(); ++i)
56 {
57 if(resLayers_[i] != 0U)
58 maxIndex = i; // Update maxIndex with the current non-zero element's index
59 }
60
61 // If no non-zero element was found, return 0. Otherwise, return maxIndex + 1
62 return (maxIndex != -1) ? static_cast<uint8_t>(maxIndex + 1) : 0;
63 }
64
72 std::vector<uint16_t> resLayers_;
73};
74
75} // namespace grk
ResWindow.
Definition CompressedChunkCache.h:36
uint8_t totalResolutions_
total number of resolutions in code stream
Definition PacketProgressionState.h:68
PacketProgressionState(uint8_t totalResolutions)
Constructs a PacketProgressionState.
Definition PacketProgressionState.h:41
PacketProgressionState()
Constructs a PacketProgressionState.
Definition PacketProgressionState.h:36
std::vector< uint16_t > resLayers_
maximum layers read, by packet, for each resolution.
Definition PacketProgressionState.h:72
uint8_t numResolutionsRead(void) const
Calculates maximum number of resolutions read, by packet.
Definition PacketProgressionState.h:49