PostT1DecompressFilters.h
Go to the documentation of this file.
#pragma once
#include "grk_includes.h"
namespace grk
{
template<typename T>
class RoiShiftFilter
{
public:
RoiShiftFilter(DecompressBlockExec* block) : roiShift(block->roishift) {}
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 = abs(val);
if(mag >= thresh)
{
mag >>= roiShift;
val = val < 0 ? -mag : mag;
}
dest[i] = val / 2;
}
}
private:
uint32_t roiShift;
};
template<typename T>
class ShiftFilter
{
public:
ShiftFilter([[maybe_unused]] DecompressBlockExec* block) {}
inline void copy(T* dest, T* src, uint32_t len)
{
for(uint32_t i = 0; i < len; ++i)
dest[i] = src[i] / 2;
}
};
template<typename T>
class RoiScaleFilter
{
public:
RoiScaleFilter(DecompressBlockExec* block)
: roiShift(block->roishift), scale(block->stepsize / 2)
{}
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 = abs(val);
if(mag >= thresh)
{
mag >>= roiShift;
val = val < 0 ? -mag : mag;
}
((float*)dest)[i] = (float)val * scale;
}
}
private:
uint32_t roiShift;
float scale;
};
template<typename T>
class ScaleFilter
{
public:
ScaleFilter(DecompressBlockExec* block) : scale(block->stepsize / 2) {}
inline void copy(T* dest, T* src, uint32_t len)
{
for(uint32_t i = 0; i < len; ++i)
((float*)dest)[i] = (float)src[i] * scale;
}
private:
float scale;
};
} // namespace grk
grk::RoiScaleFilter
Definition PostT1DecompressFilters.h:45
grk::RoiScaleFilter::scale
float scale
Definition PostT1DecompressFilters.h:68
grk::RoiScaleFilter::roiShift
uint32_t roiShift
Definition PostT1DecompressFilters.h:67
grk::RoiScaleFilter::copy
void copy(T *dest, T *src, uint32_t len)
Definition PostT1DecompressFilters.h:50
grk::RoiScaleFilter::RoiScaleFilter
RoiScaleFilter(DecompressBlockExec *block)
Definition PostT1DecompressFilters.h:47
grk::RoiShiftFilter
Definition PostT1DecompressFilters.h:9
grk::RoiShiftFilter::copy
void copy(T *dest, T *src, uint32_t len)
Definition PostT1DecompressFilters.h:12
grk::RoiShiftFilter::roiShift
uint32_t roiShift
Definition PostT1DecompressFilters.h:29
grk::RoiShiftFilter::RoiShiftFilter
RoiShiftFilter(DecompressBlockExec *block)
Definition PostT1DecompressFilters.h:11
grk::ScaleFilter
Definition PostT1DecompressFilters.h:73
grk::ScaleFilter::copy
void copy(T *dest, T *src, uint32_t len)
Definition PostT1DecompressFilters.h:76
grk::ScaleFilter::scale
float scale
Definition PostT1DecompressFilters.h:83
grk::ScaleFilter::ScaleFilter
ScaleFilter(DecompressBlockExec *block)
Definition PostT1DecompressFilters.h:75
grk::ShiftFilter
Definition PostT1DecompressFilters.h:33
grk::ShiftFilter::copy
void copy(T *dest, T *src, uint32_t len)
Definition PostT1DecompressFilters.h:36
grk::ShiftFilter::ShiftFilter
ShiftFilter(DecompressBlockExec *block)
Definition PostT1DecompressFilters.h:35
grk_includes.h
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::DecompressBlockExec
Definition BlockExec.h:45