Grok  9.7.5
Resolution.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-2022 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 #pragma once
18 
19 #include "grk_includes.h"
20 
21 namespace grk
22 {
23 struct Resolution : public grk_rect32
24 {
27  current_plugin_tile(nullptr)
28  {}
29  virtual void print() const override
30  {
32  for(uint32_t i = 0; i < numTileBandWindows; ++i)
33  {
34  std::cout << "band " << i << " : ";
35  tileBand[i].print();
36  }
37  }
38  bool init(bool isCompressor, TileComponentCodingParams* tccp, uint8_t resno,
40  {
41  if(initialized)
42  return true;
43 
44  this->current_plugin_tile = current_plugin_tile;
45 
46  /* p. 35, table A-23, ISO/IEC FDIS154444-1 : 2000 (18 august 2000) */
47  precinctExpn = grk_pt32(tccp->precWidthExp[resno], tccp->precHeightExp[resno]);
48 
49  /* p. 64, B.6, ISO/IEC FDIS15444-1 : 2000 (18 august 2000) */
52 
53  uint64_t num_precincts = (uint64_t)precinctGridWidth * precinctGridHeight;
54  if(resno != 0)
55  {
57  grk_pt32(ceildivpow2<uint32_t>(precinctPartitionTopLeft.x, 1),
58  ceildivpow2<uint32_t>(precinctPartitionTopLeft.y, 1));
59  precinctExpn.x--;
60  precinctExpn.y--;
61  }
62  cblkExpn = grk_pt32(std::min<uint32_t>(tccp->cblkw, precinctExpn.x),
63  std::min<uint32_t>(tccp->cblkh, precinctExpn.y));
64  for(uint8_t bandIndex = 0; bandIndex < numTileBandWindows; ++bandIndex)
65  {
66  auto curr_band = tileBand + bandIndex;
67  curr_band->numPrecincts = num_precincts;
68  if(isCompressor)
69  {
70  for(uint64_t precinctIndex = 0; precinctIndex < num_precincts; ++precinctIndex)
71  {
72  if(!curr_band->createPrecinct(true, precinctIndex, precinctPartitionTopLeft,
74  return false;
75  }
76  }
77  }
78  initialized = true;
79 
80  return true;
81  }
82 
84  Subband tileBand[BAND_NUM_INDICES]; // unreduced tile component bands in canvas coordinates
85  uint32_t numTileBandWindows; // 1 or 3
86  uint32_t precinctGridWidth, precinctGridHeight; /* dimensions of precinct grid */
91 };
92 
93 } // namespace grk
Copyright (C) 2016-2022 Grok Image Compression Inc.
Definition: ICacheable.h:20
grk_pt< uint32_t > grk_pt32
Definition: util.h:37
static uint32_t floordivpow2(uint32_t a, uint32_t b)
Divide an unsigned integer by a power of 2 and round downwards.
Definition: grk_intmath.h:48
@ BAND_NUM_INDICES
Definition: Subband.h:41
Plugin tile.
Definition: grok.h:1095
Definition: Resolution.h:24
bool initialized
Definition: Resolution.h:83
uint32_t precinctGridWidth
Definition: Resolution.h:86
uint32_t numTileBandWindows
Definition: Resolution.h:85
Subband tileBand[BAND_NUM_INDICES]
Definition: Resolution.h:84
grk_pt32 precinctPartitionTopLeft
Definition: Resolution.h:88
virtual void print() const override
Definition: Resolution.h:29
Resolution()
Definition: Resolution.h:25
bool init(bool isCompressor, TileComponentCodingParams *tccp, uint8_t resno, grk_plugin_tile *current_plugin_tile)
Definition: Resolution.h:38
uint32_t precinctGridHeight
Definition: Resolution.h:86
grk_plugin_tile * current_plugin_tile
Definition: Resolution.h:90
grk_pt32 cblkExpn
Definition: Resolution.h:87
grk_pt32 precinctExpn
Definition: Resolution.h:89
Definition: Subband.h:45
void print() const override
Definition: Subband.h:61
uint64_t numPrecincts
Definition: Subband.h:116
Tile-component coding parameters.
Definition: CodingParams.h:53
uint8_t cblkh
log2(code-blocks height)
Definition: CodingParams.h:62
uint32_t precWidthExp[GRK_J2K_MAXRLVLS]
precinct width (power of 2 exponent, < 16)
Definition: CodingParams.h:85
uint8_t cblkw
log2(code-blocks width)
Definition: CodingParams.h:60
uint32_t precHeightExp[GRK_J2K_MAXRLVLS]
precinct height (power of 2 exponent, < 16)
Definition: CodingParams.h:87
T x
Definition: util.h:34
T y
Definition: util.h:35
uint32_t x0
Definition: util.h:109
virtual void print(void) const
Definition: util.h:111
uint32_t y0
Definition: util.h:109