AVIR
High-quality pro image resizing library
 
Loading...
Searching...
No Matches
avir::CImageResizerFilterStepINL< fptype, fptypeatom > Class Template Reference

Interleaved filtering steps implementation class. More...

#include <avir.h>

Inheritance diagram for avir::CImageResizerFilterStepINL< fptype, fptypeatom >:
avir::CImageResizerFilterStep< fptype, fptypeatom >

Public Member Functions

void calcScanlineBias (const fptype *p, const int SrcLen, fptype *const ElBiases) const
 
void convertVtoH (const fptype *ip, fptype *op, const int SrcLen, const int SrcIncr) const
 
void doFilter (const fptype *const Src, fptype *Dst, const int DstIncr) const
 
void doResize (const fptype *SrcLine, fptype *DstLine, const int DstLineIncr, const fptype *const ElBiases, fptype *const) const
 
void doResize2 (const fptype *SrcLine, fptype *DstLine, const int DstLineIncr, const fptype *const ElBiases, fptype *const) const
 
void doUpsample (const fptype *const Src, fptype *const Dst) const
 
template<class Tin>
void packScanline (const Tin *ip, fptype *const op0, const int l0) const
 
void prepareInBuf (fptype *Src) const
 
void unbiasScanline (fptype *p, int l, const fptype *const ElBiases) const
 

Static Public Member Functions

static void applySRGBGamma (fptype *p, int l, const CImageResizerVars &Vars0)
 
template<class Tout>
static void unpackScanline (const fptype *ip, Tout *op, int l, const CImageResizerVars &Vars0)
 

Additional Inherited Members

- Public Attributes inherited from avir::CImageResizerFilterStep< fptype, fptypeatom >
double DCGain
 DC gain which was applied to the filter. Not defined if ResampleFactor = 0.
 
int EdgePixelCount
 The number of edge pixels added. Affects the initial position within the input scanline, used to produce edge pixels. This variable is used and should be defined when IsUpsample=false and ResampleFactor>0. When assigning this variable it is also necessary to update InPrefix, OutLen and Vars.o variables.
 
CBuffer< fptype > Flt
 Filter to use at this step.
 
CDSPFracFilterBankLin< fptype > * FltBank
 Filter bank in use by *this resizing step.
 
int FltLatency
 Filter's latency (group delay, shift) in pixels.
 
CFltBuffer FltOrig
 Originally-designed filter. This buffer may not be assigned. Assigned by filters that precede the resizing step if such filter is planned to be embedded into the interpolation filter as "external" filter. If IsUpsample=true and this filter buffer is not empty, the upsampling step will not itself apply any filtering over upsampled input scanline.
 
int InBuf
 Input buffer index, 0 or 1.
 
int InElIncr
 Pixel element increment within the input buffer, used during de-interleaved processing: in this case each image's channel is stored independently, InElIncr elements apart.
 
int InLen
 Input scanline's length in pixels.
 
int InPrefix
 Required input prefix pixels. These prefix pixels will be filled with source scanline's first pixel value. If IsUpsample is "true", this is the additional number of times the first pixel will be filtered before processing scanline, this number is also reflected in the OutPrefix.
 
int InSuffix
 Required input suffix pixels. These suffix pixels will be filled with source scanline's last pixel value. If IsUpsample is "true", this is the additional number of times the last pixel will be filtered before processing scanline, this number is also reflected in the OutSuffix.
 
bool IsUpsample
 "True" if this step is an upsampling step, "false" if downsampling step. Should be set to "false" if ResampleFactor equals 0.
 
int OutBuf
 Output buffer index. 0 or 1; 2 for the last step.
 
int OutElIncr
 Pixel element increment within the output buffer, used during de-interleaved processing. Equals to the InBufElIncr of the next step.
 
int OutLen
 Length of the resulting scanline.
 
int OutPrefix
 Required output prefix pixels. These prefix pixels will not be pre-filled with any values. Value is valid only if IsUpsample equals "true".
 
