PacketParser.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 <cstdint>
#include <map>
namespace grk
{
struct TileProcessor;
class PacketParser
{
public:
PacketParser(TileProcessor* tileProcessor, uint16_t packetSequenceNumber, uint16_t compno,
uint8_t resno, uint64_t precinctIndex, uint16_t layno, uint8_t* data,
uint32_t lengthFromMarker, size_t tileBytes, size_t remainingTilePartBytes);
virtual ~PacketParser(void) = default;
void readHeader(void);
void readData(void);
uint32_t numHeaderBytes(void);
uint32_t numSignalledDataBytes(void);
uint32_t numSignalledBytes(void);
uint32_t numReadDataBytes(void);
void print(void);
private:
void readDataFinalize(void);
void initSegment(DecompressCodeblock* cblk, uint32_t index, uint8_t cblk_sty, bool first);
TileProcessor* tileProcessor_;
uint16_t packetSequenceNumber_;
uint16_t compno_;
uint8_t resno_;
uint64_t precinctIndex_;
uint16_t layno_;
uint8_t* data_;
size_t tileBytes_;
size_t remainingTilePartBytes_;
bool tagBitsPresent_;
// header bytes in packet - doesn't include packed header bytes
uint32_t packetHeaderBytes_;
uint32_t signalledDataBytes_;
uint32_t readDataBytes_;
uint32_t lengthFromMarker_;
bool parsedHeader_;
bool headerError_;
};
struct PrecinctPacketParsers
{
PrecinctPacketParsers(TileProcessor* tileProcessor);
~PrecinctPacketParsers(void);
void pushParser(PacketParser* parser);
TileProcessor* tileProcessor_;
PacketParser** parsers_;
uint16_t numParsers_;
uint16_t allocatedParsers_;
};
struct TileProcessor;
struct ParserMap
{
ParserMap(TileProcessor* tileProcessor);
~ParserMap();
void pushParser(uint64_t precinctIndex, PacketParser* parser);
TileProcessor* tileProcessor_;
std::map<uint64_t, PrecinctPacketParsers*> precinctParsers_;
};
} // namespace grk
grk::PacketParser
Definition PacketParser.h:28
grk::PacketParser::readDataFinalize
void readDataFinalize(void)
Definition PacketParser.cpp:448
grk::PacketParser::tagBitsPresent_
bool tagBitsPresent_
Definition PacketParser.h:54
grk::PacketParser::data_
uint8_t * data_
Definition PacketParser.h:51
grk::PacketParser::precinctIndex_
uint64_t precinctIndex_
Definition PacketParser.h:49
grk::PacketParser::numSignalledDataBytes
uint32_t numSignalledDataBytes(void)
Definition PacketParser.cpp:52
grk::PacketParser::lengthFromMarker_
uint32_t lengthFromMarker_
Definition PacketParser.h:59
grk::PacketParser::remainingTilePartBytes_
size_t remainingTilePartBytes_
Definition PacketParser.h:53
grk::PacketParser::numSignalledBytes
uint32_t numSignalledBytes(void)
Definition PacketParser.cpp:60
grk::PacketParser::readDataBytes_
uint32_t readDataBytes_
Definition PacketParser.h:58
grk::PacketParser::packetSequenceNumber_
uint16_t packetSequenceNumber_
Definition PacketParser.h:46
grk::PacketParser::readData
void readData(void)
Definition PacketParser.cpp:359
grk::PacketParser::layno_
uint16_t layno_
Definition PacketParser.h:50
grk::PacketParser::tileProcessor_
TileProcessor * tileProcessor_
Definition PacketParser.h:45
grk::PacketParser::parsedHeader_
bool parsedHeader_
Definition PacketParser.h:60
grk::PacketParser::numReadDataBytes
uint32_t numReadDataBytes(void)
Definition PacketParser.cpp:56
grk::PacketParser::headerError_
bool headerError_
Definition PacketParser.h:61
grk::PacketParser::signalledDataBytes_
uint32_t signalledDataBytes_
Definition PacketParser.h:57
grk::PacketParser::packetHeaderBytes_
uint32_t packetHeaderBytes_
Definition PacketParser.h:56
grk::PacketParser::compno_
uint16_t compno_
Definition PacketParser.h:47
grk::PacketParser::initSegment
void initSegment(DecompressCodeblock *cblk, uint32_t index, uint8_t cblk_sty, bool first)
Definition PacketParser.cpp:332
grk::PacketParser::~PacketParser
virtual ~PacketParser(void)=default
grk::PacketParser::numHeaderBytes
uint32_t numHeaderBytes(void)
Definition PacketParser.cpp:48
grk::PacketParser::readHeader
void readHeader(void)
Definition PacketParser.cpp:65
grk::PacketParser::tileBytes_
size_t tileBytes_
Definition PacketParser.h:52
grk::PacketParser::resno_
uint8_t resno_
Definition PacketParser.h:48
grk::PacketParser::print
void print(void)
Definition PacketParser.cpp:32
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::DecompressCodeblock
Definition Codeblock.h:201
grk::ParserMap
Definition PacketParser.h:78
grk::ParserMap::pushParser
void pushParser(uint64_t precinctIndex, PacketParser *parser)
Definition PacketParser.cpp:495
grk::ParserMap::~ParserMap
~ParserMap()
Definition PacketParser.cpp:489
grk::ParserMap::precinctParsers_
std::map< uint64_t, PrecinctPacketParsers * > precinctParsers_
Definition PacketParser.h:84
grk::ParserMap::tileProcessor_
TileProcessor * tileProcessor_
Definition PacketParser.h:83
grk::PrecinctPacketParsers
Definition PacketParser.h:65
grk::PrecinctPacketParsers::allocatedParsers_
uint16_t allocatedParsers_
Definition PacketParser.h:72
grk::PrecinctPacketParsers::pushParser
void pushParser(PacketParser *parser)
Definition PacketParser.cpp:475
grk::PrecinctPacketParsers::tileProcessor_
TileProcessor * tileProcessor_
Definition PacketParser.h:69
grk::PrecinctPacketParsers::parsers_
PacketParser ** parsers_
Definition PacketParser.h:70
grk::PrecinctPacketParsers::numParsers_
uint16_t numParsers_
Definition PacketParser.h:71
grk::PrecinctPacketParsers::~PrecinctPacketParsers
~PrecinctPacketParsers(void)
Definition PacketParser.cpp:468
grk::TileProcessor
Definition TileProcessor.h:78