Grok 20.3.2
CodeblockDecompress.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 "Codeblock.h"
22
23namespace grk::t1
24{
25
27{
28 explicit CodeblockDecompress(uint16_t numLayers) : Codeblock(numLayers), impl_(nullptr) {}
30 {
31 release();
32 }
34 {
35 return getImpl()->getCompressedStream();
36 }
37 uint8_t numbps(void)
38 {
39 return getImpl()->numbps();
40 }
41 void setNumBps(uint8_t bps)
42 {
43 getImpl()->setNumBps(bps);
44 }
45 uint8_t numlenbits()
46 {
47 return getImpl()->numlenbits();
48 }
49 void setNumLenBits(uint8_t bits)
50 {
51 getImpl()->setNumLenBits(bits);
52 }
53
54 void init()
55 {
56 getImpl()->init();
57 }
58 Segment* getSegment(uint16_t segmentIndex)
59 {
60 return getImpl()->getSegment(segmentIndex);
61 }
62 void readPacketHeader(std::shared_ptr<t1_t2::BitIO> bio, uint32_t& signalledLayerDataBytes,
63 uint16_t layno, uint8_t cblk_sty)
64 {
65 getImpl()->readPacketHeader(bio, signalledLayerDataBytes, layno, cblk_sty);
66 }
67
68 void parsePacketData(uint16_t layno, size_t& remainingTilePartBytes, bool isHT,
69 uint8_t* layerData, uint32_t& layerDataOffset)
70 {
71 getImpl()->parsePacketData(layno, remainingTilePartBytes, isHT, layerData, layerDataOffset);
72 }
73 bool canDecompress(void)
74 {
75 return getImpl()->canDecompress();
76 }
77 template<typename T>
78 bool decompress(T* coder, uint8_t orientation, uint32_t cblksty)
79 {
80 return getImpl()->decompress<T>(coder, orientation, cblksty);
81 }
83 {
85 }
87 {
88 return getImpl()->dataChunksEmpty();
89 }
91 {
92 return getImpl()->getDataChunksLength();
93 }
94 bool copyDataChunksToContiguous(uint8_t* buffer)
95 {
96 return getImpl()->copyDataChunksToContiguous(buffer);
97 }
98 void release(void)
99 {
100 delete impl_;
101 impl_ = nullptr;
102 }
103
105 {
106 if(!impl_)
108 return impl_;
109 }
110
111private:
113};
114
115} // namespace grk::t1
Definition SchedulerFreebyrd.h:36
Buffer< uint8_t, AllocatorVanilla > Buffer8
Definition buffer.h:257
CodeblockDecompress(uint16_t numLayers)
Definition CodeblockDecompress.h:28
void readPacketHeader(std::shared_ptr< t1_t2::BitIO > bio, uint32_t &signalledLayerDataBytes, uint16_t layno, uint8_t cblk_sty)
Definition CodeblockDecompress.h:62
void parsePacketData(uint16_t layno, size_t &remainingTilePartBytes, bool isHT, uint8_t *layerData, uint32_t &layerDataOffset)
Definition CodeblockDecompress.h:68
CodeblockDecompressImpl * getImpl(void)
Definition CodeblockDecompress.h:104
void init()
Definition CodeblockDecompress.h:54
void setNumLenBits(uint8_t bits)
Definition CodeblockDecompress.h:49
size_t getDataChunksLength()
Definition CodeblockDecompress.h:90
void release(void)
Definition CodeblockDecompress.h:98
uint8_t numlenbits()
Definition CodeblockDecompress.h:45
Segment * getSegment(uint16_t segmentIndex)
Definition CodeblockDecompress.h:58
~CodeblockDecompress()
Definition CodeblockDecompress.h:29
bool copyDataChunksToContiguous(uint8_t *buffer)
Definition CodeblockDecompress.h:94
bool dataChunksEmpty()
Definition CodeblockDecompress.h:86
Buffer8 * getCompressedStream(void)
Definition CodeblockDecompress.h:33
CodeblockDecompressImpl * impl_
Definition CodeblockDecompress.h:112
bool decompress(T *coder, uint8_t orientation, uint32_t cblksty)
Definition CodeblockDecompress.h:78
uint16_t getNumDataParsedSegments(void)
Definition CodeblockDecompress.h:82
uint8_t numbps(void)
Definition CodeblockDecompress.h:37
void setNumBps(uint8_t bps)
Definition CodeblockDecompress.h:41
bool canDecompress(void)
Definition CodeblockDecompress.h:73
Decompression code block implementation.
Definition CodeblockDecompressImpl.h:151
void init()
Initializes the code block.
Definition CodeblockDecompressImpl.h:174
bool dataChunksEmpty()
Checks whether all segments' data chunks are empty.
Definition CodeblockDecompressImpl.h:555
bool copyDataChunksToContiguous(uint8_t *buffer) const
Copies all segment data chunk buffers for all uncompressed segments whose data has been parsed,...
Definition CodeblockDecompressImpl.h:587
Segment * getSegment(uint16_t index)
Gets segment for the specified index If index equals number of segments, then a new segment will be a...
Definition CodeblockDecompressImpl.h:211
void setNumBps(uint8_t bps)
Sets number of bit planes to be decompressed.
Definition CodeblockDecompressImpl.h:200
bool decompress(T *coder, uint8_t orientation, uint32_t cblksty)
Decompresses all layers specified so far.
Definition CodeblockDecompressImpl.h:441
bool canDecompress(void)
Definition CodeblockDecompressImpl.h:425
void readPacketHeader(std::shared_ptr< t1_t2::BitIO > bio, uint32_t &signalledLayerDataBytes, uint16_t layno, uint8_t cblk_sty)
Reads packet header.
Definition CodeblockDecompressImpl.h:225
void parsePacketData(uint16_t layno, size_t &remainingTilePartBytes, bool isHT, uint8_t *layerData, uint32_t &layerDataOffset)
Parses packet data based on packet header.
Definition CodeblockDecompressImpl.h:317
uint16_t getNumDataParsedSegments(void)
Gets number of segments whose layer data has been parsed.
Definition CodeblockDecompressImpl.h:521
size_t getDataChunksLength() const
Gets combined length of all data chunks across all uncompressed segments whose datg has been parsed.
Definition CodeblockDecompressImpl.h:572
uint16_t numLayers_
Number of layers in code block.
Definition Codeblock.h:62
Codeblock(uint16_t numLayers)
Creates a Codeblock.
Definition Codeblock.h:53
uint8_t numbps(void)
Definition CodeblockImpl.h:52
void setNumLenBits(uint8_t bits)
Definition CodeblockImpl.h:64
Buffer8 * getCompressedStream(void)
Definition CodeblockImpl.h:48
uint8_t numlenbits()
Definition CodeblockImpl.h:60
Stores information for a code block segment.
Definition CodeblockDecompressImpl.h:40