Grok 20.3.2
grk::ResPrecinctInfo Struct Reference

Cached geometric state of a tile component's resolution, relative to its precinct grid. More...

#include <PacketIter.h>

Public Member Functions

 ResPrecinctInfo ()
bool init (uint8_t resno, uint8_t decompLevel, Rect32 tileBounds, uint32_t dx, uint32_t dy, bool windowed, Rect32 tileWindow)
 Initializes resolution precinct info for a specific resolution level.
void print (void)
 Prints resolution precinct info for debugging.

Public Attributes

uint8_t precWidthExp
 log2 precinct width in resolution space (0-15, from codestream SPcoc)
uint8_t precHeightExp
 log2 precinct height in resolution space
uint8_t precWidthExpPRJ
 log2 precinct width in projected space: precWidthExp + decompLevel
uint8_t precHeightExpPRJ
 log2 precinct height in projected space: precHeightExp + decompLevel
uint32_t resOffsetX0PRJ
 horizontal offset of resolution origin relative to projected precinct grid (zero when tile origin is (0,0))
uint32_t resOffsetY0PRJ
 vertical offset of resolution origin relative to projected precinct grid
uint64_t precWidthPRJ
 precinct width in projected space: compDx << precWidthExpPRJ
uint64_t precWidthPRJMinusOne
 precWidthPRJ - 1 (cached for bitwise alignment checks)
uint64_t precHeightPRJ
 precinct height in projected space: compDy << precHeightExpPRJ
uint64_t precHeightPRJMinusOne
 precHeightPRJ - 1 (cached for bitwise alignment checks)
uint64_t numPrecincts_
 total number of precincts in this resolution (= tileBoundsPrecGrid.area())
uint64_t dxPRJ
 component subsampling projected to resolution: compDx << decompLevel
uint64_t dyPRJ
 component subsampling projected to resolution: compDy << decompLevel
uint32_t resInPrecGridX0
 floor(res.x0 / 2^precWidthExp): resolution origin in precinct grid coords
uint32_t resInPrecGridY0
 floor(res.y0 / 2^precHeightExp): resolution origin in precinct grid coords
uint8_t resno_
 resolution number (0 = lowest)
uint8_t decompLevel_
 decomposition level (numresolutions - 1 - resno)
Rect< uint64_t > tileBoundsPrecPRJ
 tile bounds snapped to precinct boundaries, in projected space
Rect32 tileBoundsPrecGrid
 tile bounds mapped to precinct grid (resolution space)
Rect< uint64_t > winPrecPRJ
 decode window bounds snapped to precinct boundaries, in projected space
Rect32 winPrecGrid
 decode window bounds mapped to precinct grid (resolution space)
uint64_t innerPrecincts_
 cached packet count: comp_e * lay_e (for RPCL skip optimization)
uint64_t winPrecinctsLeft_
 packets in precinct columns to the left of the decode window
uint64_t winPrecinctsRight_
 packets in precinct columns to the right of the decode window
uint64_t winPrecinctsTop_
 packets in precinct rows above the decode window
uint64_t winPrecinctsBottom_
 packets in precinct rows below the decode window
bool valid
 true if init() completed successfully

Detailed Description

Cached geometric state of a tile component's resolution, relative to its precinct grid.

In JPEG 2000, each resolution level has its own precinct grid. When iterating packets across resolutions (e.g. RPCL, CPRL, PCRL progression orders), lower-resolution precincts must be projected onto the highest-resolution coordinate system so all resolutions share a common iteration grid. Fields suffixed with "PRJ" represent values in this projected (highest-resolution) coordinate space.

Coordinate Spaces

  • Resolution space: native coordinates of a resolution level, after subsampling by compDx * 2^decompLevel. Precinct dimensions here are 2^precWidthExp x 2^precHeightExp.
  • Projected (PRJ) space: coordinates projected back to the highest resolution. Precinct dimensions become compDx * 2^(precWidthExp + decompLevel) in this space.
  • Precinct grid: integer grid where each cell represents one precinct. Obtained by dividing resolution-space coordinates by precinct dimensions.

Overflow Protection

init() returns false if projected precinct dimensions exceed UINT32_MAX, since Rect32::scale() operates on uint32_t coordinates. This prevents silent truncation that could produce degenerate tile bounds and infinite iteration loops.

