AVIR
High-quality pro image resizing library
 
Loading...
Searching...
No Matches
avir.h File Reference

The "main" inclusion file with all required classes and functions. More...

#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

Go to the source code of this file.

Classes

class  avir::CBuffer< T, capint >
 Memory buffer class for element array storage, with capacity tracking. More...
 
class  avir::CDSPFIREQ
 FIR filter-based equalizer generator. More...
 
class  avir::CDSPFracFilterBankLin< fptype >
 Sinc function-based fractional delay filter bank. More...
 
class  avir::CDSPPeakedCosineLPF
 Low-pass filter windowed by Peaked Cosine window function. More...
 
class  avir::CDSPWindowGenPeakedCosine
 Peaked Cosine window function generator class. More...
 
class  avir::CFltBuffer
 Buffer class for parametrized low-pass filter. More...
 
class  avir::CImageResizer< fpclass >
 Image resizer class. More...
 
class  avir::CImageResizerDithererDefINL< fptype >
 Image resizer's default dithering class. More...
 
class  avir::CImageResizerDithererErrdINL< fptype >
 Image resizer's error-diffusion dithering class, interleaved mode. More...
 
class  avir::CImageResizerFilterStep< fptype, fptypeatom >
 Image resizer's filtering step class. More...
 
class  avir::CImageResizerFilterStepINL< fptype, fptypeatom >
 Interleaved filtering steps implementation class. More...
 
struct  avir::CImageResizerParams
 Resizing algorithm parameters structure. More...
 
struct  avir::CImageResizerParamsDef
 The default set of resizing algorithm parameters (10.06/1.88/1.029(256064.90)/0.000039). More...
 
struct  avir::CImageResizerParamsHigh
 Set of resizing algorithm parameters for low-aliasing resizing (11.59/1.84/1.015(73054.59)/0.000159). More...
 
struct  avir::CImageResizerParamsLow
 Set of resizing algorithm parameters for lower-ringing performance (9.21/1.91/1.040(391960.71)/0.000023). More...
 
struct  avir::CImageResizerParamsLR
 Set of resizing algorithm parameters for low-ringing performance (7.91/1.96/1.065(1980857.66)/0.000004). More...
 
struct  avir::CImageResizerParamsULR
 Set of resizing algorithm parameters for ultra-low-ringing performance (7.50/2.01/1.083(11568559.86)/0.000001). More...
 
struct  avir::CImageResizerParamsUltra
 Set of resizing algorithm parameters for ultra low-aliasing resizing (13.68/1.79/1.000(521792.07)/0.000026). More...
 
class  avir::CImageResizerThreadPool
 Thread pool for multi-threaded image resizing operation. More...
 
class  avir::CImageResizerVars
 Image resizing variables class. More...
 
struct  avir::CImageResizerFilterStep< fptype, fptypeatom >::CResizePos
 Resizing position structure. More...
 
class  avir::CImageResizerFilterStep< fptype, fptypeatom >::CRPosBuf
 Resizing positions buffer class. More...
 
class  avir::CImageResizerFilterStep< fptype, fptypeatom >::CRPosBufArray
 Resizing positions buffer array class. More...
 
class  avir::CSineGen
 Sine signal generator class. More...
 
class  avir::CStructArray< T >
 Array of structured objects. More...
 
class  avir::CImageResizerThreadPool::CWorkload
 Thread pool's workload object class. More...
 
class  avir::fpclass_def< afptype, afptypeatom, adith >
 Floating-point processing definition and abstraction class. More...
 

Macros

#define AVIR_NOCTOR(ClassName)
 
#define AVIR_PI   3.1415926535897932
 
#define AVIR_PId2   1.5707963267948966
 
#define AVIR_RESIZE_PART1
 
#define AVIR_RESIZE_PART1
 
#define AVIR_RESIZE_PART1nx
 
#define AVIR_RESIZE_PART1nx
 
#define AVIR_RESIZE_PART2
 
#define AVIR_RESIZE_PART2
 
#define AVIR_VERSION   "3.0"
 

Functions

template<class T1, class T2>
void avir::addArray (const T1 *ip, T2 *op, int l, const int ipinc=1, const int opinc=1)
 
template<class T>
void avir::calcFIRFilterResponse (const T *flt, int fltlen, const double th, double &re0, double &im0, const int fltlat=0)
 
template<class T>
avir::clamp (const T &Value, const T minv, const T maxv)
 
template<class T>
avir::convertLin2SRGB (const T s)
 
template<class T>
avir::convertSRGB2Lin (const T s)
 
template<class T1, class T2>
void avir::copyArray (const T1 *ip, T2 *op, int l, const int ipinc=1, const int opinc=1)
 
template<class T>
void avir::normalizeFIRFilter (T *const p, const int l, const double DCGain, const int pstep=1)
 
template<class T>
avir::pow24_sRGB (const T x)
 
template<class T>
avir::pow24i_sRGB (const T x)
 
template<class T1, class T2>
void avir::replicateArray (const T1 *const ip, const int ipl, T2 *op, int l, const int opinc)
 
template<class T>
avir::round (const T d)
 

Detailed Description

The "main" inclusion file with all required classes and functions.

This is the "main" inclusion file for the "AVIR" image resizer. This inclusion file contains implementation of the AVIR image resizing algorithm in its entirety. Also includes several classes and functions that can be useful elsewhere.

AVIR Copyright (c) 2015-2021 Aleksey Vaneev

Macro Definition Documentation

◆ AVIR_NOCTOR

#define AVIR_NOCTOR ( ClassName)
Value:
private: \
ClassName( const ClassName& ) { } \
ClassName& operator = ( const ClassName& ) { return( *this ); }

A special macro that defines empty copy-constructor and copy operator with the "private:" prefix. This macro should be used in classes that cannot be copied in a standard C++ way.

◆ AVIR_PI

#define AVIR_PI   3.1415926535897932

The macro equals to "pi" constant, fills 53-bit floating point mantissa. Undefined at the end of file.

◆ AVIR_PId2

#define AVIR_PId2   1.5707963267948966

The macro equals to "pi divided by 2" constant, fills 53-bit floating point mantissa. Undefined at the end of file.

◆ AVIR_RESIZE_PART1 [1/2]

#define AVIR_RESIZE_PART1
Value:
while( rpos < rpose ) \
{ \
const fptype x = (fptype) rpos -> x; \
const fptype* const ftp = rpos -> ftp; \
const fptype* const ftp2 = ftp + IntFltLen; \
const fptype* Src = SrcLine + rpos -> SrcOffs; \
int i;

◆ AVIR_RESIZE_PART1 [2/2]

#define AVIR_RESIZE_PART1
Value:
while( rpos < rpose ) \
{ \
const fptype x = (fptype) rpos -> x; \
const fptype* const ftp = rpos -> ftp; \
const fptype* const ftp2 = ftp + IntFltLen0; \
const fptype* Src = SrcLine + rpos -> SrcOffs; \
const int IntFltLen = rpos -> fl; \
int i;

◆ AVIR_RESIZE_PART1nx [1/2]

#define AVIR_RESIZE_PART1nx
Value:
while( rpos < rpose ) \
{ \
const fptype* const ftp = rpos -> ftp; \
const fptype* Src = SrcLine + rpos -> SrcOffs; \
int i;

◆ AVIR_RESIZE_PART1nx [2/2]

#define AVIR_RESIZE_PART1nx
Value:
while( rpos < rpose ) \
{ \
const fptype* const ftp = rpos -> ftp; \
const fptype* Src = SrcLine + rpos -> SrcOffs; \
const int IntFltLen = rpos -> fl; \
int i;

◆ AVIR_RESIZE_PART2 [1/2]

#define AVIR_RESIZE_PART2
Value:
DstLine += DstLineIncr; \
rpos++; \
}

◆ AVIR_RESIZE_PART2 [2/2]

#define AVIR_RESIZE_PART2
Value:
DstLine += DstLineIncr; \
rpos++; \
}

◆ AVIR_VERSION

#define AVIR_VERSION   "3.0"

The macro defines AVIR version string.

Function Documentation

◆ addArray()

template<class T1, class T2>
void avir::addArray ( const T1 * ip,
T2 * op,
int l,
const int ipinc = 1,
const int opinc = 1 )

Function adds values located in array "ip" to array "op".

Parameters
ipInput buffer.
[out]opOutput buffer.
lThe number of elements to add.
ipInput buffer pointer increment.
opOutput buffer pointer increment.

◆ calcFIRFilterResponse()

template<class T>
void avir::calcFIRFilterResponse ( const T * flt,
int fltlen,
const double th,
double & re0,
double & im0,
const int fltlat = 0 )

Function calculates frequency response of the specified FIR filter at the specified circular frequency. Phase can be calculated as atan2( im, re ). Function uses computationally-efficient oscillators instead of "cos" and "sin" functions.

Parameters
fltFIR filter's coefficients.
fltlenNumber of coefficients (taps) in the filter.
thCircular frequency [0; pi].
[out]re0Resulting real part of the complex frequency response.
[out]im0Resulting imaginary part of the complex frequency response.
fltlatFilter's latency in samples (taps).

◆ clamp()

template<class T>
T avir::clamp ( const T & Value,
const T minv,
const T maxv )

Template function "clamps" (clips) the specified value so that it is not lesser than "minv", and not greater than "maxv".

Parameters
ValueValue to clamp.
minvMinimal allowed value.
maxvMaximal allowed value.
Returns
The clamped value.

◆ convertLin2SRGB()

template<class T>
T avir::convertLin2SRGB ( const T s)

Function approximately de-linearizes the linear gamma value.

Parameters
sLinear gamma value, in the range 0 to 1.
Returns
sRGB gamma value, approximated.

◆ convertSRGB2Lin()

template<class T>
T avir::convertSRGB2Lin ( const T s)

Function approximately linearizes the sRGB gamma value.

Parameters
ssRGB gamma value, in the range 0 to 1.
Returns
Linearized sRGB gamma value, approximated.

◆ copyArray()

template<class T1, class T2>
void avir::copyArray ( const T1 * ip,
T2 * op,
int l,
const int ipinc = 1,
const int opinc = 1 )

Function converts (via typecast) specified array of type T1 values of length l into array of type T2 values. If T1 is the same as T2, copy operation is performed. When copying data at overlapping address spaces, "op" should be lower than "ip".

Parameters
ipInput buffer.
[out]opOutput buffer.
lThe number of elements to copy.
ipInput buffer pointer increment.
opOutput buffer pointer increment.

◆ normalizeFIRFilter()

template<class T>
void avir::normalizeFIRFilter ( T *const p,
const int l,
const double DCGain,
const int pstep = 1 )

Function normalizes FIR filter so that its frequency response at DC is equal to DCGain.

Parameters
[in,out]pFilter coefficients.
lFilter length.
DCGainFilter's gain at DC.
pstep"p" array step.

◆ pow24_sRGB()

template<class T>
T avir::pow24_sRGB ( const T x)

Power 2.4 approximation function, designed for sRGB gamma correction.

Parameters
xArgument, in the range 0.09 to 1.
Returns
Value raised into power 2.4, approximate.

◆ pow24i_sRGB()

template<class T>
T avir::pow24i_sRGB ( const T x)

Power 1/2.4 approximation function, designed for sRGB gamma correction.

Parameters
xArgument, in the range 0.003 to 1.
Returns
Value raised into power 1/2.4, approximate.

◆ replicateArray()

template<class T1, class T2>
void avir::replicateArray ( const T1 *const ip,
const int ipl,
T2 * op,
int l,
const int opinc )

Function that replicates a set of adjacent elements several times in a row. This operation is usually used to replicate pixels at the start or end of image's scanline.

Parameters
ipSource array.
iplSource array length (usually 1..4, but can be any number).
[out]opDestination buffer.
lNumber of times the source array should be replicated (the destination buffer should be able to hold ipl * l number of elements).
opincDestination buffer position increment after replicating the source array. This value should be equal to at least ipl.

◆ round()

template<class T>
T avir::round ( const T d)

Rounding function, based on the (int) typecast. Biased result. Not suitable for numbers >= 2^31.

Parameters
dValue to round.
Returns
Rounded value. Some bias may be introduced.