ResSimple.h
Go to the documentation of this file.
#pragma once
namespace grk
{
enum eBandOrientation
{
BAND_ORIENT_LL,
BAND_ORIENT_HL,
BAND_ORIENT_LH,
BAND_ORIENT_HH,
BAND_NUM_ORIENTATIONS
};
// LL band index when resolution == 0
const uint32_t BAND_RES_ZERO_INDEX_LL = 0;
// band indices when resolution > 0
enum eBandIndex
{
BAND_INDEX_HL,
BAND_INDEX_LH,
BAND_INDEX_HH,
BAND_NUM_INDICES
};
struct ResSimple : public grk_rect32
{
ResSimple(void) : numTileBandWindows(0) {}
ResSimple(grk_rect32* res, uint8_t numTileBandWindows, grk_rect32 (&tileBand)[BAND_NUM_INDICES])
{
setRect(res);
this->numTileBandWindows = numTileBandWindows;
for(uint8_t i = 0; i < numTileBandWindows; i++)
this->tileBand[i] = tileBand[i];
}
ResSimple(grk_rect32 currentRes, bool finalResolution)
{
setRect(currentRes);
if(finalResolution)
{
numTileBandWindows = 1;
tileBand[0] = currentRes;
}
else
{
numTileBandWindows = 3;
for(uint8_t j = 0; j < numTileBandWindows; ++j)
tileBand[j] = getBandWindow(1, j + 1, currentRes);
}
}
static grk_rect32 getBandWindow(uint8_t numDecomps, uint8_t orientation,
grk_rect32 tileCompWindowUnreduced)
{
assert(orientation < BAND_NUM_ORIENTATIONS);
if(numDecomps == 0)
return tileCompWindowUnreduced;
/* project window onto sub-band generated by `numDecomps` decompositions */
/* See equation B-15 of the standard. */
uint32_t bx0 = orientation & 1;
uint32_t by0 = (uint32_t)(orientation >> 1U);
uint32_t bx0Offset = (1U << (numDecomps - 1)) * bx0;
uint32_t by0Offset = (1U << (numDecomps - 1)) * by0;
uint32_t tc_originx0 = tileCompWindowUnreduced.origin_x0;
uint32_t tc_originy0 = tileCompWindowUnreduced.origin_y0;
uint32_t tcx0 = tileCompWindowUnreduced.x0;
uint32_t tcy0 = tileCompWindowUnreduced.y0;
uint32_t tcx1 = tileCompWindowUnreduced.x1;
uint32_t tcy1 = tileCompWindowUnreduced.y1;
return grk_rect32(
(tc_originx0 <= bx0Offset) ? 0
: ceildivpow2<uint32_t>(tc_originx0 - bx0Offset, numDecomps),
(tc_originy0 <= by0Offset) ? 0
: ceildivpow2<uint32_t>(tc_originy0 - by0Offset, numDecomps),
(tcx0 <= bx0Offset) ? 0 : ceildivpow2<uint32_t>(tcx0 - bx0Offset, numDecomps),
(tcy0 <= by0Offset) ? 0 : ceildivpow2<uint32_t>(tcy0 - by0Offset, numDecomps),
(tcx1 <= bx0Offset) ? 0 : ceildivpow2<uint32_t>(tcx1 - bx0Offset, numDecomps),
(tcy1 <= by0Offset) ? 0 : ceildivpow2<uint32_t>(tcy1 - by0Offset, numDecomps));
}
grk_rect32 tileBand[BAND_NUM_INDICES]; // unreduced tile component bands in canvas coordinates
uint8_t numTileBandWindows; // 1 or 3
};
} // namespace grk
grk
Copyright (C) 2016-2023 Grok Image Compression Inc.
Definition ICacheable.h:20
grk::grk_read
void grk_read(const uint8_t *buffer, TYPE *value, uint32_t numBytes)
Definition BufferedStream.h:239
grk::grk_rect32
grk_rect< uint32_t > grk_rect32
Definition geometry.h:61
grk::eBandOrientation
eBandOrientation
Definition ResSimple.h:23
grk::BAND_ORIENT_HH
@ BAND_ORIENT_HH
Definition ResSimple.h:27
grk::BAND_ORIENT_HL
@ BAND_ORIENT_HL
Definition ResSimple.h:25
grk::BAND_NUM_ORIENTATIONS
@ BAND_NUM_ORIENTATIONS
Definition ResSimple.h:28
grk::BAND_ORIENT_LH
@ BAND_ORIENT_LH
Definition ResSimple.h:26
grk::BAND_ORIENT_LL
@ BAND_ORIENT_LL
Definition ResSimple.h:24
grk::eBandIndex
eBandIndex
Definition ResSimple.h:35
grk::BAND_INDEX_HL
@ BAND_INDEX_HL
Definition ResSimple.h:36
grk::BAND_INDEX_LH
@ BAND_INDEX_LH
Definition ResSimple.h:37
grk::BAND_NUM_INDICES
@ BAND_NUM_INDICES
Definition ResSimple.h:39
grk::BAND_INDEX_HH
@ BAND_INDEX_HH
Definition ResSimple.h:38
grk::BAND_RES_ZERO_INDEX_LL
const uint32_t BAND_RES_ZERO_INDEX_LL
Definition ResSimple.h:31
grk::ResSimple
Definition ResSimple.h:43
grk::ResSimple::ResSimple
ResSimple(grk_rect32 currentRes, bool finalResolution)
Definition ResSimple.h:52
grk::ResSimple::tileBand
grk_rect32 tileBand[BAND_NUM_INDICES]
Definition ResSimple.h:110
grk::ResSimple::ResSimple
ResSimple(void)
Definition ResSimple.h:44
grk::ResSimple::ResSimple
ResSimple(grk_rect32 *res, uint8_t numTileBandWindows, grk_rect32(&tileBand)[BAND_NUM_INDICES])
Definition ResSimple.h:45
grk::ResSimple::numTileBandWindows
uint8_t numTileBandWindows
Definition ResSimple.h:111
grk::ResSimple::getBandWindow
static grk_rect32 getBandWindow(uint8_t numDecomps, uint8_t orientation, grk_rect32 tileCompWindowUnreduced)
Get band window (in tile component coordinates) for specified number of decompositions.
Definition ResSimple.h:77
grk::grk_rect< uint32_t >
grk::grk_rect< uint32_t >::setRect
void setRect(grk_rect< uint32_t > *rhs)
Definition geometry.h:228