Grok 20.3.2
Tile.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 <memory>
21
22#include "TileComponent.h"
23
24namespace grk
25{
26
27/*
28 * @struct Tile
29 * @brief Stores information about a JPEG 2000 tile and its components
30 *
31 * Tile dimensions live in canvas coordinates, and are equal to the
32 * full, non-windowed, unreduced tile dimensions.
33 *
34 * @ref TileComponent dimensions are reduced
35 * if there is a resolution reduction.
36 *
37 */
38struct Tile : public Rect32
39{
40 Tile() : Tile(0) {}
41
42 explicit Tile(uint16_t numcomps) : numcomps_(numcomps), comps_(nullptr), distortion_(0)
43 {
44 if(numcomps)
45 comps_ = new TileComponent[numcomps];
46 }
47
48 virtual ~Tile()
49 {
50 delete[] comps_;
51 }
52
53 double getLayerDistortion(uint16_t layer)
54 {
55 return getLayerDistortion()[layer];
56 }
57
58 void setLayerDistortion(uint16_t layer, double disto)
59 {
60 getLayerDistortion()[layer] = disto;
61 }
62
63 void incLayerDistortion(uint16_t layer, double distoDelta)
64 {
65 setLayerDistortion(layer, getLayerDistortion(layer) + distoDelta);
66 }
67
71 uint16_t numcomps_;
72
77
82
83private:
84 std::unique_ptr<double[]>& getLayerDistortion()
85 {
87 : (layerDistortion_ = std::make_unique<double[]>(maxCompressLayersGRK),
88 std::ranges::fill_n(layerDistortion_.get(), maxCompressLayersGRK, 0),
90 }
91
95 std::unique_ptr<double[]> layerDistortion_;
96};
97
98} // namespace grk
ResWindow.
Definition CompressedChunkCache.h:36
const uint16_t maxCompressLayersGRK
Definition CodeStreamLimits.h:40
Rect< uint32_t > Rect32
Definition geometry.h:64
Stores sub-sampled, unreduced tile component dimensions, along with reduction information.
Definition TileComponent.h:37
void incLayerDistortion(uint16_t layer, double distoDelta)
Definition Tile.h:63
double getLayerDistortion(uint16_t layer)
Definition Tile.h:53
Tile(uint16_t numcomps)
Definition Tile.h:42
Tile()
Definition Tile.h:40
TileComponent * comps_
array of TileComponent
Definition Tile.h:76
std::unique_ptr< double[]> layerDistortion_
distortion by layer
Definition Tile.h:95
std::unique_ptr< double[]> & getLayerDistortion()
Definition Tile.h:84
void setLayerDistortion(uint16_t layer, double disto)
Definition Tile.h:58
uint16_t numcomps_
number of components
Definition Tile.h:71
double distortion_
total tile distortion
Definition Tile.h:81
virtual ~Tile()
Definition Tile.h:48