PostT1DecompressFiltersOpenHTJ2K.h
Go to the documentation of this file.
#pragma once
#include "grk_includes.h"
namespace openhtj2k
{
template<typename T>
class RoiShiftOpenHTJ2KFilter
{
public:
RoiShiftOpenHTJ2KFilter(grk::DecompressBlockExec* block)
: roiShift(block->roishift), shift(31U - (block->k_msbs + 1U))
{}
inline void copy(T* dest, T* src, uint32_t len)
{
T thresh = 1 << roiShift;
for(uint32_t i = 0; i < len; ++i)
{
T val = src[i];
T mag = (val & 0x7FFFFFFF);
if(mag >= thresh)
val = (T)(((uint32_t)mag >> roiShift) & ((uint32_t)val & 0x80000000));
int32_t val_shifted = (val & 0x7FFFFFFF) >> shift;
dest[i] = (int32_t)(((uint32_t)val & 0x80000000) ? -val_shifted : val_shifted);
}
}
private:
uint32_t roiShift;
uint32_t shift;
};
template<typename T>
class ShiftOpenHTJ2KFilter
{
public:
ShiftOpenHTJ2KFilter([[maybe_unused]] grk::DecompressBlockExec* block) {}
inline void copy(T* dest, T* src, uint32_t len)
{
for(uint32_t i = 0; i < len; ++i)
{
dest[i] = src[i];
}
}
};
template<typename T>
class RoiScaleOpenHTJ2KFilter
{
public:
RoiScaleOpenHTJ2KFilter([[maybe_unused]] grk::DecompressBlockExec* block) {}
inline void copy(T* dest, T* src, uint32_t len)
{
for(uint32_t i = 0; i < len; ++i)
{
((float*)dest)[i] = src[i];
}
}
};
template<typename T>
class ScaleOpenHTJ2KFilter
{
public:
ScaleOpenHTJ2KFilter(grk::DecompressBlockExec* block)
: scale(block->stepsize / (float)(1u << (31 - (block->k_msbs + 1))))
{
assert(block->bandNumbps <= 31);
}
inline void copy(T* dest, T* src, uint32_t len)
{
for(uint32_t i = 0; i < len; ++i)
{
((float*)dest)[i] = src[i] * scale;
}
}
private:
float scale;
};
} // namespace openhtj2k
openhtj2k::RoiScaleOpenHTJ2KFilter
Definition PostT1DecompressFiltersOpenHTJ2K.h:48
openhtj2k::RoiScaleOpenHTJ2KFilter::copy
void copy(T *dest, T *src, uint32_t len)
Definition PostT1DecompressFiltersOpenHTJ2K.h:51
openhtj2k::RoiScaleOpenHTJ2KFilter::RoiScaleOpenHTJ2KFilter
RoiScaleOpenHTJ2KFilter(grk::DecompressBlockExec *block)
Definition PostT1DecompressFiltersOpenHTJ2K.h:50
openhtj2k::RoiShiftOpenHTJ2KFilter
Definition PostT1DecompressFiltersOpenHTJ2K.h:9
openhtj2k::RoiShiftOpenHTJ2KFilter::shift
uint32_t shift
Definition PostT1DecompressFiltersOpenHTJ2K.h:30
openhtj2k::RoiShiftOpenHTJ2KFilter::RoiShiftOpenHTJ2KFilter
RoiShiftOpenHTJ2KFilter(grk::DecompressBlockExec *block)
Definition PostT1DecompressFiltersOpenHTJ2K.h:11
openhtj2k::RoiShiftOpenHTJ2KFilter::roiShift
uint32_t roiShift
Definition PostT1DecompressFiltersOpenHTJ2K.h:29
openhtj2k::RoiShiftOpenHTJ2KFilter::copy
void copy(T *dest, T *src, uint32_t len)
Definition PostT1DecompressFiltersOpenHTJ2K.h:14
openhtj2k::ScaleOpenHTJ2KFilter
Definition PostT1DecompressFiltersOpenHTJ2K.h:62
openhtj2k::ScaleOpenHTJ2KFilter::ScaleOpenHTJ2KFilter
ScaleOpenHTJ2KFilter(grk::DecompressBlockExec *block)
Definition PostT1DecompressFiltersOpenHTJ2K.h:64
openhtj2k::ScaleOpenHTJ2KFilter::scale
float scale
Definition PostT1DecompressFiltersOpenHTJ2K.h:78
openhtj2k::ScaleOpenHTJ2KFilter::copy
void copy(T *dest, T *src, uint32_t len)
Definition PostT1DecompressFiltersOpenHTJ2K.h:69
openhtj2k::ShiftOpenHTJ2KFilter
Definition PostT1DecompressFiltersOpenHTJ2K.h:34
openhtj2k::ShiftOpenHTJ2KFilter::ShiftOpenHTJ2KFilter
ShiftOpenHTJ2KFilter(grk::DecompressBlockExec *block)
Definition PostT1DecompressFiltersOpenHTJ2K.h:36
openhtj2k::ShiftOpenHTJ2KFilter::copy
void copy(T *dest, T *src, uint32_t len)
Definition PostT1DecompressFiltersOpenHTJ2K.h:37
grk_includes.h
openhtj2k
Definition PostT1DecompressFiltersOpenHTJ2K.h:6
grk::BlockExec::bandNumbps
uint8_t bandNumbps
Definition BlockExec.h:32
grk::DecompressBlockExec
Definition BlockExec.h:45