Grok 12.0.1
LengthCache.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016-2024 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#pragma once
18#include <vector>
19#include <map>
20
21namespace grk
22{
70{
72 virtual ~CodeStreamInfo();
74 bool updateTileInfo(uint16_t tileIndex, uint8_t currentTilePart, uint8_t numTileParts);
75 TileInfo* getTileInfo(uint16_t tileIndex);
77 void pushMarker(uint16_t id, uint64_t pos, uint32_t len);
79 void setMainHeaderStart(uint64_t start);
81 void setMainHeaderEnd(uint64_t end);
82 bool seekFirstTilePart(uint16_t tileIndex);
83
84 private:
89 std::vector<MarkerInfo*> marker;
90 // TileInfo array
94};
102
103typedef std::vector<TilePartLengthInfo> TL_INFO_VEC;
104typedef std::map<uint16_t, TL_INFO_VEC*> TL_MAP;
105
107{
109 explicit TileLengthMarkers(BufferedStream* stream);
111
113 void rewind(void);
116 void invalidate(void);
117 bool valid(void);
120 void push(uint16_t tileIndex, uint32_t tile_part_size);
121 bool writeEnd(void);
130 static bool addTileMarkerInfo(uint16_t tileno, CodeStreamInfo* codeStreamInfo, uint16_t type,
131 uint64_t pos, uint32_t len);
132
133 private:
136 TL_MAP::iterator markerIt_;
141 bool valid_;
143 // used to track tile index when there are no tile indices
144 // stored in markers
147};
148
155
157{
160
161 std::vector<PacketInfo*> packetInfo;
162};
163
164} // namespace grk
Definition TileSet.h:9
Copyright (C) 2016-2024 Grok Image Compression Inc.
Definition ICacheable.h:20
void grk_read(const uint8_t *buffer, TYPE *value, uint32_t numBytes)
Definition BufferedStream.h:239
std::map< uint16_t, TL_INFO_VEC * > TL_MAP
Definition LengthCache.h:104
std::vector< TilePartLengthInfo > TL_INFO_VEC
Definition LengthCache.h:103
Definition BufferedStream.h:35
Definition LengthCache.h:70
uint64_t mainHeaderStart
main header start position (SOC position)
Definition LengthCache.h:86
uint64_t getMainHeaderStart(void)
Definition LengthCache.cpp:191
void pushMarker(uint16_t id, uint64_t pos, uint32_t len)
Definition LengthCache.cpp:187
bool updateTileInfo(uint16_t tileIndex, uint8_t currentTilePart, uint8_t numTileParts)
Definition LengthCache.cpp:145
bool seekFirstTilePart(uint16_t tileIndex)
Definition LengthCache.cpp:207
bool allocTileInfo(uint16_t numTiles)
Definition LengthCache.cpp:137
virtual ~CodeStreamInfo()
Definition LengthCache.cpp:131
void setMainHeaderEnd(uint64_t end)
Definition LengthCache.cpp:203
void dump(FILE *outputFileStream)
Definition LengthCache.cpp:158
uint16_t numTiles
Definition LengthCache.h:92
uint64_t getMainHeaderEnd(void)
Definition LengthCache.cpp:199
BufferedStream * stream
Definition LengthCache.h:93
std::vector< MarkerInfo * > marker
Definition LengthCache.h:89
CodeStreamInfo(BufferedStream *str)
Definition LengthCache.cpp:128
TileInfo * getTileInfo(uint16_t tileIndex)
Definition LengthCache.cpp:151
void setMainHeaderStart(uint64_t start)
Definition LengthCache.cpp:195
TileInfo * tileInfo
Definition LengthCache.h:91
uint64_t mainHeaderEnd
main header end position (first SOT position)
Definition LengthCache.h:88
Coding parameters.
Definition CodingParams.h:245
Definition LengthCache.h:24
MarkerInfo()
Definition LengthCache.cpp:24
void dump(FILE *outputFileStream)
Definition LengthCache.cpp:27
uint16_t id
Definition LengthCache.h:28
uint32_t len
length (marker id included)
Definition LengthCache.h:32
uint64_t pos
position in code stream
Definition LengthCache.h:30
Definition LengthCache.h:157
~PacketInfoCache()
Definition LengthCache.cpp:533
std::vector< PacketInfo * > packetInfo
Definition LengthCache.h:161
Definition LengthCache.h:150
uint32_t packetLength
Definition LengthCache.h:153
PacketInfo(void)
Definition LengthCache.cpp:532
uint32_t getPacketDataLength(void)
Definition LengthCache.h:47
TilePartInfo * getTilePartInfo(uint8_t tilePart)
Definition LengthCache.cpp:108
uint32_t numMarkers
Definition LengthCache.h:66
void dump(FILE *outputFileStream, uint16_t tileNum)
Definition LengthCache.cpp:114
bool hasTilePartInfo(void)
Definition LengthCache.cpp:80
MarkerInfo * markerInfo
Definition LengthCache.h:65
uint8_t numTileParts
Definition LengthCache.h:56
uint8_t currentTilePart
Definition LengthCache.h:58
~TileInfo(void)
Definition LengthCache.cpp:52
uint8_t allocatedTileParts
Definition LengthCache.h:57
bool update(uint16_t tileIndex, uint8_t currentTilePart, uint8_t numTileParts)
Definition LengthCache.cpp:84
uint16_t tileno
Definition LengthCache.h:55
bool checkResize(void)
Definition LengthCache.cpp:57
TileInfo(void)
Definition LengthCache.cpp:44
TilePartInfo * tilePartInfo
Definition LengthCache.h:62
uint32_t allocatedMarkers
Definition LengthCache.h:67
Definition LengthCache.h:107
bool valid(void)
Definition LengthCache.cpp:251
void push(uint16_t tileIndex, uint32_t tile_part_size)
Definition LengthCache.cpp:495
TilePartLengthInfo * next(void)
Definition LengthCache.cpp:386
TileLengthMarkers(uint16_t numSignalledTiles)
Definition LengthCache.cpp:229
TL_MAP::iterator markerIt_
Definition LengthCache.h:136
bool writeEnd(void)
Definition LengthCache.cpp:499
BufferedStream * stream_
Definition LengthCache.h:139
TL_INFO_VEC * curr_vec_
Definition LengthCache.h:138
uint16_t numSignalledTiles_
Definition LengthCache.h:146
void invalidate(void)
Definition LengthCache.cpp:255
bool writeBegin(uint16_t numTilePartsTotal)
Definition LengthCache.cpp:471
TL_MAP * markers_
Definition LengthCache.h:135
void seek(TileSet *tilesToDecompress, CodingParams *cp, BufferedStream *stream)
Seek to next scheduled tile part.
Definition LengthCache.cpp:442
bool hasTileIndices_
Definition LengthCache.h:142
uint16_t tileCount_
Definition LengthCache.h:145
uint16_t markerTilePartIndex_
Definition LengthCache.h:137
void rewind(void)
Definition LengthCache.cpp:375
static bool addTileMarkerInfo(uint16_t tileno, CodeStreamInfo *codeStreamInfo, uint16_t type, uint64_t pos, uint32_t len)
Add tile header marker information.
Definition LengthCache.cpp:516
~TileLengthMarkers()
Definition LengthCache.cpp:238
bool read(uint8_t *headerData, uint16_t header_size)
Definition LengthCache.cpp:260
uint64_t streamStart
Definition LengthCache.h:140
bool valid_
Definition LengthCache.h:141
Definition LengthCache.h:35
uint64_t startPosition
start position of tile part
Definition LengthCache.h:40
uint64_t endHeaderPosition
end position of tile part header
Definition LengthCache.h:42
uint64_t endPosition
end position of tile part
Definition LengthCache.h:44
void dump(FILE *outputFileStream, uint8_t tilePart)
Definition LengthCache.cpp:35
TilePartInfo(void)
Definition LengthCache.cpp:34
Definition LengthCache.h:96
TilePartLengthInfo()
Definition LengthCache.cpp:225
uint32_t length_
Definition LengthCache.h:100
uint16_t tileIndex_
Definition LengthCache.h:99