Windowed Decode

When decoding a spatial sub-region (window), winPrecGrid and winPrecPRJ describe the precinct bounds that intersect the decode window. The winPrecincts{Left,Right,Top,Bottom} fields cache packet counts for precincts outside the window, enabling efficient skipping via PLT markers.

Constructor & Destructor Documentation

◆ ResPrecinctInfo()

Member Function Documentation

◆ init()

bool grk::ResPrecinctInfo::init ( uint8_t resno,
uint8_t decompLevel,
Rect32 tileBounds,
uint32_t dx,
uint32_t dy,
bool windowed,
Rect32 tileWindow )

Initializes resolution precinct info for a specific resolution level.

Computes precinct grid dimensions, projected coordinates, and windowed decode bounds. Returns false if the resolution has zero extent, or if projected precinct dimensions would overflow uint32_t (preventing Rect32::scale() truncation bugs).

Parameters
resnoresolution number (0 = lowest)
decompLeveldecomposition level (numresolutions - 1 - resno)
tileBoundstile bounds in image coordinates
dxcomponent horizontal subsampling factor
dycomponent vertical subsampling factor
windowedtrue if decoding a sub-region
tileWindowdecode window in unreduced tile coordinates (used only if windowed)
Returns
true on success, false if resolution is degenerate or overflows

References grk::Rect< T >::clip_IN_PLACE(), decompLevel_, dxPRJ, dyPRJ, grk::floordivpow2(), grk::Rect< T >::grow_IN_PLACE(), numPrecincts_, precHeightExp, precHeightExpPRJ, precHeightPRJ, precHeightPRJMinusOne, precWidthExp, precWidthExpPRJ, precWidthPRJ, precWidthPRJMinusOne, resInPrecGridX0, resInPrecGridY0, resno_, resOffsetX0PRJ, resOffsetY0PRJ, grk::Rect< T >::scaleDownCeil(), tileBoundsPrecGrid, tileBoundsPrecPRJ, valid, winPrecGrid, and winPrecPRJ.

Referenced by grk::PacketIter::genPrecinctInfo(), and grk::PacketIter::validatePrecinct().

◆ print()

void grk::ResPrecinctInfo::print ( void )

Member Data Documentation

◆ decompLevel_

◆ dxPRJ

uint64_t grk::ResPrecinctInfo::dxPRJ

component subsampling projected to resolution: compDx << decompLevel

Referenced by grk::PacketIter::genPrecinctX0Grid(), init(), print(), and ResPrecinctInfo().

◆ dyPRJ

uint64_t grk::ResPrecinctInfo::dyPRJ

component subsampling projected to resolution: compDy << decompLevel

Referenced by grk::PacketIter::genPrecinctY0Grid(), init(), print(), and ResPrecinctInfo().

◆ innerPrecincts_

uint64_t grk::ResPrecinctInfo::innerPrecincts_

cached packet count: comp_e * lay_e (for RPCL skip optimization)

Referenced by ResPrecinctInfo().

◆ numPrecincts_

uint64_t grk::ResPrecinctInfo::numPrecincts_

total number of precincts in this resolution (= tileBoundsPrecGrid.area())

Referenced by init(), print(), and ResPrecinctInfo().

◆ precHeightExp

◆ precHeightExpPRJ

uint8_t grk::ResPrecinctInfo::precHeightExpPRJ

log2 precinct height in projected space: precHeightExp + decompLevel

Referenced by init(), and ResPrecinctInfo().

◆ precHeightPRJ

uint64_t grk::ResPrecinctInfo::precHeightPRJ

precinct height in projected space: compDy << precHeightExpPRJ

Referenced by grk::PacketIter::genPrecinctY0Grid(), init(), print(), and ResPrecinctInfo().

◆ precHeightPRJMinusOne

uint64_t grk::ResPrecinctInfo::precHeightPRJMinusOne

precHeightPRJ - 1 (cached for bitwise alignment checks)

Referenced by grk::PacketIter::genPrecinctY0GridPCRL_OPT(), init(), and ResPrecinctInfo().

◆ precWidthExp

◆ precWidthExpPRJ