int OutSuffix
 Required input suffix pixels. These suffix pixels will not be pre-filled with any values. Value is valid only if IsUpsample equals "true".
 
CBuffer< fptype > PrefixDC
 DC component fluctuations added at the start of the resulting scanline, used when IsUpsample equals "true".
 
int ResampleFactor
 Resample factor (>=1). If 0, this is a resizing step. This value should be >1 if IsUpsample equals "true".
 
CRPosBufRPosBuf
 Resizing positions buffer. Used when ResampleFactor equals 0 (resizing step).
 
CBuffer< fptype > SuffixDC
 DC component fluctuations added at the end of the resulting scanline, used when IsUpsample equals "true".
 
const CImageResizerVarsVars
 Image resizing-related variables.
 
- Static Public Attributes inherited from avir::CImageResizerFilterStep< fptype, fptypeatom >
static const int EdgePixelCountDef = 3
 The default number of pixels additionally produced at scanline edges during filtering. This is required to reduce edge artifacts.
 

Detailed Description

template<class fptype, class fptypeatom>
class avir::CImageResizerFilterStepINL< fptype, fptypeatom >

Interleaved filtering steps implementation class.

This class implements scanline filtering functions in interleaved mode. This means that each pixel is processed independently, not in groups.

Template Parameters
fptypeFloating point type to use for storing pixel elements. SIMD types can be used: in this case each element may hold a whole pixel.
fptypeatomThe atomic type the "fptype" consists of.

Member Function Documentation

◆ applySRGBGamma()

template<class fptype, class fptypeatom>
static void avir::CImageResizerFilterStepINL< fptype, fptypeatom >::applySRGBGamma ( fptype * p,
int l,
const CImageResizerVars & Vars0 )
static

Function applies Linear to sRGB gamma correction to the specified scanline.

Parameters
pScanline.
lThe number of pixels to de-linearize.
Vars0Image resizing-related variables.

◆ calcScanlineBias()

template<class fptype, class fptypeatom>
void avir::CImageResizerFilterStepINL< fptype, fptypeatom >::calcScanlineBias ( const fptype * p,
const int SrcLen,
fptype *const ElBiases ) const

Function calculates scanline's DC gain for each channel, further used to "unbias" the scanline.

Parameters
pSource scanline.
SrcLenSource scanline's length.
[out]ElBiasesResuling biases.

◆ convertVtoH()

template<class fptype, class fptypeatom>
void avir::CImageResizerFilterStepINL< fptype, fptypeatom >::convertVtoH ( const fptype * ip,
fptype * op,
const int SrcLen,
const int SrcIncr ) const

Function converts vertical scanline to horizontal scanline. This function is called by the image resizer when image is resized vertically. This means that the vertical scanline is stored in the same format produced by the packScanline() and maintained by other filtering functions.

Parameters
ipInput vertical scanline.
opOutput buffer (temporary buffer used during resizing).
SrcLenThe number of pixels in the input scanline, also used to calculate input buffer increment.
SrcIncrInput buffer increment to the next vertical pixel.

◆ doFilter()

template<class fptype, class fptypeatom>
void avir::CImageResizerFilterStepINL< fptype, fptypeatom >::doFilter ( const fptype *const Src,
fptype * Dst,
const int DstIncr ) const

Function peforms scanline filtering with optional downsampling. Function makes use of the symmetry of the filter.

Parameters
SrcSource scanline buffer (length = this -> InLen). Source scanline increment will be equal to ElCount.
DstDestination scanline buffer.
DstIncrDestination scanline buffer increment, used for horizontal or vertical scanline stepping.

◆ doResize()

template<class fptype, class fptypeatom>
void avir::CImageResizerFilterStepINL< fptype, fptypeatom >::doResize ( const fptype * SrcLine,
fptype * DstLine,
const int DstLineIncr,
const fptype *const ElBiases,
fptype * const  ) const

