Grok  9.5.0
Resolution.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-2021 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 grkRectU32
24 {
27  current_plugin_tile(nullptr)
28  {}
29  void print()
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 = grkPointU32(tccp->precinctWidthExp[resno], tccp->precinctHeightExp[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  {
56  precinctStart = grkPointU32(ceildivpow2<uint32_t>(precinctStart.x, 1),
57  ceildivpow2<uint32_t>(precinctStart.y, 1));
58  precinctExpn.x--;
59  precinctExpn.y--;
60  }
61  cblkExpn = grkPointU32(std::min<uint32_t>(tccp->cblkw, precinctExpn.x),
62  std::min<uint32_t>(tccp->cblkh, precinctExpn.y));
63  for(uint8_t bandIndex = 0; bandIndex < numTileBandWindows; ++bandIndex)
64  {
65  auto curr_band = tileBand + bandIndex;
66  curr_band->numPrecincts = num_precincts;
67  if(isCompressor)
68  {
69  for(uint64_t precinctIndex = 0; precinctIndex < num_precincts; ++precinctIndex)
70  {
71  if(!curr_band->createPrecinct(true, precinctIndex, precinctStart, precinctExpn,
73  return false;
74  }
75  }
76  }
77  initialized = true;
78 
79  return true;
80  }
81 
83  Subband tileBand[BAND_NUM_INDICES]; // unreduced tile component bands in canvas coordinates
84  uint32_t numTileBandWindows; // 1 or 3
85  uint32_t precinctGridWidth, precinctGridHeight; /* dimensions of precinct grid */
90 };
91 
92 } // namespace grk
Copyright (C) 2016-2021 Grok Image Compression Inc.
Definition: ICacheable.h:20
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
grkPoint< uint32_t > grkPointU32
Definition: util.h:37
@ BAND_NUM_INDICES
Definition: Subband.h:41
Plugin tile.
Definition: grok.h:1096
Definition: Resolution.h:24
bool initialized
Definition: Resolution.h:82
uint32_t precinctGridWidth
Definition: Resolution.h:85
grkPointU32 precinctStart
Definition: Resolution.h:87
uint32_t numTileBandWindows
Definition: Resolution.h:84
Subband tileBand[BAND_NUM_INDICES]
Definition: Resolution.h:83
Resolution()
Definition: Resolution.h:25
grkPointU32 precinctExpn
Definition: Resolution.h:88
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:85
grk_plugin_tile * current_plugin_tile
Definition: Resolution.h:89
grkPointU32 cblkExpn
Definition: Resolution.h:86
void print()
Definition: Resolution.h:29
Definition: Subband.h:45
void print()
Definition: Subband.h:60
uint64_t numPrecincts
Definition: Subband.h:110
Tile-component coding parameters.
Definition: CodingParams.h:53
uint8_t cblkh
log2(code-blocks height)
Definition: CodingParams.h:62
uint32_t precinctHeightExp[GRK_J2K_MAXRLVLS]
precinct height (power of 2 exponent, < 16)
Definition: CodingParams.h:87
uint8_t cblkw
log2(code-blocks width)
Definition: CodingParams.h:60
uint32_t precinctWidthExp[GRK_J2K_MAXRLVLS]
precinct width (power of 2 exponent, < 16)
Definition: CodingParams.h:85
T x
Definition: util.h:34
T y
Definition: util.h:35
uint32_t y0
Definition: util.h:96
void print(void) const
Definition: util.h:107
uint32_t x0
Definition: util.h:96