28 template<
class fptype,
class fptypesimd >
67 const int ElCount =
Vars -> ElCount;
70 if( !
Vars -> UseSRGBGamma )
72 for( j = 0; j < ElCount; j++ )
74 const Tin* ip = ip0 + j;
75 fptype*
const op = op0 + j *
InElIncr;
78 for( i = 0; i < l; i++ )
80 op[ i ] = (fptype) *ip;
87 const fptype gm = (fptype)
Vars -> InGammaMult;
89 for( j = 0; j < ElCount; j++ )
91 const Tin* ip = ip0 + j;
92 fptype*
const op = op0 + j *
InElIncr;
95 for( i = 0; i < l; i++ )
97 op[ i ] = convertSRGB2Lin( (fptype) *ip * gm );
116 const int ElCount = Vars0.
ElCount;
120 for( j = 0; j < ElCount; j++ )
122 fptype*
const p = p0 + j * l;
125 for( i = 0; i < l; i++ )
127 p[ i ] = convertLin2SRGB( p[ i ]) * gm;
149 const int SrcIncr )
const
151 const int ElCount =
Vars -> ElCount;
152 const int SrcElIncr = SrcIncr / ElCount;
153 const int ips1 = SrcElIncr;
154 const int ips2 = SrcElIncr * 2;
155 const int ips3 = SrcElIncr * 3;
163 for( j = 0; j < SrcLen; j++ )
173 for( j = 0; j < SrcLen; j++ )
176 op[ ops1 ] = ip[ ips1 ];
177 op[ ops2 ] = ip[ ips2 ];
178 op[ ops3 ] = ip[ ips3 ];
186 for( j = 0; j < SrcLen; j++ )
189 op[ ops1 ] = ip[ ips1 ];
190 op[ ops2 ] = ip[ ips2 ];
198 for( j = 0; j < SrcLen; j++ )
201 op[ ops1 ] = ip[ ips1 ];
222 template<
class Tout >
226 const int ElCount = Vars0.
ElCount;
229 for( j = 0; j < ElCount; j++ )
231 const fptype*
const ip = ip0 + j * l;
235 for( i = 0; i < l; i++ )
237 *op = (Tout) ip[ i ];
253 fptype*
const ElBiases )
const
255 const int ElCount =
Vars -> ElCount;
258 for( j = 0; j < ElCount; j++ )
260 const fptype*
const p = p0 + j *
InElIncr;
261 fptype b = (fptype) 0;
264 for( i = 0; i < SrcLen; i++ )
269 ElBiases[ j ] = b / (fptype) SrcLen;
283 const fptype*
const ElBiases )
const
285 const int ElCount =
Vars -> ElCount;
288 for( j = 0; j < ElCount; j++ )
290 fptype*
const p = p0 + j *
InElIncr;
291 const fptype b = ElBiases[ j ];
294 for( i = 0; i < l; i++ )
319 for( j = 0; j <
Vars -> ElCount; j++ )
322 fptype*
const Src2 = Src +
InLen - 1;
323 replicateArray( Src2, 1, Src2 + 1,
InSuffix, 1 );
338 const int elalign =
Vars -> elalign;
340 const fptype*
const f =
Flt;
346 for( j = 0; j <
Vars -> ElCount; j++ )
348 const fptype* ip = Src;
392 fptypesimd ipv = (fptypesimd) ip[ 0 ];
396 for( i = 0; i < flen; i += elalign )
398 fptypesimd :: addu( op0 + i,
399 fptypesimd :: load( f + i ) * ipv );
410 ipv = (fptypesimd) ip[ 0 ];
412 for( i = 0; i < flen; i += elalign )
414 fptypesimd :: addu( op0 + i,
415 fptypesimd :: load( f + i ) * ipv );
424 ipv = (fptypesimd) ip[ 0 ];
428 for( i = 0; i < flen; i += elalign )
430 fptypesimd :: addu( op0 + i,
431 fptypesimd :: load( f + i ) * ipv );
441 for( i = 0; i < l; i += elalign )
443 fptypesimd :: addu( op0 + i,
444 fptypesimd :: load( dc + i ) * ipv );
447 ipv = (fptypesimd) Src[ 0 ];
452 for( i = 0; i < l; i += elalign )
454 fptypesimd :: addu( op0 + i,
455 fptypesimd :: load( dc + i ) * ipv );
474 void doFilter(
const fptype*
const Src, fptype* Dst,
475 const int DstIncr )
const
477 const int ElCount =
Vars -> ElCount;
478 const int elalign =
Vars -> elalign;
479 const fptype*
const f = &
Flt[ 0 ];
493 fptypesimd s = fptypesimd :: load( f ) *
494 fptypesimd :: loadu( ip );
496 for( i = elalign; i < flen; i += elalign )
498 s += fptypesimd :: load( f + i ) *
499 fptypesimd :: loadu( ip + i );
511 for( j = 0; j < ElCount; j++ )
521 fptypesimd s = fptypesimd :: load( f ) *
522 fptypesimd :: loadu( ip );
524 for( i = elalign; i < flen; i += elalign )
526 s += fptypesimd :: load( f + i ) *
527 fptypesimd :: loadu( ip + i );
545 const fptype* ip = ip0;
548 for( j = 0; j < ElCount; j++ )
550 fptypesimd s = fptypesimd :: load( f ) *
551 fptypesimd :: loadu( ip );
553 for( i = elalign; i < flen; i += elalign )
555 s += fptypesimd :: load( f + i ) *
556 fptypesimd :: loadu( ip + i );
588 void doResize(
const fptype* SrcLine, fptype* DstLine,
589 int DstLineIncr,
const fptype*
const ElBiases,
590 fptype*
const xx )
const
592 const int IntFltLen =
FltBank -> getFilterLen();
593 const int ElCount =
Vars -> ElCount;
594 const int elalign =
Vars -> elalign;
596 CResizePos* rpos = &(*RPosBuf)[ 0 ];
602 #define AVIR_RESIZE_PART1 \
603 while( DstLineLen > 0 ) \
605 const fptypesimd x = (fptypesimd) rpos -> x; \
606 const fptype* ftp = rpos -> ftp; \
607 const fptype* ftp2 = rpos -> ftp + IntFltLen; \
608 const fptype* Src = SrcLine + rpos -> SrcOffs;
610 #define AVIR_RESIZE_PART1nx \
611 while( DstLineLen > 0 ) \
613 const fptype* ftp = rpos -> ftp; \
614 const fptype* Src = SrcLine + rpos -> SrcOffs;
616 #define AVIR_RESIZE_PART2 \
617 DstLine += DstLineIncr; \
624 const fptype b = ElBiases[ 0 ];
626 if(
FltBank -> getOrder() == 1 )
630 fptypesimd sum = ( fptypesimd :: load( ftp ) +
631 fptypesimd :: load( ftp2 ) * x ) *
632 fptypesimd :: loadu( Src );
634 for( i = elalign; i < IntFltLen; i += elalign )
636 sum += ( fptypesimd :: load( ftp + i ) +
637 fptypesimd :: load( ftp2 + i ) * x ) *
638 fptypesimd :: loadu( Src + i );
641 DstLine[ 0 ] = sum.hadd() + b;
649 fptypesimd sum = fptypesimd :: load( ftp ) *
650 fptypesimd :: loadu( Src );
652 for( i = elalign; i < IntFltLen; i += elalign )
654 sum += fptypesimd :: load( ftp + i ) *
655 fptypesimd :: loadu( Src + i );
658 DstLine[ 0 ] = sum.hadd() + b;
664 if( DstLineIncr == 1 )
669 const int DstLineElIncr =
OutElIncr - DstLineIncr * DstLineLen;
671 if(
FltBank -> getOrder() == 1 )
673 for( j = 0; j < ElCount; j++ )
675 const fptype b = ElBiases[ j ];
679 fptypesimd sum = 0.0;
681 for( i = 0; i < IntFltLen; i += elalign )
683 sum += ( fptypesimd :: load( ftp + i ) +
684 fptypesimd :: load( ftp2 + i ) * x ) *
685 fptypesimd :: loadu( Src + i );
688 DstLine[ 0 ] = sum.hadd() + b;
692 DstLine += DstLineElIncr;
695 rpos = &(*RPosBuf)[ 0 ];
700 for( j = 0; j < ElCount; j++ )
702 const fptype b = ElBiases[ j ];
706 fptypesimd sum = fptypesimd :: load( ftp ) *
707 fptypesimd :: loadu( Src );
709 for( i = elalign; i < IntFltLen; i += elalign )
711 sum += fptypesimd :: load( ftp + i ) *
712 fptypesimd :: loadu( Src + i );
715 DstLine[ 0 ] = sum.hadd() + b;
719 DstLine += DstLineElIncr;
722 rpos = &(*RPosBuf)[ 0 ];
730 DstLineIncr -= DstLineElIncr * ElCount;
732 if(
FltBank -> getOrder() == 1 )
736 for( i = 0; i < IntFltLen; i += elalign )
738 ( fptypesimd :: load( ftp + i ) +
739 fptypesimd :: load( ftp2 + i ) * x ).store( xx + i );
742 for( j = 0; j < ElCount; j++ )
744 fptypesimd sum = fptypesimd :: load( xx ) *
745 fptypesimd :: loadu( Src );
747 for( i = elalign; i < IntFltLen; i += elalign )
749 sum += fptypesimd :: load( xx + i ) *
750 fptypesimd :: loadu( Src + i );
753 DstLine[ 0 ] = sum.hadd() + ElBiases[ j ];
754 DstLine += DstLineElIncr;
764 for( j = 0; j < ElCount; j++ )
766 fptypesimd sum = fptypesimd :: load( ftp ) *
767 fptypesimd :: loadu( Src );
769 for( i = elalign; i < IntFltLen; i += elalign )
771 sum += fptypesimd :: load( ftp + i ) *
772 fptypesimd :: loadu( Src + i );
775 DstLine[ 0 ] = sum.hadd() + ElBiases[ j ];
776 DstLine += DstLineElIncr;
784 #undef AVIR_RESIZE_PART2
785 #undef AVIR_RESIZE_PART1nx
786 #undef AVIR_RESIZE_PART1
795 int DstLineIncr,
const fptype*
const ElBiases,
796 fptype*
const xx )
const
798 doResize( SrcLine, DstLine, DstLineIncr, ElBiases, xx );
816 template<
class fptype,
class fptypesimd >
831 const double aTrMul,
const double aPkOut )
856 void dither( fptype*
const ResScanline )
const
858 const int elalign =
Vars -> elalign;
859 const fptypesimd c0 = 0.0;
860 const fptypesimd PkOut = (fptypesimd)
PkOut0;
867 for( j = 0; j <
LenE - elalign; j += elalign )
869 const fptypesimd z0 = round(
870 fptypesimd :: loadu( ResScanline + j ));
872 clamp( z0, c0, PkOut ).storeu( ResScanline + j );
875 const int lim =
LenE - j;
876 const fptypesimd z0 = round(
877 fptypesimd :: loadu( ResScanline + j, lim ));
879 clamp( z0, c0, PkOut ).storeu( ResScanline + j, lim );
883 const fptypesimd TrMul = (fptypesimd)
TrMul0;
885 for( j = 0; j <
LenE - elalign; j += elalign )
887 const fptypesimd z0 = round(
888 fptypesimd :: loadu( ResScanline + j ) / TrMul ) * TrMul;
890 clamp( z0, c0, PkOut ).storeu( ResScanline + j );
893 const int lim =
LenE - j;
894 const fptypesimd z0 = round(
895 fptypesimd :: loadu( ResScanline + j, lim ) / TrMul ) * TrMul;
897 clamp( z0, c0, PkOut ).storeu( ResScanline + j, lim );
926 template<
class fptype,
class fptypesimd >
941 const double aTrMul,
const double aPkOut )
953 for( i = 0; i <
LenE +
Vars -> ElCount; i++ )
959 static bool isRecursive()
964 void dither( fptype*
const ResScanline )
966 const int ea =
Vars -> elalign;
967 const fptypesimd c0 = 0.0;
968 const fptypesimd TrMul = (fptypesimd)
TrMul0;
969 const fptypesimd PkOut = (fptypesimd)
PkOut0;
972 for( j = 0; j <
LenE - ea; j += ea )
974 fptypesimd :: addu( ResScanline + j,
981 fptypesimd :: addu( ResScanline + j,
986 const int Len1 =
Len - 1;
987 fptype* rs = ResScanline;
991 for( i = 0; i <
Vars -> ElCount; i++ )
993 for( j = 0; j < Len1; j++ )
997 fptype*
const rsj = rs + j;
998 const fptype z0 = round( rsj[ 0 ] / TrMul ) * TrMul;
999 const fptype Noise = rsj[ 0 ] - z0;
1000 rsj[ 0 ] = clamp( z0, (fptype) 0.0, PkOut );
1002 fptype*
const rsdj = rsd + j;
1003 rsj[ 1 ] += Noise * (fptype) 0.364842;
1004 rsdj[ -1 ] += Noise * (fptype) 0.207305;
1005 rsdj[ 0 ] += Noise * (fptype) 0.364842;
1006 rsdj[ 1 ] += Noise * (fptype) 0.063011;
1011 const fptype z1 = round( rs[ Len1 ] / TrMul ) * TrMul;
1012 const fptype Noise2 = rs[ Len1 ] - z1;
1013 rs[ Len1 ] = clamp( z1, c0, PkOut );
1015 rsd[ Len1 - 1 ] += Noise2 * (fptype) 0.207305;
1016 rsd[ Len1 ] += Noise2 * (fptype) 0.364842;
1056 template<
class afptype,
class afptypesimd,
1064 static const int fppack = 1;
1066 static const int fpalign =
sizeof( afptypesimd );
1069 static const int elalign =
sizeof( afptypesimd ) /
sizeof( afptype );
Image resizer's error-diffusion dithering class, de-interleaved mode.
Definition: avir_dil.h:927
double OutGammaMult
Definition: avir.h:2392
static void applySRGBGamma(fptype *const p0, const int l, const CImageResizerVars &Vars0)
Definition: avir_dil.h:113
CBuffer< fptype > Flt
Definition: avir.h:2460
double TrMul0
Definition: avir_dil.h:908
int LenE
Definition: avir_dil.h:906
void convertVtoH(const fptype *ip, fptype *op, const int SrcLen, const int SrcIncr) const
Definition: avir_dil.h:148
int EdgePixelCount
Definition: avir.h:2520
bool IsUpsample
Definition: avir.h:2453
afptype fptypeatom
Definition: avir_dil.h:1063
Image resizing variables class.
Definition: avir.h:2349
int LenE
Definition: avir_dil.h:1028
void dither(fptype *const ResScanline) const
Definition: avir_dil.h:856
int OutSuffix
Definition: avir.h:2504
static void unpackScanline(const fptype *const ip0, Tout *const op0, const int l, const CImageResizerVars &Vars0)
Definition: avir_dil.h:223
void init(const int aLen, const CImageResizerVars &aVars, const double aTrMul, const double aPkOut)
Definition: avir_dil.h:830
int InElIncr
Definition: avir.h:2492
int FltLatency
Definition: avir.h:2472
adith CDitherer
Definition: avir_dil.h:1086
int Len
Definition: avir_dil.h:1024
static bool isRecursive()
Definition: avir_dil.h:845
static const int packmode
Definition: avir_dil.h:1080
static const int elalign
Definition: avir_dil.h:1074
const CImageResizerVars * Vars
Definition: avir.h:2474
Floating-point processing definition and abstraction class for de-interleaved processing.
Definition: avir_dil.h:1058
const CImageResizerVars * Vars
Definition: avir_dil.h:1026
void prepareInBuf(fptype *Src) const
Definition: avir_dil.h:310
void unbiasScanline(fptype *const p0, const int l, const fptype *const ElBiases) const
Definition: avir_dil.h:282
void doUpsample(const fptype *Src, fptype *Dst) const
Definition: avir_dil.h:336
CBuffer< fptype > PrefixDC
Definition: avir.h:2512
Image resizer's filtering step class.
Definition: avir.h:2448
int ResampleFactor
Definition: avir.h:2457
static const int fpalign
Definition: avir_dil.h:1068
CBuffer< fptype > ResScanlineDith0
Definition: avir_dil.h:1034
int ElCount
Definition: avir.h:2352
int OutPrefix
Definition: avir.h:2500
void init(const int aLen, const CImageResizerVars &aVars, const double aTrMul, const double aPkOut)
Definition: avir_dil.h:940
fptype * ResScanlineDith
Definition: avir_dil.h:1037
CDSPFracFilterBankLin< fptype > * FltBank
Definition: avir.h:2626
void packScanline(const Tin *const ip0, fptype *const op0, const int l) const
Definition: avir_dil.h:64
const CImageResizerVars * Vars
Definition: avir_dil.h:904
int Len
Definition: avir_dil.h:902
void doResize2(const fptype *SrcLine, fptype *DstLine, int DstLineIncr, const fptype *const ElBiases, fptype *const xx) const
Definition: avir_dil.h:794
int InSuffix
Definition: avir.h:2486
De-interleaved filtering steps implementation class.
Definition: avir_dil.h:29
int InPrefix
Definition: avir.h:2480
int OutLen
Definition: avir.h:2496
afptype fptype
Definition: avir_dil.h:1061
Image resizer's default de-interleaved dithering class.
Definition: avir_dil.h:817
void calcScanlineBias(const fptype *const p0, const int SrcLen, fptype *const ElBiases) const
Definition: avir_dil.h:252
double PkOut0
Definition: avir_dil.h:1032
CImageResizerFilterStepDIL< fptype, afptypesimd > CFilterStep
Definition: avir_dil.h:1083
int OutElIncr
Definition: avir.h:2508
static const int fppack
Definition: avir_dil.h:1065
void alloc(const capint aCapacity, const int aAlignment=0)
Definition: avir.h:522
CRPosBuf * RPosBuf
Definition: avir.h:2623
int InLen
Definition: avir.h:2476
double TrMul0
Definition: avir_dil.h:1030
CBuffer< fptype > SuffixDC
Definition: avir.h:2516
void doResize(const fptype *SrcLine, fptype *DstLine, int DstLineIncr, const fptype *const ElBiases, fptype *const xx) const
Definition: avir_dil.h:588
void doFilter(const fptype *const Src, fptype *Dst, const int DstIncr) const
Definition: avir_dil.h:474
double PkOut0
Definition: avir_dil.h:910
CFltBuffer FltOrig
Definition: avir.h:2462
capint getCapacity() const
Definition: avir.h:545