Function performs resizing of a single scanline. This function does not "know" about the length of the source scanline buffer. This buffer should be padded with enough pixels so that ( SrcPos - FilterLenD2 ) is always >= 0 and ( SrcPos + ( DstLineLen - 1 ) * k + FilterLenD2 + 1 ) does not exceed source scanline's buffer length. SrcLine's increment is assumed to be equal to ElCount.

Parameters
SrcLineSource scanline buffer.
DstLineDestination (resized) scanline buffer.
DstLineIncrDestination scanline position increment, used for horizontal or vertical scanline stepping.
ElBiasesBias values to add to the resulting scanline.
xxTemporary buffer, of size FltBank -> getFilterLen(), must be aligned by fpclass :: fpalign.

◆ doResize2()

template<class fptype, class fptypeatom>
void avir::CImageResizerFilterStepINL< fptype, fptypeatom >::doResize2 ( const fptype * SrcLine,
fptype * DstLine,
const int DstLineIncr,
const fptype *const ElBiases,
fptype * const  ) const

Function performs resizing of a single scanline assuming that the input buffer consists of zero-padded elements (2X upsampling without filtering). Similar to the doResize() function otherwise.

Parameters
SrcLineSource scanline buffer.
DstLineDestination (resized) scanline buffer.
DstLineIncrDestination scanline position increment, used for horizontal or vertical scanline stepping.
ElBiasesBias values to add to the resulting scanline.
xxTemporary buffer, of size FltBank -> getFilterLen(), must be aligned by fpclass :: fpalign.

◆ doUpsample()

template<class fptype, class fptypeatom>
void avir::CImageResizerFilterStepINL< fptype, fptypeatom >::doUpsample ( const fptype *const Src,
fptype *const Dst ) const

Function peforms scanline upsampling with filtering.

Parameters
SrcSource scanline buffer (length = this -> InLen). Source scanline increment will be equal to ElCount.
DstDestination scanline buffer.

◆ packScanline()

template<class fptype, class fptypeatom>
template<class Tin>
void avir::CImageResizerFilterStepINL< fptype, fptypeatom >::packScanline ( const Tin * ip,
fptype *const op0,
const int l0 ) const

Function performs "packing" of a scanline, and type conversion. Scanline, depending on the "fptype" can be potentially stored as a packed SIMD values having a certain atomic type. If required, the sRGB gamma correction is applied.

Parameters
ipInput scanline.
op0Output scanline.
l0The number of pixels to "pack".

◆ prepareInBuf()

template<class fptype, class fptypeatom>
void avir::CImageResizerFilterStepINL< fptype, fptypeatom >::prepareInBuf ( fptype * Src) const

Function prepares input scanline buffer for *this filtering step. Left- and right-most pixels are replicated to make sure no buffer overrun happens. Such approach also allows to bypass any pointer range checks.

Parameters
SrcSource buffer.

◆ unbiasScanline()

template<class fptype, class fptypeatom>
void avir::CImageResizerFilterStepINL< fptype, fptypeatom >::unbiasScanline ( fptype * p,
int l,
const fptype *const ElBiases ) const

Function applies "unbiasing" to the scanline, by subtracting the previously calculated bias (DC gain) values.

Parameters
pScanline.
lScanline's length.
ElBiasesBiases to subtract, for each channel.

◆ unpackScanline()

template<class fptype, class fptypeatom>
template<class Tout>
static void avir::CImageResizerFilterStepINL< fptype, fptypeatom >::unpackScanline ( const fptype * ip,
Tout * op,
int l,
const CImageResizerVars & Vars0 )
static

Function performs "unpacking" of a scanline and type conversion (truncation is used when floating point is converted to integer). Scanline, depending on the "fptype" can be potentially stored as a packed SIMD values having a certain atomic type. The unpacking function assumes that scanline is stored in the style produced by the packScanline() function.

Parameters
ipInput scanline.
opOutput scanline.
lThe number of pixels to "unpack".
Vars0Image resizing-related variables.