Grok 20.3.2
PLMarker.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#include <vector>
20#include <map>
21#include <memory>
22
23namespace grk
24{
25
31typedef std::vector<std::unique_ptr<Buffer8>> RAW_PL_MARKER;
32
43typedef std::map<uint32_t, std::unique_ptr<RAW_PL_MARKER>> RAW_PL_MARKER_MAP;
44
53{
57 PLMarker(void);
61 ~PLMarker(void);
62
66 void disable(void);
67
72 bool isEnabled(void);
73
74 // compress
79 void pushInit(bool isFinal);
80
86 bool pushPL(uint32_t len);
87
92 bool write(void);
93
98 uint32_t getTotalBytesWritten(void);
99
100 // decompress
105 explicit PLMarker(IStream* strm);
106
114 bool readPLT(uint8_t* headerData, uint16_t headerSize, int16_t tilePartIndex = -1);
115
122 bool readPLM(uint8_t* headerData, uint16_t headerSize);
123
127 void rewind(void);
128
133 uint32_t pop(void);
134
140 uint64_t pop(uint64_t numPackets);
141
142private:
143 void clearMarkers(void);
144 bool findMarker(uint32_t index, bool compress);
145 Buffer8* addNewMarker(uint8_t* data, uint16_t len, int16_t tilePartIndex = -1);
146 std::unique_ptr<RAW_PL_MARKER_MAP> rawMarkers_;
147 RAW_PL_MARKER_MAP::iterator currMarkerIter_;
148
150 // compress
155
157 // decompress
158 bool readNextByte(uint8_t Iplm, uint32_t* packetLength);
160 uint32_t packetLen_;
164
166};
167
168} // namespace grk
ResWindow.
Definition CompressedChunkCache.h:36
std::vector< std::unique_ptr< Buffer8 > > RAW_PL_MARKER
collection of raw marker data stored in Buffer8
Definition PLMarker.h:31
Buffer< uint8_t, AllocatorVanilla > Buffer8
Definition buffer.h:257
std::map< uint32_t, std::unique_ptr< RAW_PL_MARKER > > RAW_PL_MARKER_MAP
collection of RAW_PL_MARKER pointers
Definition PLMarker.h:43
Definition IStream.h:60
bool readPLM(uint8_t *headerData, uint16_t headerSize)
Reads PLM marker.
Definition PLMarker.cpp:151
IStream * stream_
Definition PLMarker.h:153
void rewind(void)
Resets object for reading packet lengths.
Definition PLMarker.cpp:432
bool findMarker(uint32_t index, bool compress)
Definition PLMarker.cpp:288
Buffer8 * currMarkerBuf_
Definition PLMarker.h:162
bool write(void)
Writes marker to stream.
Definition PLMarker.cpp:129
bool readPLT(uint8_t *headerData, uint16_t headerSize, int16_t tilePartIndex=-1)
Reads PLT marker.
Definition PLMarker.cpp:266
uint32_t packetLen_
Definition PLMarker.h:160
RAW_PL_MARKER_MAP::iterator currMarkerIter_
Definition PLMarker.h:147
bool isEnabled(void)
Checks if object is enabled.
Definition PLMarker.cpp:60
bool isFinal_
Definition PLMarker.h:152
bool enabled_
Definition PLMarker.h:165
bool sequential_
Definition PLMarker.h:159
bool pushPL(uint32_t len)
Pushes packet length @len length of packet.
Definition PLMarker.cpp:76
uint32_t currMarkerBufIndex_
Definition PLMarker.h:161
PLMarker(void)
Constructs a PLMarker.
Definition PLMarker.cpp:42
uint32_t totalBytesWritten_
Definition PLMarker.h:151
bool readNextByte(uint8_t Iplm, uint32_t *packetLength)
Definition PLMarker.cpp:349
void pushInit(bool isFinal)
Prepares for pushing markers.
Definition PLMarker.cpp:70
Buffer8 * addNewMarker(uint8_t *data, uint16_t len, int16_t tilePartIndex=-1)
Definition PLMarker.cpp:203
uint32_t pop(void)
pop next packet length
Definition PLMarker.cpp:376
void disable(void)
Disables object in event of corrupt PL marker.
Definition PLMarker.cpp:56
~PLMarker(void)
Destroys a PLMarker.
Definition PLMarker.cpp:52
uint32_t getTotalBytesWritten(void)
Gets total bytes written.
Definition PLMarker.cpp:125
void clearMarkers(void)
Definition PLMarker.cpp:64
std::unique_ptr< RAW_PL_MARKER_MAP > rawMarkers_
Definition PLMarker.h:146