Grok 10.0.5
Precinct.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016-2023 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#pragma once
17#include "grk_includes.h"
18
19namespace grk
20{
21template<typename T, typename P>
22class BlockCache : public SparseCache<T>
23{
24 public:
25 BlockCache(uint16_t numLayers, uint64_t maxChunkSize, P* blockInitializer)
26 : SparseCache<T>(maxChunkSize), blockInitializer_(blockInitializer), numLayers_(numLayers)
27 {}
28 virtual ~BlockCache() = default;
29
30 protected:
31 virtual T* create(uint64_t index) override
32 {
33 auto item = new T(numLayers_);
34 blockInitializer_->initCodeBlock(item, index);
35 return item;
36 }
37
38 private:
40 uint16_t numLayers_;
41};
42
43struct PrecinctImpl
44{
45 PrecinctImpl(bool isCompressor, grk_rect32* bounds, grk_pt32 cblk_expn);
46 ~PrecinctImpl(void);
47 grk_rect32 getCodeBlockBounds(uint64_t cblkno);
48 bool initCodeBlocks(uint16_t numLayers, grk_rect32* bounds);
49 template<typename T>
50 bool initCodeBlock(T* block, uint64_t cblkno);
51 void deleteTagTrees();
52 TagTreeU16* getIncludeTagTree(void);
53 TagTreeU8* getIMsbTagTree(void);
54 BlockCache<CompressCodeblock, PrecinctImpl>* enc;
55 BlockCache<DecompressCodeblock, PrecinctImpl>* dec;
56 grk_rect32 cblk_grid_;
57 grk_rect32 bounds_;
58 grk_pt32 cblk_expn_;
60
61 private:
62 TagTreeU16* incltree; /* inclusion tree */
63 TagTreeU8* imsbtree; /* IMSB tree */
64};
65struct Precinct : public grk_rect32
66{
67 Precinct(TileProcessor* tileProcessor, const grk_rect32& bounds, grk_pt32 cblk_expn);
68 virtual ~Precinct();
69 void deleteTagTrees();
70 grk_rect32 getCodeBlockBounds(uint64_t cblkno);
71 TagTreeU16* getInclTree(void);
72 TagTreeU8* getImsbTree(void);
73 uint32_t getCblkGridwidth(void);
74 uint32_t getCblkGridHeight(void);
75 uint32_t getNominalBlockSize(void);
76 uint64_t getNumCblks(void);
77 CompressCodeblock* getCompressedBlockPtr(uint64_t cblkno);
78 DecompressCodeblock* getDecompressedBlockPtr(uint64_t cblkno);
79 DecompressCodeblock* tryGetDecompressedBlockPtr(uint64_t cblkno);
80 grk_pt32 getCblkExpn(void);
81 grk_rect32 getCblkGrid(void);
82 uint64_t precinctIndex;
83 uint16_t numLayers_;
84
85 private:
86 PrecinctImpl* impl;
87 grk_pt32 cblk_expn_;
88 PrecinctImpl* getImpl(void)
89 {
90 impl->initCodeBlocks(numLayers_, this);
91 return impl;
92 }
93};
94
95} // namespace grk
uint64_t precinctIndex
Definition BlockExec.h:78
uint64_t cblkno
Definition BlockExec.h:79
TileProcessor * tileProcessor
Definition PacketManager.h:100
grk_pt32 cblk_expn_
Definition Precinct.h:58
bool isCompressor_
Definition Precinct.h:59
BlockCache< CompressCodeblock, PrecinctImpl > * enc
Definition Precinct.h:54
TagTreeU16 * incltree
Definition Precinct.h:62
PrecinctImpl * impl
Definition Precinct.h:86
P * blockInitializer_
Definition Precinct.h:39
uint16_t numLayers_
Definition Precinct.h:40
grk_rect32 cblk_grid_
Definition Precinct.h:56
TagTreeU8 * imsbtree
Definition Precinct.h:63
grk_rect32 bounds_
Definition Precinct.h:57
BlockCache< DecompressCodeblock, PrecinctImpl > * dec
Definition Precinct.h:55
grk_rect32 bounds
Definition SparseCanvas.h:275
TagTree< uint16_t > TagTreeU16
Definition TileCache.h:259
TagTree< uint8_t > TagTreeU8
Definition TileCache.h:258
grk_rect< uint32_t > grk_rect32
Definition TileCache.h:61
grk_pt< uint32_t > grk_pt32
Definition TileCache.h:40
Copyright (C) 2016-2023 Grok Image Compression Inc.
Definition ICacheable.h:20
grk_rect< uint32_t > grk_rect32
Definition geometry.h:61