uint8_t grk::ResPrecinctInfo::precWidthExpPRJ

log2 precinct width in projected space: precWidthExp + decompLevel

Referenced by init(), and ResPrecinctInfo().

◆ precWidthPRJ

uint64_t grk::ResPrecinctInfo::precWidthPRJ

precinct width in projected space: compDx << precWidthExpPRJ

Referenced by grk::PacketIter::genPrecinctX0Grid(), init(), print(), and ResPrecinctInfo().

◆ precWidthPRJMinusOne

uint64_t grk::ResPrecinctInfo::precWidthPRJMinusOne

precWidthPRJ - 1 (cached for bitwise alignment checks)

Referenced by grk::PacketIter::genPrecinctX0GridPCRL_OPT(), init(), and ResPrecinctInfo().

◆ resInPrecGridX0

uint32_t grk::ResPrecinctInfo::resInPrecGridX0

floor(res.x0 / 2^precWidthExp): resolution origin in precinct grid coords

Referenced by grk::PacketIter::genPrecinctX0Grid(), grk::PacketIter::genPrecinctX0GridPCRL_OPT(), grk::PacketIter::genPrecinctX0GridRPCL_OPT(), init(), and ResPrecinctInfo().

◆ resInPrecGridY0

uint32_t grk::ResPrecinctInfo::resInPrecGridY0

floor(res.y0 / 2^precHeightExp): resolution origin in precinct grid coords

Referenced by grk::PacketIter::genPrecinctY0Grid(), grk::PacketIter::genPrecinctY0GridPCRL_OPT(), grk::PacketIter::genPrecinctY0GridRPCL_OPT(), init(), and ResPrecinctInfo().

◆ resno_

uint8_t grk::ResPrecinctInfo::resno_

resolution number (0 = lowest)

Referenced by init(), print(), and ResPrecinctInfo().

◆ resOffsetX0PRJ

uint32_t grk::ResPrecinctInfo::resOffsetX0PRJ

horizontal offset of resolution origin relative to projected precinct grid (zero when tile origin is (0,0))

Referenced by grk::PacketIter::genPrecinctX0Grid(), init(), and ResPrecinctInfo().

◆ resOffsetY0PRJ

uint32_t grk::ResPrecinctInfo::resOffsetY0PRJ

vertical offset of resolution origin relative to projected precinct grid

Referenced by grk::PacketIter::genPrecinctY0Grid(), init(), and ResPrecinctInfo().

◆ tileBoundsPrecGrid

Rect32 grk::ResPrecinctInfo::tileBoundsPrecGrid

tile bounds mapped to precinct grid (resolution space)

Referenced by init(), and print().

◆ tileBoundsPrecPRJ

Rect<uint64_t> grk::ResPrecinctInfo::tileBoundsPrecPRJ

tile bounds snapped to precinct boundaries, in projected space

Referenced by init(), and print().

◆ valid

bool grk::ResPrecinctInfo::valid

true if init() completed successfully

Referenced by init(), grk::PacketIter::precInfoCheck(), and ResPrecinctInfo().

◆ winPrecGrid

Rect32 grk::ResPrecinctInfo::winPrecGrid

decode window bounds mapped to precinct grid (resolution space)

Referenced by init(), and print().

◆ winPrecinctsBottom_

uint64_t grk::ResPrecinctInfo::winPrecinctsBottom_

packets in precinct rows below the decode window

Referenced by ResPrecinctInfo().

◆ winPrecinctsLeft_

uint64_t grk::ResPrecinctInfo::winPrecinctsLeft_

packets in precinct columns to the left of the decode window

Referenced by ResPrecinctInfo().

◆ winPrecinctsRight_

uint64_t grk::ResPrecinctInfo::winPrecinctsRight_

packets in precinct columns to the right of the decode window

Referenced by ResPrecinctInfo().

◆ winPrecinctsTop_

uint64_t grk::ResPrecinctInfo::winPrecinctsTop_

packets in precinct rows above the decode window

Referenced by ResPrecinctInfo().

◆ winPrecPRJ

Rect<uint64_t> grk::ResPrecinctInfo::winPrecPRJ

decode window bounds snapped to precinct boundaries, in projected space

Referenced by init(), and print().


The documentation for this struct was generated from the following files: