LengthCache.h
Go to the documentation of this file.
/*
* Copyright (C) 2016-2023 Grok Image Compression Inc.
*
* This source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vector>
#include <map>
namespace grk
{
struct MarkerInfo
{
MarkerInfo(uint16_t _id, uint64_t _pos, uint32_t _len);
MarkerInfo();
void dump(FILE* outputFileStream);
uint16_t id;
uint64_t pos;
uint32_t len;
};
struct TilePartInfo
{
TilePartInfo(uint64_t start, uint64_t endHeader, uint64_t end);
TilePartInfo(void);
void dump(FILE* outputFileStream, uint8_t tilePart);
uint64_t startPosition;
uint64_t endHeaderPosition;
uint64_t endPosition;
};
struct TileInfo
{
TileInfo(void);
~TileInfo(void);
bool checkResize(void);
bool hasTilePartInfo(void);
bool update(uint16_t tileIndex, uint8_t currentTilePart, uint8_t numTileParts);
TilePartInfo* getTilePartInfo(uint8_t tilePart);
void dump(FILE* outputFileStream, uint16_t tileNum);
uint16_t tileno;
uint8_t numTileParts;
uint8_t allocatedTileParts;
uint8_t currentTilePart;
private:
// TilePartInfo array
TilePartInfo* tilePartInfo;
// MarkerInfo array
MarkerInfo* markerInfo;
uint32_t numMarkers;
uint32_t allocatedMarkers;
};
struct CodeStreamInfo
{
CodeStreamInfo(BufferedStream* str);
virtual ~CodeStreamInfo();
bool allocTileInfo(uint16_t numTiles);
bool updateTileInfo(uint16_t tileIndex, uint8_t currentTilePart, uint8_t numTileParts);
TileInfo* getTileInfo(uint16_t tileIndex);
void dump(FILE* outputFileStream);
void pushMarker(uint16_t id, uint64_t pos, uint32_t len);
uint64_t getMainHeaderStart(void);
void setMainHeaderStart(uint64_t start);
uint64_t getMainHeaderEnd(void);
void setMainHeaderEnd(uint64_t end);
bool seekFirstTilePart(uint16_t tileIndex);
private:
uint64_t mainHeaderStart;
uint64_t mainHeaderEnd;
std::vector<MarkerInfo*> marker;
// TileInfo array
TileInfo* tileInfo;
uint16_t numTiles;
BufferedStream* stream;
};
struct TilePartLengthInfo
{
explicit TilePartLengthInfo();
TilePartLengthInfo(uint16_t tileno, uint32_t len);
uint16_t tileIndex_;
uint32_t length_;
};
typedef std::vector<TilePartLengthInfo> TL_INFO_VEC;
typedef std::map<uint16_t, TL_INFO_VEC*> TL_MAP;
struct TileLengthMarkers
{
explicit TileLengthMarkers(uint16_t numSignalledTiles);
explicit TileLengthMarkers(BufferedStream* stream);
~TileLengthMarkers();
bool read(uint8_t* headerData, uint16_t header_size);
void rewind(void);
TilePartLengthInfo* next(void);
TilePartLengthInfo* next(bool peek);
void invalidate(void);
bool valid(void);
void seek(TileSet* tilesToDecompress, CodingParams* cp, BufferedStream* stream);
bool writeBegin(uint16_t numTilePartsTotal);
void push(uint16_t tileIndex, uint32_t tile_part_size);
bool writeEnd(void);
static bool addTileMarkerInfo(uint16_t tileno, CodeStreamInfo* codeStreamInfo, uint16_t type,
uint64_t pos, uint32_t len);
private:
void push(uint8_t i_TLM, TilePartLengthInfo curr_vec);
TL_MAP* markers_;
TL_MAP::iterator markerIt_;
uint16_t markerTilePartIndex_;
TL_INFO_VEC* curr_vec_;
BufferedStream* stream_;
uint64_t streamStart;
bool valid_;
bool hasTileIndices_;
// used to track tile index when there are no tile indices
// stored in markers
uint16_t tileCount_;
uint16_t numSignalledTiles_;
};
struct PacketInfo
{
PacketInfo(void);
uint32_t getPacketDataLength(void);
uint32_t packetLength;
};
struct PacketInfoCache
{
PacketInfoCache();
~PacketInfoCache();
std::vector<PacketInfo*> packetInfo;
};
} // namespace grk
grk::TileSet
Definition TileSet.h:9
grk
Copyright (C) 2016-2023 Grok Image Compression Inc.
Definition ICacheable.h:20
grk::grk_read
void grk_read(const uint8_t *buffer, TYPE *value, uint32_t numBytes)
Definition BufferedStream.h:239
grk::TL_MAP
std::map< uint16_t, TL_INFO_VEC * > TL_MAP
Definition LengthCache.h:104
grk::TL_INFO_VEC
std::vector< TilePartLengthInfo > TL_INFO_VEC
Definition LengthCache.h:103
grk::BufferedStream
Definition BufferedStream.h:35
grk::CodeStreamInfo
Definition LengthCache.h:70
grk::CodeStreamInfo::mainHeaderStart
uint64_t mainHeaderStart
main header start position (SOC position)
Definition LengthCache.h:86
grk::CodeStreamInfo::getMainHeaderStart
uint64_t getMainHeaderStart(void)
Definition LengthCache.cpp:192
grk::CodeStreamInfo::pushMarker
void pushMarker(uint16_t id, uint64_t pos, uint32_t len)
Definition LengthCache.cpp:188
grk::CodeStreamInfo::updateTileInfo
bool updateTileInfo(uint16_t tileIndex, uint8_t currentTilePart, uint8_t numTileParts)
Definition LengthCache.cpp:146
grk::CodeStreamInfo::seekFirstTilePart
bool seekFirstTilePart(uint16_t tileIndex)
Definition LengthCache.cpp:208
grk::CodeStreamInfo::allocTileInfo
bool allocTileInfo(uint16_t numTiles)
Definition LengthCache.cpp:138
grk::CodeStreamInfo::~CodeStreamInfo
virtual ~CodeStreamInfo()
Definition LengthCache.cpp:132
grk::CodeStreamInfo::setMainHeaderEnd
void setMainHeaderEnd(uint64_t end)
Definition LengthCache.cpp:204
grk::CodeStreamInfo::dump
void dump(FILE *outputFileStream)
Definition LengthCache.cpp:159
grk::CodeStreamInfo::numTiles
uint16_t numTiles
Definition LengthCache.h:92
grk::CodeStreamInfo::getMainHeaderEnd
uint64_t getMainHeaderEnd(void)
Definition LengthCache.cpp:200
grk::CodeStreamInfo::stream
BufferedStream * stream
Definition LengthCache.h:93
grk::CodeStreamInfo::marker
std::vector< MarkerInfo * > marker
Definition LengthCache.h:89
grk::CodeStreamInfo::getTileInfo
TileInfo * getTileInfo(uint16_t tileIndex)
Definition LengthCache.cpp:152
grk::CodeStreamInfo::setMainHeaderStart
void setMainHeaderStart(uint64_t start)
Definition LengthCache.cpp:196
grk::CodeStreamInfo::tileInfo
TileInfo * tileInfo
Definition LengthCache.h:91
grk::CodeStreamInfo::mainHeaderEnd
uint64_t mainHeaderEnd
main header end position (first SOT position)
Definition LengthCache.h:88
grk::CodingParams
Coding parameters.
Definition CodingParams.h:245
grk::MarkerInfo
Definition LengthCache.h:24
grk::MarkerInfo::MarkerInfo
MarkerInfo()
Definition LengthCache.cpp:24
grk::MarkerInfo::dump
void dump(FILE *outputFileStream)
Definition LengthCache.cpp:27
grk::MarkerInfo::id
uint16_t id
Definition LengthCache.h:28
grk::MarkerInfo::len
uint32_t len
length (marker id included)
Definition LengthCache.h:32
grk::MarkerInfo::pos
uint64_t pos
position in code stream
Definition LengthCache.h:30
grk::PacketInfoCache
Definition LengthCache.h:157
grk::PacketInfoCache::~PacketInfoCache
~PacketInfoCache()
Definition LengthCache.cpp:532
grk::PacketInfoCache::PacketInfoCache
PacketInfoCache()
grk::PacketInfoCache::packetInfo
std::vector< PacketInfo * > packetInfo
Definition LengthCache.h:161
grk::PacketInfo
Definition LengthCache.h:150
grk::PacketInfo::packetLength
uint32_t packetLength
Definition LengthCache.h:153
grk::PacketInfo::PacketInfo
PacketInfo(void)
Definition LengthCache.cpp:531
grk::PacketInfo::getPacketDataLength
uint32_t getPacketDataLength(void)
grk::TileInfo
Definition LengthCache.h:47
grk::TileInfo::getTilePartInfo
TilePartInfo * getTilePartInfo(uint8_t tilePart)
Definition LengthCache.cpp:109
grk::TileInfo::numMarkers
uint32_t numMarkers
Definition LengthCache.h:66
grk::TileInfo::dump
void dump(FILE *outputFileStream, uint16_t tileNum)
Definition LengthCache.cpp:115
grk::TileInfo::hasTilePartInfo
bool hasTilePartInfo(void)
Definition LengthCache.cpp:81
grk::TileInfo::markerInfo
MarkerInfo * markerInfo
Definition LengthCache.h:65
grk::TileInfo::numTileParts
uint8_t numTileParts
Definition LengthCache.h:56
grk::TileInfo::currentTilePart
uint8_t currentTilePart
Definition LengthCache.h:58
grk::TileInfo::~TileInfo
~TileInfo(void)
Definition LengthCache.cpp:52
grk::TileInfo::allocatedTileParts
uint8_t allocatedTileParts
Definition LengthCache.h:57
grk::TileInfo::update
bool update(uint16_t tileIndex, uint8_t currentTilePart, uint8_t numTileParts)
Definition LengthCache.cpp:85
grk::TileInfo::tileno
uint16_t tileno
Definition LengthCache.h:55
grk::TileInfo::checkResize
bool checkResize(void)
Definition LengthCache.cpp:57
grk::TileInfo::TileInfo
TileInfo(void)
Definition LengthCache.cpp:44
grk::TileInfo::tilePartInfo
TilePartInfo * tilePartInfo
Definition LengthCache.h:62
grk::TileInfo::allocatedMarkers
uint32_t allocatedMarkers
Definition LengthCache.h:67
grk::TileLengthMarkers
Definition LengthCache.h:107
grk::TileLengthMarkers::valid
bool valid(void)
Definition LengthCache.cpp:252
grk::TileLengthMarkers::push
void push(uint16_t tileIndex, uint32_t tile_part_size)
Definition LengthCache.cpp:494
grk::TileLengthMarkers::next
TilePartLengthInfo * next(void)
Definition LengthCache.cpp:386
grk::TileLengthMarkers::markerIt_
TL_MAP::iterator markerIt_
Definition LengthCache.h:136
grk::TileLengthMarkers::writeEnd
bool writeEnd(void)
Definition LengthCache.cpp:498
grk::TileLengthMarkers::stream_
BufferedStream * stream_
Definition LengthCache.h:139
grk::TileLengthMarkers::curr_vec_
TL_INFO_VEC * curr_vec_
Definition LengthCache.h:138
grk::TileLengthMarkers::numSignalledTiles_
uint16_t numSignalledTiles_
Definition LengthCache.h:146
grk::TileLengthMarkers::invalidate
void invalidate(void)
Definition LengthCache.cpp:256
grk::TileLengthMarkers::writeBegin
bool writeBegin(uint16_t numTilePartsTotal)
Definition LengthCache.cpp:470
grk::TileLengthMarkers::markers_
TL_MAP * markers_
Definition LengthCache.h:135
grk::TileLengthMarkers::seek
void seek(TileSet *tilesToDecompress, CodingParams *cp, BufferedStream *stream)
Seek to next scheduled tile part.
Definition LengthCache.cpp:441
grk::TileLengthMarkers::hasTileIndices_
bool hasTileIndices_
Definition LengthCache.h:142
grk::TileLengthMarkers::tileCount_
uint16_t tileCount_
Definition LengthCache.h:145
grk::TileLengthMarkers::markerTilePartIndex_
uint16_t markerTilePartIndex_
Definition LengthCache.h:137
grk::TileLengthMarkers::rewind
void rewind(void)
Definition LengthCache.cpp:375
grk::TileLengthMarkers::addTileMarkerInfo
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:515
grk::TileLengthMarkers::~TileLengthMarkers
~TileLengthMarkers()
Definition LengthCache.cpp:239
grk::TileLengthMarkers::read
bool read(uint8_t *headerData, uint16_t header_size)
Definition LengthCache.cpp:261
grk::TileLengthMarkers::streamStart
uint64_t streamStart
Definition LengthCache.h:140
grk::TileLengthMarkers::valid_
bool valid_
Definition LengthCache.h:141
grk::TilePartInfo
Definition LengthCache.h:35
grk::TilePartInfo::startPosition
uint64_t startPosition
start position of tile part
Definition LengthCache.h:40
grk::TilePartInfo::endHeaderPosition
uint64_t endHeaderPosition
end position of tile part header
Definition LengthCache.h:42
grk::TilePartInfo::endPosition
uint64_t endPosition
end position of tile part
Definition LengthCache.h:44
grk::TilePartInfo::dump
void dump(FILE *outputFileStream, uint8_t tilePart)
Definition LengthCache.cpp:35
grk::TilePartInfo::TilePartInfo
TilePartInfo(void)
Definition LengthCache.cpp:34
grk::TilePartLengthInfo
Definition LengthCache.h:96
grk::TilePartLengthInfo::TilePartLengthInfo
TilePartLengthInfo()
Definition LengthCache.cpp:226
grk::TilePartLengthInfo::length_
uint32_t length_
Definition LengthCache.h:100
grk::TilePartLengthInfo::tileIndex_
uint16_t tileIndex_
Definition LengthCache.h:99