JD2022-TU1/main/extern/Camcam/CCMap/MAP16.cpp

2013 lines
46 KiB
C++

#ifndef MAP16_METACALL
#include "windows.h"
#include "CCMap.h"
#include "memory.h"
#include "math.h"
#include "ccmath.h"
#define MAPTYPE MAP16
#define PIXELMAPTYPE s16
#define MAPTYPECALL(a) MAP16##a
#define MAPTYPECALLEnd(a) a##MAP16
#define MAPBits 16
#else
#undef MAPTYPE
#undef PIXELMAPTYPE
#undef MAPTYPECALL
#undef MAPTYPECALLEnd
#undef MAPBits
#define MAPTYPE MAP
#define PIXELMAPTYPE s32
#define MAPTYPECALL(a) MAP32##a
#define MAPTYPECALLEnd(a) a##MAP32
#define MAPBits 32
#endif
// #include <omp.h>
void MAP16_CopySqr8(MAP8 *pSrc,MAPTYPE *pDst);
void MAP16_BLUR_H_Inplace(MAPTYPE *pSrc,u32 Rpo2);
void MAP16_BLUR_V_Inplace(MAPTYPE *pSrc,u32 Rpo2);
void SET_BORDER16(MAPTYPE *MapSRC,s32 Size,PIXELMAPTYPE Value)
{
PIXELMAPTYPE *SRC,*LAST;
SRC = MapSRC->GetBase();
for (u32 SizeY = 0; SizeY < MapSRC->SY;SizeY ++)
{
if ((SizeY < Size) || (SizeY > MapSRC->SY - Size))
{
LAST = SRC + MapSRC->SX;
while (SRC < LAST) *(SRC++) = Value;
SRC+=MapSRC->PITCH-MapSRC->SX;
} else
{
LAST = SRC + Size;
while (SRC < LAST) *(SRC++) = Value;
SRC += MapSRC->SX - Size * 2;
LAST = SRC + Size;
while (SRC < LAST) *(SRC++) = Value;
SRC+=MapSRC->PITCH-MapSRC->SX;
}
}
}
void MAPTYPECALL(_Copy)(/*IN*/MAPTYPE *pSrc,MAPTYPE *pDst)
{
PIXELMAPTYPE *PPs;
PIXELMAPTYPE *PPd,*PPl,*PPll,*PPDeriv;
/* 1 Compute 16b */
PPs = pSrc->GetBase();
PPd = pDst->GetBase();
PPl = pDst->GetBase() + pDst->PITCH * pDst->SY;
while (PPd < PPl)
{
PPll = PPd + pDst->SX;
while (PPd < PPll)
{
*PPd = *PPs;
PPd ++;
PPs ++;
}
PPs += pSrc->PITCH - pSrc->SX;
PPd += pDst->PITCH - pDst->SX;
}
}
void MAPTYPECALL(_Set)(MAPTYPE *MapSRC,PIXELMAPTYPE Value)
{
PIXELMAPTYPE *SRC,*LAST;
SRC = MapSRC->GetBase();
for (u32 SizeY = 0; SizeY < MapSRC->SY;SizeY ++)
{
LAST = SRC + MapSRC->SX;
while (SRC < LAST) *(SRC++) = Value;
SRC+=MapSRC->PITCH-MapSRC->SX;
}
}
void MAPTYPECALL(_Denoise_FAST)(MAPTYPE *pSrc,MAPTYPE *pDst)
{
PIXELMAPTYPE *PPs;
PIXELMAPTYPE *PPd,*PPl,*PPll,*PPDeriv;
/* 1 Compute 16b */
PPs = pSrc->GetBase() + pSrc->PITCH;
PPd = pDst->GetBase() + pDst->PITCH;
PPl = pDst->GetBase() + pDst->PITCH * (pDst->SY - 1);
while (PPd < PPl)
{
PPll = PPd + pDst->SX - 1;
PPd ++;
PPs ++;
while (PPd < PPll)
{
*PPd = (*(PPs + 1) + *(PPs - 1) + *(PPs + pSrc->PITCH) + *(PPs - pSrc->PITCH) +
*(PPs + 1 - pSrc->PITCH) + *(PPs - 1 - pSrc->PITCH) +
*(PPs + 1 + pSrc->PITCH) + *(PPs - 1 + pSrc->PITCH) ) >> 3;
PPd ++;
PPs ++;
}
PPs += 1 + pSrc->PITCH - pSrc->SX;
PPd += 1 + pDst->PITCH - pDst->SX;
}
}
void MAPTYPECALL(_SmallBlur_FAST)(MAPTYPE *pSrc,MAPTYPE *pDst)
{
PIXELMAPTYPE *PPs;
PIXELMAPTYPE *PPd,*PPl,*PPll,*PPDeriv;
/* 1 Compute 16b */
PPs = pSrc->GetBase() + pSrc->PITCH;
PPd = pDst->GetBase() + pDst->PITCH;
PPl = pDst->GetBase() + pDst->PITCH * (pDst->SY - 1);
while (PPd < PPl)
{
PPll = PPd + pDst->SX - 1;
PPd ++;
PPs ++;
while (PPd < PPll)
{
s32 LocalC = (*(PPs + 1) + *(PPs - 1) + *(PPs + pSrc->PITCH) + *(PPs - pSrc->PITCH));
s32 LocalD = (*(PPs + 1 + pSrc->PITCH) + *(PPs - 1 + pSrc->PITCH) + *(PPs + 1 - pSrc->PITCH) + *(PPs - 1 - pSrc->PITCH));
/* *PPd +=(*(PPs + 1 - pSrc->PITCH) + *(PPs - 1 - pSrc->PITCH) +
*(PPs + 1 + pSrc->PITCH) + *(PPs - 1 + pSrc->PITCH) );
*PPd += *(PPs)<<3;*/
*PPd = (((LocalC*1) + LocalD*0)/1)>>2;
PPd ++;
PPs ++;
}
PPs += 1 + pSrc->PITCH - pSrc->SX;
PPd += 1 + pDst->PITCH - pDst->SX;
}
}
void MAPTYPECALL(_CopyUnAlias)(MAPTYPE *pSrc,MAPTYPE *pDst)
{
for (int Y = 0; Y < pDst->SY ; Y+=2)
for (int X = 0; X < pDst->SX ; X+=2)
{
pDst->GetBase()[(X>>1)+(Y>>1)*pDst->PITCH] = pSrc->GetBase()[X+Y*pDst->PITCH];
pDst->GetBase()[(X>>1)+(pDst->SX>>1)+(Y>>1)*pDst->PITCH] = pSrc->GetBase()[(X+1)+Y*pDst->PITCH];
pDst->GetBase()[(X>>1)+(pDst->SX>>1)+((pDst->SY>>1)+(Y>>1))*pDst->PITCH] = pSrc->GetBase()[(X+1)+(Y+1)*pDst->PITCH];
pDst->GetBase()[(X>>1)+((pDst->SY>>1)+(Y>>1))*pDst->PITCH] = pSrc->GetBase()[X+(Y+1)*pDst->PITCH];
}
}
void MAPTYPECALL(_CopyReAlias)(MAPTYPE *pSrc,MAPTYPE *pDst)
{
for (int Y = 0; Y < pDst->SY ; Y+=2)
for (int X = 0; X < pDst->SX ; X+=2)
{
pDst->GetBase()[X+Y*pDst->PITCH] = pSrc->GetBase()[(X>>1)+(Y>>1)*pSrc->PITCH];
pDst->GetBase()[(X+1)+Y*pDst->PITCH] = pSrc->GetBase()[(X>>1)+(pSrc->SX>>1)+(Y>>1)*pSrc->PITCH];
pDst->GetBase()[(X+1)+(Y+1)*pDst->PITCH] = pSrc->GetBase()[(X>>1)+(pSrc->SX>>1)+((pSrc->SY>>1)+(Y>>1))*pSrc->PITCH];
pDst->GetBase()[X+(Y+1)*pDst->PITCH] = pSrc->GetBase()[(X>>1)+((pSrc->SY>>1)+(Y>>1))*pSrc->PITCH];
}
}
void MAPTYPECALL(_CopySqr8)(MAP8 *pSrc,MAPTYPE *pDst)
{
// In place blur 8 bits horizontaly
PIXELMAPTYPE *PPd,*PPl,*PPdOfset;
u8 *ppSrc;
ppSrc = pSrc->GetBase();
PPd = pDst->GetBase();
PPl = pDst->GetBase() + pDst->PITCH * pDst->SY;
while (PPd < PPl)
{
*PPd = ((PIXELMAPTYPE)(*ppSrc)-128) * ((PIXELMAPTYPE)(*ppSrc)-128);
PPd ++;
ppSrc++;
}
}
void MAPTYPECALL(_Or)(MAPTYPE *pSrc,MAPTYPE *pDst)
{
// In place blur 8 bits horizontaly
PIXELMAPTYPE *PPd,*PPl,*PPdOfset;
PIXELMAPTYPE *ppSrc;
ppSrc = pSrc->GetBase();
PPd = pDst->GetBase();
PPl = pDst->GetBase() + pDst->PITCH * pDst->SY;
while (PPd < PPl)
{
*PPd |= *ppSrc;
PPd ++;
ppSrc++;
}
}
void MAPTYPECALL(_And)(MAPTYPE *pSrc,MAPTYPE *pDst)
{
// In place blur 8 bits horizontaly
PIXELMAPTYPE *PPd,*PPl,*PPdOfset;
PIXELMAPTYPE *ppSrc;
ppSrc = pSrc->GetBase();
PPd = pDst->GetBase();
PPl = pDst->GetBase() + pDst->PITCH * pDst->SY;
while (PPd < PPl)
{
*PPd &= *ppSrc;
PPd ++;
ppSrc++;
}
}
void MAPTYPECALL(_Add)(MAPTYPE *MapSRC,PIXELMAPTYPE Value)
{
PIXELMAPTYPE *SRC,*LAST;
SRC = MapSRC->GetBase();
for (u32 SizeY = 0; SizeY < MapSRC->SY;SizeY ++)
{
LAST = SRC + MapSRC->SX;
while (SRC < LAST) *(SRC++) += Value;
SRC+=MapSRC->PITCH-MapSRC->SX;
}
}
void MAPTYPECALL(_And)(MAPTYPE *MapSRC,PIXELMAPTYPE Value)
{
PIXELMAPTYPE *SRC,*LAST;
SRC = MapSRC->GetBase();
for (u32 SizeY = 0; SizeY < MapSRC->SY;SizeY ++)
{
LAST = SRC + MapSRC->SX;
while (SRC < LAST) *(SRC++) &= Value;
SRC+=MapSRC->PITCH-MapSRC->SX;
}
}
void MAPTYPECALL(_Or)(MAPTYPE *MapSRC,PIXELMAPTYPE Value)
{
PIXELMAPTYPE *SRC,*LAST;
SRC = MapSRC->GetBase();
for (u32 SizeY = 0; SizeY < MapSRC->SY;SizeY ++)
{
LAST = SRC + MapSRC->SX;
while (SRC < LAST) *(SRC++) |= Value;
SRC+=MapSRC->PITCH-MapSRC->SX;
}
}
void MAPTYPECALL(_Xor)(MAPTYPE *MapSRC,PIXELMAPTYPE Value)
{
PIXELMAPTYPE *SRC,*LAST;
SRC = MapSRC->GetBase();
for (u32 SizeY = 0; SizeY < MapSRC->SY;SizeY ++)
{
LAST = SRC + MapSRC->SX;
while (SRC < LAST) *(SRC++) ^= Value;
SRC+=MapSRC->PITCH-MapSRC->SX;
}
}
void MAPTYPECALL(_Abs)(MAPTYPE *MapSRC)
{
PIXELMAPTYPE *SRC,*LAST;
SRC = MapSRC->GetBase();
for (u32 SizeY = 0; SizeY < MapSRC->SY;SizeY ++)
{
LAST = SRC + MapSRC->SX;
while (SRC < LAST)
{
if (*(SRC)<0) *(SRC) = -*(SRC);
/*PIXELMAPTYPE Abs;
Abs = *(SRC) >> 15;
*(SRC) ^= Abs;
*(SRC) += Abs & 1;*/
SRC++;
}
SRC+=MapSRC->PITCH-MapSRC->SX;
}
}
void MAPTYPECALL(_OnlyAbs)(MAPTYPE *MapSRC)
{
PIXELMAPTYPE *SRC,*LAST;
SRC = MapSRC->GetBase();
for (u32 SizeY = 0; SizeY < MapSRC->SY;SizeY ++)
{
LAST = SRC + MapSRC->SX;
while (SRC < LAST)
{
PIXELMAPTYPE Abs;
/* Abs = *(SRC) >> 15;
Abs ^= 0xffff;
*(SRC) &= Abs;*/
if (*(SRC) < 0) *(SRC) = 0;
SRC++;
}
SRC+=MapSRC->PITCH-MapSRC->SX;
}
}
void MAPTYPECALL(_Neg)(MAPTYPE *MapSRC)
{
PIXELMAPTYPE *SRC,*LAST;
SRC = MapSRC->GetBase();
for (u32 SizeY = 0; SizeY < MapSRC->SY;SizeY ++)
{
LAST = SRC + MapSRC->SX;
while (SRC < LAST)
{
*(SRC) = -*(SRC);
SRC++;
}
SRC+=MapSRC->PITCH-MapSRC->SX;
}
}
void MAPTYPECALL(_Limit_UP)(MAPTYPE *MapSRC,PIXELMAPTYPE UpperValue)
{
PIXELMAPTYPE *SRC,*LAST;
SRC = MapSRC->GetBase();
for (u32 SizeY = 0; SizeY < MapSRC->SY;SizeY ++)
{
LAST = SRC + MapSRC->SX;
while (SRC < LAST)
{
PIXELMAPTYPE LV;
*(SRC) -= UpperValue;
LV = *(SRC) >> (MAPBits-1);
*(SRC) &= LV;
*(SRC++) += UpperValue;
}
SRC+=MapSRC->PITCH-MapSRC->SX;
}
}
void MAPTYPECALL(_Limit_Down)(MAPTYPE *MapSRC,PIXELMAPTYPE LowestValue)
{
PIXELMAPTYPE *SRC,*LAST;
SRC = MapSRC->GetBase();
for (u32 SizeY = 0; SizeY < MapSRC->SY;SizeY ++)
{
LAST = SRC + MapSRC->SX;
while (SRC < LAST)
{
PIXELMAPTYPE LV;
*(SRC) -= LowestValue;
LV = *(SRC) >> (MAPBits-1);
LV ^= -1;
*(SRC) &= LV;
*(SRC++) += LowestValue;
}
SRC+=MapSRC->PITCH-MapSRC->SX;
}
}
void MAPTYPECALL(_Limit_Inside)(MAPTYPE *MapSRC,PIXELMAPTYPE LowestValue)
{
PIXELMAPTYPE *SRC,*LAST;
SRC = MapSRC->GetBase();
for (u32 SizeY = 0; SizeY < MapSRC->SY;SizeY ++)
{
LAST = SRC + MapSRC->SX;
while (SRC < LAST)
{
PIXELMAPTYPE LV;
if (*(SRC) > 0)
{
if (*(SRC) < LowestValue) *(SRC) = 0;
} else
if (*(SRC) > -LowestValue) *(SRC) = 0;
*(SRC++);
}
SRC+=MapSRC->PITCH-MapSRC->SX;
}
}
void MAPTYPECALL(_Shift)(MAPTYPE *MapSRC,PIXELMAPTYPE Value)
{
PIXELMAPTYPE *SRC,*LAST;
SRC = MapSRC->GetBase();
if (Value > 0)
{
for (u32 SizeY = 0; SizeY < MapSRC->SY;SizeY ++)
{
LAST = SRC + MapSRC->SX;
while (SRC < LAST)
{
*(SRC) <<= Value;
*(SRC++);
}
SRC+=MapSRC->PITCH-MapSRC->SX;
}
}
else
{
Value = -Value;
for (u32 SizeY = 0; SizeY < MapSRC->SY;SizeY ++)
{
LAST = SRC + MapSRC->SX;
while (SRC < LAST)
{
*(SRC) >>= Value;
//if (*(SRC) == -1) *(SRC) = 0;
*(SRC++);
}
SRC+=MapSRC->PITCH-MapSRC->SX;
}
}
}
void MAPTYPECALL(_Mul)(MAPTYPE *MapSRC,MAPTYPE *MapDST)
{
PIXELMAPTYPE *SRC,*LAST,*DST;
DST = MapDST->GetBase();
SRC = MapSRC->GetBase();
for (u32 SizeY = 0; SizeY < MapDST->SY;SizeY ++)
{
LAST = DST + MapDST->SX;
while (DST < LAST) *(DST++) *= *(SRC++);
SRC+=MapSRC->PITCH-MapSRC->SX;
DST+=MapDST->PITCH-MapDST->SX;
}
}
void MAPTYPECALL(_Mul)(MAPTYPE *MapDST,s32 Mult,s32 Shift)
{
PIXELMAPTYPE *LAST,*DST;
DST = MapDST->GetBase();
for (u32 SizeY = 0; SizeY < MapDST->SY;SizeY ++)
{
LAST = DST + MapDST->SX;
while (DST < LAST) *(DST++) = ((s32)(*(DST)>>Shift) * Mult);
DST+=MapDST->PITCH-MapDST->SX;
}
}
void MAPTYPECALL(_MulNegOnly)(MAPTYPE *MapDST,s32 Mult,s32 Shift)
{
PIXELMAPTYPE *LAST,*DST;
DST = MapDST->GetBase();
for (u32 SizeY = 0; SizeY < MapDST->SY;SizeY ++)
{
LAST = DST + MapDST->SX;
while (DST < LAST)
{
if (*(DST) < 0)
*(DST) = ((s32)*(DST) * Mult)>>Shift;
*(DST++);
}
DST+=MapDST->PITCH-MapDST->SX;
}
}
void MAPTYPECALL(_Sqr)(MAPTYPE *MapSRC)
{
PIXELMAPTYPE *SRC,*LAST;
SRC = MapSRC->GetBase();
for (u32 SizeY = 0; SizeY < MapSRC->SY;SizeY ++)
{
LAST = SRC + MapSRC->SX;
while (SRC < LAST)
{
int Square;
Square = *(SRC) * *(SRC);
//if (Square > 32700) Square = 32700;
*(SRC++) = Square;
}
SRC+=MapSRC->PITCH-MapSRC->SX;
}
}
void MAPTYPECALL(_Sqrt)(MAPTYPE *MapSRC)
{
PIXELMAPTYPE *SRC,*LAST;
SRC = MapSRC->GetBase();
for (u32 SizeY = 0; SizeY < MapSRC->SY;SizeY ++)
{
LAST = SRC + MapSRC->SX;
while (SRC < LAST)
{
if (*(SRC))
{
if (*(SRC)>0)
*(SRC) = (PIXELMAPTYPE)FastSqrt((float)*(SRC));
else
*(SRC) = -(PIXELMAPTYPE)FastSqrt(-(float)*(SRC));
}
SRC++;
}
SRC+=MapSRC->PITCH-MapSRC->SX;
}
}
void MAPTYPECALL(_PseudoLog)(MAPTYPE *MapSRC)
{
PIXELMAPTYPE *SRC,*LAST;
SRC = MapSRC->GetBase();
for (u32 SizeY = 0; SizeY < MapSRC->SY;SizeY ++)
{
LAST = SRC + MapSRC->SX;
while (SRC < LAST)
{
float Conv;
if (*(SRC))
{
if (*(SRC) < 0)
{
Conv = (float)-*(SRC);
*(SRC) = -((PIXELMAPTYPE)((*(s32 *)&Conv) >> 16)-(64<<8));
} else
{
Conv = *(SRC);
*(SRC) = (PIXELMAPTYPE)((*(s32 *)&Conv) >> 16)-(64<<8);
}
}
SRC++;
}
SRC+=MapSRC->PITCH-MapSRC->SX;
}
}
void MAPTYPECALL(_Add)(MAPTYPE *pSrc,MAPTYPE *pDst)
{
// In place blur 8 bits horizontaly
PIXELMAPTYPE *PPd,*PPl,*PPdOfset;
PIXELMAPTYPE *ppSrc;
ppSrc = (PIXELMAPTYPE*)pSrc->GetBase();
PPd = pDst->GetBase();
PPl = pDst->GetBase() + pDst->PITCH * pDst->SY;
while (PPd < PPl)
{
*PPd += *ppSrc;
PPd ++;
ppSrc++;
}
}
float MAPTYPECALL(_DotProductNormalized)(MAPTYPE *pSrc,MAPTYPE *pDst)
{
float DP = 0.0f;
float SqrDst = 0;
float AveDst = 0;
// In place blur 8 bits horizontaly
PIXELMAPTYPE *PPd,*PPl,*PPdOfset;
PIXELMAPTYPE *ppSrc;
ppSrc = (PIXELMAPTYPE*)pSrc->GetBase();
PPd = pDst->GetBase();
PPl = pDst->GetBase() + pDst->PITCH * pDst->SY;
while (PPd < PPl)
{
AveDst += (float)*PPd;
SqrDst += (float)*PPd * (float)*PPd;
DP += (float)*PPd * (float)*ppSrc;
PPd ++;
ppSrc++;
}
SqrDst /= (float)pDst->PITCH * (float)pDst->SY;
AveDst /= (float)pDst->PITCH * (float)pDst->SY;
AveDst *= AveDst;
return DP / sqrt(SqrDst - AveDst);
}
float MAPTYPECALL(_DotProduct)(MAPTYPE *pSrc,MAPTYPE *pDst)
{
float DP = 0.0f;
// In place blur 8 bits horizontaly
PIXELMAPTYPE *PPd,*PPl,*PPdOfset;
PIXELMAPTYPE *ppSrc;
ppSrc = (PIXELMAPTYPE*)pSrc->GetBase();
PPd = pDst->GetBase();
PPl = pDst->GetBase() + pDst->PITCH * pDst->SY;
while (PPd < PPl)
{
DP += (float)*PPd * (float)*ppSrc;
PPd ++;
ppSrc++;
}
return DP;
}
void MAPTYPECALL(_MIN)(MAPTYPE *MapSRC,MAPTYPE *MapDST)
{
PIXELMAPTYPE *LAST,*DST,*SRC;
for (u32 SizeY = 1; SizeY < MapSRC->SY - 1;SizeY ++)
{
SRC = MapSRC->GetBase() + SizeY * MapSRC->PITCH + 1;
DST = MapDST->GetBase() + SizeY * MapDST->PITCH + 1;
LAST = SRC + MapSRC->SX - 1 * 2;
while (SRC < LAST)
{
*DST = *SRC;
if (*DST > *(SRC+1)) *DST = *(SRC+1);
if (*DST > *(SRC+1+MapSRC->PITCH)) *DST = *(SRC+1+MapSRC->PITCH);
if (*DST > *(SRC+1-MapSRC->PITCH)) *DST = *(SRC+1-MapSRC->PITCH);
if (*DST > *(SRC-1)) *DST = *(SRC-1);
if (*DST > *(SRC-1+MapSRC->PITCH)) *DST = *(SRC-1+MapSRC->PITCH);
if (*DST > *(SRC-1-MapSRC->PITCH)) *DST = *(SRC-1-MapSRC->PITCH);
if (*DST > *(SRC+MapSRC->PITCH)) *DST = *(SRC+MapSRC->PITCH);
if (*DST > *(SRC-MapSRC->PITCH)) *DST = *(SRC-MapSRC->PITCH);
SRC++;
DST++;
}
}
}
void MAPTYPECALL(_MAX)(MAPTYPE *MapSRC,MAPTYPE *MapDST)
{
PIXELMAPTYPE *LAST,*DST,*SRC;
for (u32 SizeY = 1; SizeY < MapSRC->SY - 1;SizeY ++)
{
SRC = MapSRC->GetBase() + SizeY * MapSRC->PITCH + 1;
DST = MapDST->GetBase() + SizeY * MapDST->PITCH + 1;
LAST = SRC + MapSRC->SX - 1 * 2;
while (SRC < LAST)
{
*DST = *SRC;
if (*DST < *(SRC+1)) *DST = *(SRC+1);
if (*DST < *(SRC+1+MapSRC->PITCH)) *DST = *(SRC+1+MapSRC->PITCH);
if (*DST < *(SRC+1-MapSRC->PITCH)) *DST = *(SRC+1-MapSRC->PITCH);
if (*DST < *(SRC-1)) *DST = *(SRC-1);
if (*DST < *(SRC-1+MapSRC->PITCH)) *DST = *(SRC-1+MapSRC->PITCH);
if (*DST < *(SRC-1-MapSRC->PITCH)) *DST = *(SRC-1-MapSRC->PITCH);
if (*DST < *(SRC+MapSRC->PITCH)) *DST = *(SRC+MapSRC->PITCH);
if (*DST < *(SRC-MapSRC->PITCH)) *DST = *(SRC-MapSRC->PITCH);
SRC++;
DST++;
}
}
}
void MAPTYPECALL(_Sub)(MAPTYPE *pSrc,MAPTYPE *pDst)
{
// In place blur 8 bits horizontaly
PIXELMAPTYPE *PPd,*PPl,*PPdOfset;
PIXELMAPTYPE *ppSrc;
ppSrc = (PIXELMAPTYPE*)pSrc->GetBase();
PPd = pDst->GetBase();
PPl = pDst->GetBase() + pDst->PITCH * pDst->SY;
while (PPd < PPl)
{
*PPd -= *ppSrc;
PPd ++;
ppSrc++;
}
}
void MAPTYPECALL(_MaxValue)(MAPTYPE *pSrc,PIXELMAPTYPE Value)
{
// In place blur 8 bits horizontaly
PIXELMAPTYPE *PPl;
PIXELMAPTYPE *ppSrc;
ppSrc = (PIXELMAPTYPE*)pSrc->GetBase();
PPl = pSrc->GetBase() + pSrc->PITCH * pSrc->SY;
while (ppSrc < PPl)
{
if (*ppSrc > Value) *ppSrc = Value;
ppSrc++;
}
}
void MAPTYPECALL(_Div)(MAPTYPE *pSrc,MAPTYPE *pDst,PIXELMAPTYPE Delta)
{
// In place blur 8 bits horizontaly
PIXELMAPTYPE *PPd,*PPl,*PPdOfset;
PIXELMAPTYPE *ppSrc;
ppSrc = (PIXELMAPTYPE*)pSrc->GetBase();
PPd = pDst->GetBase();
PPl = pDst->GetBase() + pDst->PITCH * pDst->SY;
while (PPd < PPl)
{
if (*ppSrc + Delta)
*PPd /= *ppSrc + Delta;
else
*PPd = 0;
PPd ++;
ppSrc++;
}
}
void MAPTYPECALL(_Copy8)(MAP8 *pSrc,MAPTYPE *pDst)
{
// In place blur 8 bits horizontaly
PIXELMAPTYPE *PPd,*PPl,*PPdOfset;
u8 *ppSrc;
ppSrc = pSrc->GetBase();
PPd = pDst->GetBase();
PPl = pDst->GetBase() + pDst->PITCH * pDst->SY;
while (PPd < PPl)
{
u16 Lv = *PPd;
*PPd = ((PIXELMAPTYPE)(*ppSrc)-128)<<7;
PPd ++;
ppSrc++;
}
}
void MAPTYPECALL(_SwapTranspose8)(PIXELMAPTYPE *pSrc1,PIXELMAPTYPE *pSrc2,s32 Pitch)
{
PIXELMAPTYPE Swap1[8*8],*pSwap1;
PIXELMAPTYPE Swap2[8*8],*pSwap2;
pSwap1 = Swap1; pSwap2 = Swap2;
for (int X = 0 ; X < 8 ; X ++)
{
for (int Y = 0 ; Y < 8 ; Y ++)
{
*(pSwap1++) = *(pSrc1++);
*(pSwap2++) = *(pSrc2++);
}
pSrc1+=Pitch - 8;
pSrc2+=Pitch - 8;
}
pSrc1 -= 8*Pitch;
pSrc2 -= 8*Pitch;
for (int X = 0 ; X < 8 ; X ++)
{
pSwap1 = Swap1+X; pSwap2 = Swap2+X;
for (int Y = 0 ; Y < 8 ; Y ++)
{
*(pSrc1++) = *(pSwap2);
*(pSrc2++) = *(pSwap1);
pSwap1+=8;
pSwap2+=8;
}
pSrc1+=Pitch - 8;
pSrc2+=Pitch - 8;
}
}
void MAPTYPECALL(_BLUR_TransposeFAST)(MAPTYPE *pSrc)
{
/* pSrc Must Be a Quad. */
#define TileSizePo2 3
#define TileSizeSize (1<<TileSizePo2)
u32 MAXX;
PIXELMAPTYPE *pSrcBASE = pSrc->GetBase();
MAXX = pSrc->SX < pSrc->SY ? pSrc->SX : pSrc->SY;
for (int Y = 0 ; Y < MAXX ; Y += TileSizeSize)
{
for (int X = Y ; X < MAXX ; X += TileSizeSize)
{
MAPTYPECALL(_SwapTranspose8)(pSrcBASE + X + Y * pSrc->PITCH,pSrcBASE + Y + X * pSrc->PITCH,pSrc->PITCH);
}
}
}
void MAPTYPECALL(_SWAP_Inplace)(MAPTYPE *pSrc)
{
MAPTYPE Map, Map2;
PIXELMAPTYPE pSwap;
int iSwap;
// Warning algorithm assumes that there is enought memory allocated
if (pSrc->PITCH >= pSrc->SY)
{
Map = *pSrc; Map.staticBase = 1;
Map.SY = pSrc->PITCH;
MAPTYPECALL(_BLUR_TransposeFAST)(&Map);
PIXELMAPTYPE *buffer = pSrc->GetBase();
PIXELMAPTYPE *bufferPtr, *bufferPtrDec, *bufferEnd, *bufferEndIn;
// put buffer at end
if (pSrc->SX > pSrc->SY)
{
int decSize = pSrc->PITCH - pSrc->SY;
int dec = 0;
bufferPtr = buffer;
bufferPtrDec = buffer;
bufferEnd = bufferPtr + pSrc->SX*pSrc->SY;
while (bufferPtr < bufferEnd)
{
bufferEndIn = bufferPtr + pSrc->SY;
while (bufferPtr < bufferEndIn)
{
*bufferPtr = *bufferPtrDec;
bufferPtr++;
bufferPtrDec++;
}
bufferPtrDec += decSize;
}
}
iSwap = pSrc->SY;
pSrc->SY = pSrc->SX;
pSrc->PITCH = iSwap;
pSrc->SX = iSwap;
} else
{
PIXELMAPTYPE *buffer = pSrc->GetBase();
PIXELMAPTYPE *bufferPtr, *bufferPtrDec, *bufferBeginIn;
int decSize = pSrc->SY - pSrc->PITCH;
int dec = 0;
bufferPtr = buffer + pSrc->SY*pSrc->SY - 1 - decSize;
bufferPtrDec= buffer + pSrc->PITCH*pSrc->SY - 1;
while (buffer < bufferPtrDec)
{
bufferBeginIn = bufferPtrDec - pSrc->PITCH;
while (bufferBeginIn < bufferPtrDec)
{
*bufferPtr = *bufferPtrDec;
bufferPtr--;
bufferPtrDec--;
}
bufferPtr -= decSize;
}
Map = *pSrc; Map.staticBase = 1;
Map.SX = pSrc->SY;
Map.PITCH = pSrc->SY;
MAPTYPECALL(_BLUR_TransposeFAST)(&Map);
iSwap = pSrc->SY;
pSrc->SY = pSrc->SX;
pSrc->PITCH = iSwap;
pSrc->SX = iSwap;
}
}
void MAPTYPECALL(_BLUR_H_Inplace)(MAPTYPE *pSrc,u32 Rpo2)
{
// In place blur 8 bits horizontaly
PIXELMAPTYPE *PPd,*PPl,*PPdOfset;
u32 R = (1<<Rpo2 );
s32 INC = 0;
Rpo2++;
PIXELMAPTYPE *pSrcBASE = pSrc->GetBase();
for (int i = 0 ; i < R ; i ++) INC += (s32)pSrcBASE[i];
PPd = pSrc->GetBase();
PPl = pSrc->GetBase() + pSrc->PITCH * pSrc->SY - R;
while (PPd < PPl)
{
PIXELMAPTYPE Lv = *PPd;
*PPd = (PIXELMAPTYPE)(INC>>Rpo2);
INC -= Lv;
INC += *(PPd + R);
PPd ++;
}
PPd = pSrc->GetBase();
PPdOfset = PPl - (R>>1);
while (PPdOfset > PPd)
{
*(PPl--) = (*(PPdOfset) + *(PPdOfset+1));
PPdOfset--;
}
}
//*/
/*
void MAPTYPECALL(_BLUR_H_Inplace)(MAPTYPE *pSrc,u32 Rpo2)
{
// In place blur 8 bits horizontaly
PIXELMAPTYPE *PPd,*PPl,*PPi,*PPdOfset;
u32 R = (1<<Rpo2 );
s32 INC = 0;
Rpo2++;
PIXELMAPTYPE *pSrcBASE = pSrc->GetBase();
for (int i = 0 ; i < R ; i ++) INC += (s32)pSrcBASE[i];
PPd = pSrc->GetBase();
PPl = pSrc->GetBase() + pSrc->PITCH * pSrc->SY - R;
while (PPd < PPl)
{
PPi = PPd + pSrc->SX;
while (PPd < PPi)
{
PIXELMAPTYPE Lv = *PPd;
*PPd = (PIXELMAPTYPE)(INC>>Rpo2);
INC -= Lv;
INC += *(PPd + R);
PPd++;
}
PPd += pSrc->PITCH - pSrc->SX;
}
PPd = pSrc->GetBase();
PPdOfset = PPl - (R>>1);
while (PPdOfset > PPd)
{
*(PPl--) = (*(PPdOfset) + *(PPdOfset+1));
PPdOfset--;
}
}
//*/
/*
void MAPTYPECALL(_BLUR_H_Inplace)(MAPTYPE *pSrc,u32 Rpo2)
{
// In place blur 8 bits horizontaly
u32 R = (1<<Rpo2 );
u32 INC, PREV_INC;
int i;
PIXELMAPTYPE buffer[1088];
PIXELMAPTYPE *bufferPtr;
PIXELMAPTYPE *PPd, *PPl, *PPi;
Rpo2++;
PPd = pSrc->GetBase();
PPl = pSrc->GetBase() + pSrc->PITCH * pSrc->SY - R;
while (PPd < PPl)
{
for (i=0; i<(R>>1)+1; i++) buffer[i] = PPd[0];
memcpy(buffer + (R>>1)+1, PPd, pSrc->SX*sizeof(PIXELMAPTYPE));
for (i=0; i<(R>>1)+1; i++) buffer[i+pSrc->SX+(R>>1)] = PPd[pSrc->SX-1];
INC =0;
for (i=1; i<R+1 ; i++) INC += (u32)buffer[i-1];
PPi = PPd + pSrc->SX;
bufferPtr = buffer;
while (PPd < PPi)
{
PREV_INC = INC;
INC += (u32)*(bufferPtr + R);
INC -= (u32)*bufferPtr;
*PPd = (PIXELMAPTYPE)((INC+PREV_INC)>>Rpo2);
PPd++;
bufferPtr++;
}
PPd += pSrc->PITCH - pSrc->SX;
}
}
//*/
void MAPTYPECALL(_BLUR_V_Inplace_Old)(MAPTYPE *pSrc,u32 Rpo2)
{
// In place blur 8 bits verticaly
PIXELMAPTYPE *PPd,*PPl,*PPdOfset;
u32 R = 1<<Rpo2;
s32 INC[1024];
Rpo2 ++;
memset(INC,0,sizeof(INC));
PIXELMAPTYPE *pSrcBASE = pSrc->GetBase();
for (int i = 0 ; i < pSrc->SX ; i ++)
{
for (int j = 0 ; j < R ; j ++)
INC[i] += (s32)pSrcBASE[i+j *pSrc->PITCH];
}
for (int i = 0 ; i < pSrc->SY-R ; i ++)
{
s32 *pINC;
PIXELMAPTYPE *PPd2;
pINC = INC;
PPd = pSrc->GetBase() + i * pSrc->PITCH;
PPl = pSrc->GetBase() + i * pSrc->PITCH + pSrc->SX;
PPd2 = PPd + R * pSrc->PITCH;
while (PPd < PPl)
{
PIXELMAPTYPE Lv = *PPd;
*PPd = (PIXELMAPTYPE)(*pINC>>Rpo2);
*pINC -= Lv;
*pINC += *(PPd2++);
pINC++;
PPd ++;
}
}
for (int i = pSrc->SY-R; i < pSrc->SY ; i ++)
{
s32 *pINC;
pINC = INC;
PPd = pSrc->GetBase() + i * pSrc->PITCH;
PPl = pSrc->GetBase() + i * pSrc->PITCH + pSrc->SX;
while (PPd < PPl)
{
PIXELMAPTYPE Lv = *PPd;
*PPd = (PIXELMAPTYPE)(*pINC >>Rpo2 );
*pINC -= Lv;
pINC++;
PPd ++;
}
}
PPd = pSrc->GetBase();
PPdOfset = PPl - (R>>1) * pSrc->PITCH;
while (PPdOfset > PPd)
{
*(PPl--) = (*(PPdOfset) + *(PPdOfset + pSrc->PITCH));
PPdOfset--;
}
}
void MAPTYPECALL(_BLUR_V_Inplace)(MAPTYPE *pSrc,u32 Rpo2)
{
// In place blur 8 bits verticaly
if (Rpo2 > 3)
{
MAPTYPECALL(_BLUR_V_Inplace_Old)(pSrc,Rpo2);
return;
}
u32 R = 1<<Rpo2;
u32 INC[1024];
u32 PREV_INC;
u32 *pINC;
PIXELMAPTYPE buffer[1024*9]; // Rpo2 <= 3
int i;
Rpo2 ++;
PIXELMAPTYPE *pSrcBASE = pSrc->GetBase();
PIXELMAPTYPE *bufferPtr, *bufferPtr2;
PIXELMAPTYPE *PPd, *PPl, *PPi;
for (i=0; i<(R>>1)-1; i++)
memcpy(buffer + i*pSrc->SX, pSrcBASE, pSrc->SX*sizeof(PIXELMAPTYPE));
for (i=(R>>1)-1; i<=R; i++)
memcpy(buffer + i*pSrc->SX, pSrcBASE+(i-(R>>1)+1)*pSrc->PITCH, pSrc->SX*sizeof(PIXELMAPTYPE));
memset(INC,0,sizeof(INC));
PPd = buffer;
for (i=1; i<=R; i++)
{
pINC = INC;
PPl = PPd + pSrc->SX;
while (PPd < PPl)
{
*pINC += (u32)*PPd;
PPd++;
pINC++;
}
}
s32 beginIndex = 0;
s32 endIndex = R;
PPd = pSrcBASE;
for (i = 0 ; i < pSrc->SY ; i ++)
{
pINC = INC;
PPl = PPd + pSrc->SX;
bufferPtr = buffer + beginIndex* pSrc->SX;
bufferPtr2 = buffer + endIndex* pSrc->SX;
while (PPd < PPl)
{
PREV_INC = *pINC;
*pINC += (u32)*bufferPtr2;
*pINC -= (u32)*bufferPtr;
*PPd = (PIXELMAPTYPE)((*pINC+PREV_INC)>>Rpo2);
PPd++;
bufferPtr++;
bufferPtr2++;
pINC++;
}
if ((i+(R>>1)+1) < pSrc->SY)
memcpy(buffer + beginIndex*pSrc->SX,
pSrcBASE+(i+(R>>1)+1)*pSrc->PITCH, pSrc->SX*sizeof(PIXELMAPTYPE));
else
memcpy(buffer + beginIndex*pSrc->SX,
pSrcBASE+(pSrc->SY-1)*pSrc->PITCH, pSrc->SX*sizeof(PIXELMAPTYPE));
endIndex = beginIndex;
beginIndex = (beginIndex + 1) % (R+1);
PPd += pSrc->PITCH - pSrc->SX;
}
}
//*/
void MAPTYPECALL(_BLUR_Inplace)(MAPTYPE *pSrc, u32 Rpo2 , u32 Iteration)
{
SET_BORDER16(pSrc,1<<(Rpo2-1),0);
while (Iteration--)
{
MAPTYPECALL(_BLUR_H_Inplace)(pSrc,Rpo2);
MAPTYPECALL(_BLUR_V_Inplace)(pSrc,Rpo2);
}
}
#define PIXELMAPTYPE_SWAP(a,b) {PIXELMAPTYPE Swp;Swp = a;a = b ; b = Swp; }
void MAPTYPECALL(_ShiftLine)(PIXELMAPTYPE *pSrc,s32 Shift,s32 Lenght)
{
PIXELMAPTYPE CpyL[2048];
// In place shift 16 bits horizontaly
if (Shift < 0) Shift = Lenght + Shift;
if (Shift <= 0) return;
if (Shift >= Lenght) Shift = Lenght -1;
memcpy(CpyL,pSrc,Lenght*sizeof(PIXELMAPTYPE));
memcpy(pSrc,CpyL+Lenght-Shift,Shift*sizeof(PIXELMAPTYPE));
memcpy(pSrc+Shift,CpyL,(Lenght-Shift)*sizeof(PIXELMAPTYPE));
}
void MAPTYPECALL(_ShiftLine_Interpolated)(PIXELMAPTYPE *pSrc,s32 Shift,s32 Lenght)
{
PIXELMAPTYPE CpyL[2048];
s32 Counter ;
// In place shift 16 bits horizontaly
if (Shift == 0) return;
if (Shift < 0) Shift += (Lenght<<8);
if (Shift < 0) Shift += (Lenght<<8);
if (Shift < 0) Shift += (Lenght<<8);
if (Shift > Lenght<<8) Shift %= Lenght<<8;
if (Shift == 0) return;
s32 Blend = (Shift&0xff);
Shift >>= 8;
for (Counter = 0;Counter < Lenght; Counter++)
pSrc[Counter]>>=4;
for (Counter = 0;Counter < Shift-1; Counter++)
{
CpyL[Counter] = (pSrc[Lenght-Shift+Counter] * Blend + pSrc[Lenght-Shift+Counter+1] * (255-Blend))>>4;
}
CpyL[Counter] = (pSrc[Lenght-Shift+Counter] * Blend + pSrc[0] * (255-Blend))>>4;
for (Counter = Shift;Counter < Lenght ; Counter++)
{
CpyL[Counter] = (pSrc[Counter-Shift] * Blend + pSrc[Counter-Shift+1] * (255-Blend))>>4;
}
memcpy(pSrc+1,CpyL,(Lenght-1)*sizeof(PIXELMAPTYPE));
pSrc[0] = CpyL[Lenght-1];
}
void MAPTYPECALL(_BLUR_ScissorX_Inplace_Interpolated)(MAPTYPE *pSrc,s32 FactorX)
{
PIXELMAPTYPE *pCrnt,*pLast;
float Inc,Base;
pCrnt = pSrc->GetBase();
pLast = pCrnt + pSrc->PITCH * pSrc->SY;
Base = 0.0f;
Inc = (float)FactorX / (float)pSrc->SY;
while (pCrnt < pLast)
{
MAPTYPECALL(_ShiftLine_Interpolated)(pCrnt,(s32)(Base*256.0f),pSrc->SX);
Base+=Inc;
pCrnt+=pSrc->PITCH;
}
}
void MAPTYPECALL(_BLUR_CopyTranspose)(MAPTYPE *pSrc,MAPTYPE *pDst)
{
PIXELMAPTYPE *pucS,*pucD,*pucL,*pucLL;
u32 HL;
pDst->PITCH = pDst->SX = pSrc->SY;
pDst->SY = pSrc->SX;
pucS = pSrc->GetBase();
pucD = pDst->GetBase();
HL = pSrc->PITCH * pSrc->SY;
pucLL = pucS + pSrc->SX;
while (pucS < pucLL)
{
pucL = pucS + HL;
while (pucS < pucL)
{
*(pucD++) = *pucS;
pucS+=pSrc->PITCH;
}
pucS -= HL - 1;
}
}
#define TRANSPOSEMAP(TheMapM)\
{\
s32 Swap;\
Swap = TheMapM.PITCH;\
TheMapM.PITCH = TheMapM.SX = TheMapM.SY;\
TheMapM.SY = Swap;\
}
void MAPTYPECALL(_Rotate)(MAPTYPE *pSrc,MAPTYPE *pTmp,u32 Alpha)
{
if (!Alpha) return;
u32 Xalpha = ((u32)Alpha) + (32<<8);
if (Xalpha & (64<<8))
{
MAPTYPE MapTmpTransp;
MAPTYPE MapSrcTransp;
s32 FactorX = (float)pSrc->SX * tanf((64.0f + (float)Alpha) * 2.0f * 3.1415927f / 65536.0f );
MapTmpTransp =*pTmp;
MapSrcTransp =*pSrc;
TRANSPOSEMAP(MapTmpTransp);
TRANSPOSEMAP(MapSrcTransp);
MAPTYPECALL(_BLUR_CopyTranspose)(pSrc,&MapTmpTransp);
MAPTYPECALL(_BLUR_ScissorX_Inplace_Interpolated)(&MapTmpTransp,-FactorX);
MAPTYPECALL(_BLUR_CopyTranspose)(&MapTmpTransp,pSrc);
} else
{
s32 FactorX = (float)pSrc->SY * tanf((float)Alpha * 2.0f * 3.1415927f / 65536.0f );
MAPTYPECALL(_BLUR_ScissorX_Inplace_Interpolated)(pSrc,FactorX);
}
}
void MAPTYPECALL(_BLUR_XY)(MAPTYPE *pSrc,MAPTYPE *pTmp,u8 Alpha, u32 Rpo2 , u32 Iteration)
{
if (!Rpo2) return;
u32 Xalpha = ((u32)Alpha) + 32;
if (Xalpha & 64)
{
MAPTYPE MapTmpTransp;
MAPTYPE MapSrcTransp;
s32 FactorX = (float)pSrc->SX * tanf((64.0f + (float)Alpha) * 2.0f * 3.1415927f / 256.0f );
MapTmpTransp =*pTmp;
MapSrcTransp =*pSrc;
TRANSPOSEMAP(MapTmpTransp);
TRANSPOSEMAP(MapSrcTransp);
MAPTYPECALL(_BLUR_CopyTranspose)(pSrc,&MapTmpTransp);
MAPTYPECALL(_BLUR_ScissorX_Inplace_Interpolated)(&MapTmpTransp,-FactorX);
MAPTYPECALL(_BLUR_CopyTranspose)(&MapTmpTransp,pSrc);
while (Iteration--) MAPTYPECALL(_BLUR_H_Inplace)(pSrc,Rpo2);
MAPTYPECALL(_BLUR_CopyTranspose)(pSrc,&MapTmpTransp);
MAPTYPECALL(_BLUR_ScissorX_Inplace_Interpolated)(&MapTmpTransp,FactorX);
MAPTYPECALL(_BLUR_CopyTranspose)(&MapTmpTransp,pSrc);
} else
{
s32 FactorX = (float)pSrc->SY * tanf((float)Alpha * 2.0f * 3.1415927f / 256.0f );
MAPTYPECALL(_BLUR_ScissorX_Inplace_Interpolated)(pSrc,FactorX);
while (Iteration--) MAPTYPECALL(_BLUR_V_Inplace)(pSrc,Rpo2);
MAPTYPECALL(_BLUR_ScissorX_Inplace_Interpolated)(pSrc,-FactorX);
}
}
void MAPTYPECALL(_PowerBlur_H)(MAPTYPE *MapSRC,s32 Power)
{
PIXELMAPTYPE *LAST,*SRC;
s32 *DST,OneMinusPower = 256 - Power;
s32 Accum[2048];
for (u32 SizeY = 0; SizeY < MapSRC->SY ;SizeY ++)
{
s32 CurrentV;
DST = Accum;
SRC = MapSRC->GetBase()+SizeY*MapSRC->PITCH;
LAST = SRC + MapSRC->SX;
memset(DST, 0 , sizeof(Accum[0]) * (MapSRC->SX+1));
CurrentV = *(SRC);
while (SRC < LAST)
{
CurrentV = (CurrentV * Power) + ((s32)*SRC * OneMinusPower)>>8;
*DST = CurrentV;
SRC++;
DST++;
}
CurrentV = *(SRC-1);
LAST -= MapSRC->SX;
while (SRC > LAST)
{
SRC--;
DST--;
CurrentV = (CurrentV * Power) + ((s32)*SRC * OneMinusPower)>>8;
*SRC = (CurrentV + *DST)>>1;
}
SRC = MapSRC->GetBase()+SizeY*MapSRC->PITCH;
}
}
void MAPTYPECALL(_PowerBlur_H_ParmaMap)(MAPTYPE *MapSRC,MAP8 *MapParram,u32 AutoTransp)
{
PIXELMAPTYPE *LAST,*SRC;
s32 *DST,AutoPitch;
s32 Accum[2048];
AutoPitch = 1;
if (AutoTransp)
{
AutoPitch = MapParram->PITCH;
AutoTransp = 1;
} else
AutoTransp = MapParram->PITCH;
for (u32 SizeY = 0; SizeY < MapSRC->SY ;SizeY ++)
{
s32 CurrentV;
u8 *Parram = MapParram->GetBase()+SizeY*AutoTransp;
DST = Accum;
SRC = MapSRC->GetBase()+SizeY*MapSRC->PITCH;
LAST = SRC + MapSRC->SX;
memset(DST, 0 , sizeof(Accum[0]) * (MapSRC->SX+1));
CurrentV = *(SRC);
while (SRC < LAST)
{
CurrentV = (CurrentV * (s32)*Parram) + ((s32)*SRC * (256 - (s32)*Parram))>>8;
*DST = CurrentV;
SRC++;
DST++;
Parram+=AutoPitch;
}
CurrentV = *(SRC-1);
LAST -= MapSRC->SX;
while (SRC > LAST)
{
SRC--;
DST--;
Parram-=AutoPitch;
CurrentV = (CurrentV * (s32)*Parram) + ((s32)*SRC * (256 - (s32)*Parram))>>8;
*SRC = (CurrentV + *DST)>>1;
}
SRC = MapSRC->GetBase()+SizeY*MapSRC->PITCH;
}
}
void MAPTYPECALL(_PowerBlur_H_Denoise)(MAPTYPE *MapSRC,s32 Power)
{
PIXELMAPTYPE *LAST,*SRC;
s32 *DST,OneMinusPower = 256 - Power;
s32 Accum[2048];
for (u32 SizeY = 0; SizeY < MapSRC->SY ;SizeY ++)
{
s32 CurrentV;
DST = Accum;
SRC = MapSRC->GetBase()+SizeY*MapSRC->PITCH;
LAST = SRC + MapSRC->SX;
memset(DST, 0 , sizeof(Accum[0]) * (MapSRC->SX+1));
CurrentV = *(SRC);
while (SRC < LAST)
{
CurrentV = (CurrentV * Power) + ((s32)*SRC * OneMinusPower)>>8;
*DST = CurrentV;
SRC++;
DST++;
}
CurrentV = *(SRC-1);
LAST -= MapSRC->SX;
while (SRC > LAST)
{
SRC--;
DST--;
CurrentV = (CurrentV * Power) + ((s32)*SRC * OneMinusPower)>>8;
s32 RValue;
if (abs(*SRC - CurrentV) > abs(*SRC - *DST))
RValue = *DST;
else
RValue = CurrentV;
*SRC = RValue;
}
SRC = MapSRC->GetBase()+SizeY*MapSRC->PITCH;
}
}
void MAPTYPECALL(_PowerBlur_V)(MAPTYPE *MapSRC,MAPTYPE *MapTmp,s32 Power,u32 Iterations)
{
MAPTYPE MapTmpTransp;
MapTmpTransp =*MapTmp;
TRANSPOSEMAP(MapTmpTransp);
MAPTYPECALL(_BLUR_CopyTranspose)(MapSRC,&MapTmpTransp);
while (Iterations--) MAPTYPECALL(_PowerBlur_H)(&MapTmpTransp,Power);
MAPTYPECALL(_BLUR_CopyTranspose)(&MapTmpTransp,MapSRC);
}
void MAPTYPECALL(_PowerBlur_V_Denoise)(MAPTYPE *MapSRC,MAPTYPE *MapTmp,s32 Power,u32 Iterations)
{
MAPTYPE MapTmpTransp;
MapTmpTransp =*MapTmp;
TRANSPOSEMAP(MapTmpTransp);
MAPTYPECALL(_BLUR_CopyTranspose)(MapSRC,&MapTmpTransp);
while (Iterations--) MAPTYPECALL(_PowerBlur_H_Denoise)(&MapTmpTransp,Power);
MAPTYPECALL(_BLUR_CopyTranspose)(&MapTmpTransp,MapSRC);
}
void MAPTYPECALL(_PowerBlur)(MAPTYPE *MapSRC,MAPTYPE *MapTmp,s32 Power,u32 Iterations)
{
MAPTYPE MapTmpTransp;
while (Iterations--)
{
MapTmpTransp =*MapTmp;
MAPTYPECALL(_PowerBlur_H)(MapSRC,Power);
TRANSPOSEMAP(MapTmpTransp);
MAPTYPECALL(_BLUR_CopyTranspose)(MapSRC,&MapTmpTransp);
MAPTYPECALL(_PowerBlur_H)(&MapTmpTransp,Power);
MAPTYPECALL(_BLUR_CopyTranspose)(&MapTmpTransp,MapSRC);
}
}
void MAPTYPECALL(_PowerBlur_ParraMap)(MAPTYPE *MapSRC,MAPTYPE *MapTmp,MAP8 *MapParram,u32 Iterations)
{
MAPTYPE MapTmpTransp;
while (Iterations--)
{
MapTmpTransp =*MapTmp;
MAPTYPECALL(_PowerBlur_H_ParmaMap)(MapSRC,MapParram,0);
TRANSPOSEMAP(MapTmpTransp);
MAPTYPECALL(_BLUR_CopyTranspose)(MapSRC,&MapTmpTransp);
MAPTYPECALL(_PowerBlur_H_ParmaMap)(&MapTmpTransp,MapParram,1);
MAPTYPECALL(_BLUR_CopyTranspose)(&MapTmpTransp,MapSRC);
}
}
void MAPTYPECALL(_PowerBlur_Denoise_XY)(MAPTYPE *pSrc,MAPTYPE *pTmp,u8 Alpha, u32 Power, u32 Iteration)
{
SET_BORDER16(pSrc,4,0);
u32 Xalpha = ((u32)Alpha) + 32;
if (Xalpha & 64)
{
MAPTYPE MapTmpTransp;
MAPTYPE MapSrcTransp;
s32 FactorX = (float)pSrc->SX * tanf((64.0f + (float)Alpha) * 2.0f * 3.1415927f / 256.0f );
MapTmpTransp =*pTmp;
MapSrcTransp =*pSrc;
TRANSPOSEMAP(MapTmpTransp);
TRANSPOSEMAP(MapSrcTransp);
MAPTYPECALL(_BLUR_CopyTranspose)(pSrc,&MapTmpTransp);
MAPTYPECALL(_BLUR_ScissorX_Inplace_Interpolated)(&MapTmpTransp,-FactorX);
MAPTYPECALL(_BLUR_CopyTranspose)(&MapTmpTransp,pSrc);
while (Iteration--) MAPTYPECALL(_PowerBlur_H_Denoise)(pSrc,Power);
MAPTYPECALL(_BLUR_CopyTranspose)(pSrc,&MapTmpTransp);
MAPTYPECALL(_BLUR_ScissorX_Inplace_Interpolated)(&MapTmpTransp,FactorX);
MAPTYPECALL(_BLUR_CopyTranspose)(&MapTmpTransp,pSrc);
} else
{
s32 FactorX = (float)pSrc->SY * tanf((float)Alpha * 2.0f * 3.1415927f / 256.0f );
MAPTYPECALL(_BLUR_ScissorX_Inplace_Interpolated)(pSrc,FactorX);
MAPTYPECALL(_PowerBlur_V_Denoise)(pSrc,pTmp,Power,Iteration);
MAPTYPECALL(_BLUR_ScissorX_Inplace_Interpolated)(pSrc,-FactorX);
}
}
void MAPTYPECALL(_PowerBlur_Denoise)(MAPTYPE *MapSRC,MAPTYPE *MapTmp,u32 Power,u32 Iterations)
{
MAPTYPE MapTmpTransp;
while (Iterations--)
{
MapTmpTransp =*MapTmp;
MAPTYPECALL(_PowerBlur_H_Denoise)(MapSRC,Power);
TRANSPOSEMAP(MapTmpTransp);
MAPTYPECALL(_BLUR_CopyTranspose)(MapSRC,&MapTmpTransp);
MAPTYPECALL(_PowerBlur_H_Denoise)(&MapTmpTransp,Power);
MAPTYPECALL(_BLUR_CopyTranspose)(&MapTmpTransp,MapSRC);
}
}
void MAPTYPECALL(_X_BLUR_XY)(MAPTYPE *pSrc,MAPTYPE *pTmp,u8 Alpha, u32 Power,
void CALLBACK_Blur_H(MAPTYPE *MapSRC,s32 Power)
)
{
SET_BORDER16(pSrc,4,0);
u32 Xalpha = ((u32)Alpha) + 32;
if (Xalpha & 64)
{
MAPTYPE MapTmpTransp;
MAPTYPE MapSrcTransp;
s32 FactorX = (float)pSrc->SX * tanf((64.0f + (float)Alpha) * 2.0f * 3.1415927f / 256.0f );
MapTmpTransp =*pTmp;
MapSrcTransp =*pSrc;
TRANSPOSEMAP(MapTmpTransp);
TRANSPOSEMAP(MapSrcTransp);
MAPTYPECALL(_BLUR_CopyTranspose)(pSrc,&MapTmpTransp);
MAPTYPECALL(_BLUR_ScissorX_Inplace_Interpolated)(&MapTmpTransp,-FactorX);
MAPTYPECALL(_BLUR_CopyTranspose)(&MapTmpTransp,pSrc);
CALLBACK_Blur_H(pSrc,Power);
MAPTYPECALL(_BLUR_CopyTranspose)(pSrc,&MapTmpTransp);
MAPTYPECALL(_BLUR_ScissorX_Inplace_Interpolated)(&MapTmpTransp,FactorX);
MAPTYPECALL(_BLUR_CopyTranspose)(&MapTmpTransp,pSrc);
} else
{
s32 FactorX = (float)pSrc->SY * tanf((float)Alpha * 2.0f * 3.1415927f / 256.0f );
MAPTYPECALL(_BLUR_ScissorX_Inplace_Interpolated)(pSrc,FactorX);
MAPTYPE MapTmpTransp;
MapTmpTransp =*pTmp;
TRANSPOSEMAP(MapTmpTransp);
MAPTYPECALL(_BLUR_CopyTranspose)(pSrc,&MapTmpTransp);
CALLBACK_Blur_H(&MapTmpTransp,Power);
MAPTYPECALL(_BLUR_CopyTranspose)(&MapTmpTransp,pSrc);
MAPTYPECALL(_BLUR_ScissorX_Inplace_Interpolated)(pSrc,-FactorX);
}
}
void MAPTYPECALL(_PowerBLUR_XY)(MAPTYPE *pSrc,MAPTYPE *pTmp,u8 Alpha, u32 Power, u32 Iteration)
{
SET_BORDER16(pSrc,4,0);
u32 Xalpha = ((u32)Alpha) + 32;
if (Xalpha & 64)
{
MAPTYPE MapTmpTransp;
MAPTYPE MapSrcTransp;
s32 FactorX = (float)pSrc->SX * tanf((64.0f + (float)Alpha) * 2.0f * 3.1415927f / 256.0f );
MapTmpTransp =*pTmp;
MapSrcTransp =*pSrc;
TRANSPOSEMAP(MapTmpTransp);
TRANSPOSEMAP(MapSrcTransp);
MAPTYPECALL(_BLUR_CopyTranspose)(pSrc,&MapTmpTransp);
MAPTYPECALL(_BLUR_ScissorX_Inplace_Interpolated)(&MapTmpTransp,-FactorX);
MAPTYPECALL(_BLUR_CopyTranspose)(&MapTmpTransp,pSrc);
while (Iteration--) MAPTYPECALL(_PowerBlur_H)(pSrc,Power);
MAPTYPECALL(_BLUR_CopyTranspose)(pSrc,&MapTmpTransp);
MAPTYPECALL(_BLUR_ScissorX_Inplace_Interpolated)(&MapTmpTransp,FactorX);
MAPTYPECALL(_BLUR_CopyTranspose)(&MapTmpTransp,pSrc);
} else
{
s32 FactorX = (float)pSrc->SY * tanf((float)Alpha * 2.0f * 3.1415927f / 256.0f );
MAPTYPECALL(_BLUR_ScissorX_Inplace_Interpolated)(pSrc,FactorX);
MAPTYPECALL(_PowerBlur_V)(pSrc,pTmp,Power,Iteration);
MAPTYPECALL(_BLUR_ScissorX_Inplace_Interpolated)(pSrc,-FactorX);
}
}
u32 MAPTYPECALLEnd(MAP_2_)(MAP *MapSRC,MAPTYPE *MapDST,u32 Shift ) // Return Average
{
s32 *SRC,MaxX,MaxY;
u32 AverageC = 0;
PIXELMAPTYPE *LAST,*DST;
DST = MapDST->GetBase();
SRC = MapSRC->GetBase();
MaxX = MapSRC->SX > MapDST->SX ? MapDST->SX : MapSRC->SX;
MaxY = MapSRC->SY > MapDST->SY ? MapDST->SY : MapSRC->SY;
for (u32 SizeY = 0; SizeY < MaxY;SizeY ++)
{
LAST = DST + MaxX;
while (DST < LAST)
{
u32 A;
A = ((*(SRC) & 0xff0000) + ((*(SRC) & 0xff00)<<9) + ((*(SRC) & 0xff)<<16));
*(DST) = A>>(Shift);
AverageC += A >> Shift;
DST++;
SRC++;
}
SRC+=MapSRC->PITCH-MaxX;
DST+=MapDST->PITCH-MaxX;
}
return (AverageC / (MaxX)) / MaxY;
}
u32 MAP_2_MAP16_RGBA(MAP *MapSRC,MAPTYPE *MapDST,u32 RGBA ) // Return Average
{
s32 *SRC;
u32 AverageC = 0;
PIXELMAPTYPE *LAST,*DST;
DST = MapDST->GetBase();
SRC = MapSRC->GetBase();
RGBA *= 8;
for (u32 SizeY = 0; SizeY < MapDST->SY;SizeY ++)
{
LAST = DST + MapDST->SX;
while (DST < LAST)
{
*(DST) = (*(SRC)>>RGBA) & 0xff;
DST++;
SRC++;
}
SRC+=MapSRC->PITCH-MapSRC->SX;
DST+=MapDST->PITCH-MapDST->SX;
}
return (AverageC / (MapSRC->SX)) / MapSRC->SY;
}
void MAPTYPECALL(_2_MAP)(MAPTYPE *MapSRC,MAP *MapDST,u32 Shift)
{
PIXELMAPTYPE *SRC;
s32 *LAST,*DST;
DST = MapDST->GetBase();
SRC = MapSRC->GetBase();
u32 SizeYMAX,SizeXMAX;
SizeYMAX = MapSRC->SY < MapDST->SY ? MapSRC->SY : MapDST->SY ;
SizeXMAX = MapSRC->SX < MapDST->SX ? MapSRC->SX : MapDST->SX ;
for (u32 SizeY = 0; SizeY < SizeYMAX;SizeY ++)
{
LAST = DST + SizeXMAX;
while (DST < LAST)
{
s32 A;
A = *(SRC);
if (A > 255) A = 255;
if (A < 0) A = 0;
*(DST) &= ~(((u32)0xff)<<Shift);
*(DST) |= (((u32)A)<<Shift);
DST++;
SRC++;
}
/*
*(DST - 1) = 0xffffffff;
LAST = DST + (MapDST->SX>>1);
while (DST < LAST)
{
u32 A;
A = ((*(DST) & 0xff0000) + ((*(DST) & 0xff00)<<9) + ((*(DST) & 0xff)<<16))>>(18);
*(DST) = 0;
*(DST) = ((u32)A);
*(DST) |= A<<8;
*(DST) |= A<<16;
DST++;
SRC++;
}*/
SRC+=MapSRC->PITCH-SizeXMAX;
DST+=MapDST->PITCH-SizeXMAX;
}
}
void MAPTYPECALL(_DX)(MAPTYPE *MapSRC)
{
PIXELMAPTYPE *SRC,*LAST;
SRC = MapSRC->GetBase();
for (u32 SizeY = 0; SizeY < MapSRC->SY;SizeY ++)
{
PIXELMAPTYPE S,Swap;
LAST = SRC + MapSRC->SX - 1;
S = *(SRC++);
while (SRC < LAST)
{
Swap = *(SRC);
*(SRC) = *(SRC + 1) - S;
S = Swap;
SRC++;
}
SRC+=1+MapSRC->PITCH-MapSRC->SX;
}
}
void MAPTYPECALL(_DY)(MAPTYPE *MapSRC)
{
PIXELMAPTYPE *SRC,*LAST,*pSTOCK;
PIXELMAPTYPE STOCK[1024];
SRC = MapSRC->GetBase();
pSTOCK = STOCK;
LAST = SRC + MapSRC->SX;
while (SRC < LAST) *(pSTOCK++) = *(SRC++);
for (u32 SizeY = 1; SizeY < MapSRC->SY - 1;SizeY ++)
{
LAST = SRC + MapSRC->SX;
pSTOCK = STOCK;
while (SRC < LAST)
{
PIXELMAPTYPE Swap;
Swap = *pSTOCK;
*pSTOCK = *(SRC);
*(SRC) = *(SRC + MapSRC->PITCH) -Swap;
SRC++;
pSTOCK++;
}
SRC+=MapSRC->PITCH-MapSRC->SX;
}
}
void MAPTYPECALL(_XO2)(MAPTYPE *MapDST)
{
PIXELMAPTYPE *SRC,*DST,*LAST;
DST = MapDST->GetBase() ;
for (u32 SizeY = 0; SizeY < MapDST->SY;SizeY ++)
{
LAST = DST + MapDST->SX;
SRC = DST;
while (DST < LAST)
{
*SRC = (*(DST) + (*(DST+1)))>>1;
SRC++;
DST+=2;
}
while (SRC < LAST)
{
*SRC = 0;
SRC++;
}
DST+=MapDST->PITCH-MapDST->SX;
}
}
void MAPTYPECALL(_XE2)(MAPTYPE *MapDST)
{
PIXELMAPTYPE *SRC,*DST,*LAST;
DST = MapDST->GetBase() ;
for (u32 SizeY = 0; SizeY < MapDST->SY;SizeY ++)
{
LAST = DST + MapDST->SX;
SRC = DST + (MapDST->SX>>1);
while (DST < LAST)
{
LAST-=2;
SRC--;
*LAST = *SRC;
*(LAST+1) = (*SRC + *(SRC+1))>>1;
}
DST+=MapDST->PITCH;
}
}
void MAPTYPECALL(_YO2)(MAPTYPE *MapDST)
{
PIXELMAPTYPE *SRC,*DST,*LAST;
SRC = DST = MapDST->GetBase() ;
for (u32 SizeY = 0; SizeY < MapDST->SY>>1;SizeY ++)
{
LAST = DST + MapDST->SX;
while (DST < LAST)
{
*DST = (*(SRC) + (*(SRC+MapDST->PITCH)))>>1;
SRC++;
DST++;
}
DST+= MapDST->PITCH-MapDST->SX;
SRC+= MapDST->PITCH-MapDST->SX;
SRC+= MapDST->PITCH;
}
}
void MAPTYPECALL(_YE2)(MAPTYPE *MapDST)
{
PIXELMAPTYPE *SRC,*DST,*LAST;
for (s32 SizeY = 0; SizeY < MapDST->SY>>1;SizeY ++)
{
SRC = MapDST->GetBase() + MapDST->PITCH * SizeY;
DST = MapDST->GetBase() + MapDST->PITCH * (SizeY + (MapDST->SY>>1));
LAST = DST + MapDST->SX;
while (DST < LAST)
{
*DST = *(SRC);
SRC++;
DST++;
}
}
for (s32 SizeY = 0; SizeY < MapDST->SY>>1;SizeY ++)
{
SRC = MapDST->GetBase() + MapDST->PITCH * (SizeY<<1);
DST = MapDST->GetBase() + MapDST->PITCH * (SizeY + (MapDST->SY>>1));
LAST = DST + MapDST->SX;
while (DST < LAST)
{
*SRC = *DST;
SRC++;
DST++;
}
DST -= MapDST->SX;
SRC += MapDST->PITCH - MapDST->SX;
LAST = DST + MapDST->SX;
if (SizeY+1 == MapDST->SY>>1)
while (DST < LAST)
{
*SRC = *(DST);
SRC++;
DST++;
}//*/
else
while (DST < LAST)
{
*SRC = (*(DST) + *(DST+MapDST->PITCH))>>1;
SRC++;
DST++;
}//*/
}
}
void MAPTYPECALL(_XOffset)(MAPTYPE *MapDST,s32 offset)
{
PIXELMAPTYPE *SRC,*DST,*LAST;
DST = MapDST->GetBase() ;
for (u32 SizeY = 0; SizeY < MapDST->SY;SizeY ++)
{
LAST = DST + MapDST->SX;
SRC = DST;
if (offset > 0)
DST += offset;
else
{
SRC -= offset;
LAST -= offset;
}
while (DST < LAST)
{
*SRC = *(DST);
SRC++;
DST++;
}
if (offset < 0)
DST -= offset;
DST+=MapDST->PITCH-MapDST->SX;
}
}
void MAPTYPECALL(_HalfXOffset)(MAPTYPE *MapDST)
{
PIXELMAPTYPE *SRC,*DST,*LAST;
DST = MapDST->GetBase() ;
for (u32 SizeY = 0; SizeY < MapDST->SY;SizeY ++)
{
LAST = DST + MapDST->SX;
SRC = DST;
DST += MapDST->SX>>1;
while (DST < LAST)
{
PIXELMAPTYPE Swap;
Swap = *SRC;
*SRC = *DST;
*DST = Swap;
SRC++;
DST++;
}
DST+=MapDST->PITCH-MapDST->SX;
}
}
void MAPTYPECALL(_FLIP_H)(MAPTYPE *MapDST)
{
PIXELMAPTYPE *LAST,*DST,*DST2;
/* MM H */
for (u32 SizeY = 0; SizeY < MapDST->SY;SizeY ++)
{
DST = MapDST->GetBase() + SizeY * MapDST->PITCH;
DST2 = DST + MapDST->SX ;
while (DST < DST2)
{
PIXELMAPTYPE SWAP;
DST2--;
SWAP = *(DST);
*(DST) = *(DST2);
*(DST2) = SWAP;
DST++;
}
}
}
void MAPTYPECALL(_FLIP_V)(MAPTYPE *MapDST)
{
PIXELMAPTYPE *LAST,*DST,*DST2;
/* MM H */
for (u32 SizeY = 0; SizeY < MapDST->SY>>1;SizeY ++)
{
DST = MapDST->GetBase() + SizeY * MapDST->PITCH;
LAST = DST + MapDST->SX;
DST2 = MapDST->GetBase() + (MapDST->SY - SizeY - 1) * MapDST->PITCH;
while (DST < LAST)
{
PIXELMAPTYPE SWAP;
SWAP = *(DST);
*(DST) = *(DST2);
*(DST2) = SWAP;
DST++;
DST2++;
}
}
}
void MAPTYPECALL(_CopyFlipV)(MAPTYPE *MapSRC,MAPTYPE *MapDST)
{
PIXELMAPTYPE *LAST,*DST,*SRC;
/* MM H */
DST = MapDST->GetBase() + (MapDST->SY-1) * MapDST->PITCH;
SRC = MapSRC->GetBase();
for (u32 SizeY = 0; SizeY < MapDST->SY;SizeY ++)
{
LAST = DST + MapDST->SX;
while (DST < LAST)
{
*DST = *SRC;
DST++;
SRC++;
}
DST -= MapDST->SX;
DST -= MapDST->PITCH;
SRC += MapSRC->PITCH - MapSRC->SX;
}
}
void MAPTYPECALL(_CopyFlipH)(MAPTYPE *MapSRC,MAPTYPE *MapDST)
{
PIXELMAPTYPE *LAST,*DST,*SRC;
/* MM H */
DST = MapDST->GetBase();
SRC = MapSRC->GetBase();
for (u32 SizeY = 0; SizeY < MapDST->SY;SizeY ++)
{
LAST = DST + MapDST->SX;
while (DST < LAST)
{
LAST--;
*LAST = *SRC;
SRC++;
}
DST += MapDST->PITCH;
SRC += MapSRC->PITCH - MapSRC->SX;
}
}
void MAPTYPECALL(_BLUR_CopyTransposeFAST)(MAPTYPE *pSrc,MAPTYPE *pDst)
{
MAPTYPECALL(_Copy)(pSrc,pDst);
MAPTYPECALL(_BLUR_TransposeFAST)(pDst);
}
void MAPTYPECALL(_Copy_O2)(MAPTYPE *MapSRC,MAPTYPE *MapDST)
{
PIXELMAPTYPE *LAST,*DST,*SRC,*SRC2;
SRC = MapSRC->GetBase();
for (u32 SizeY = 0; SizeY < MapSRC->SY;SizeY += 2)
{
DST = MapDST->GetBase() + (SizeY>>1) * MapDST->PITCH;
LAST = SRC + MapSRC->SX;
SRC2 = SRC + MapSRC->PITCH;
while (SRC < LAST)
{
*(DST++) = (*(SRC) + *(SRC + 1) + *(SRC2) + *(SRC2 + 1))>>2;
SRC += 2;
SRC2 += 2;
}
*(DST) = *(DST-1);
SRC+=(MapSRC->PITCH-MapSRC->SX);
SRC+= MapSRC->PITCH;
}
/* LAST = DST + (MapSRC->SX>>1);
while (DST < LAST)
{
*(DST) = *(DST-MapDST->PITCH);
DST++;
}
*(DST) = *(DST-1);*/
}
void MAPTYPECALL(_BLUR_ScissorX_Inplace)(MAPTYPE *pSrc,s32 FactorX,s32 InvertOrigin)
{
PIXELMAPTYPE *pCrnt,*pLast;
float Inc,Base;
pCrnt = pSrc->GetBase();
pLast = pCrnt + pSrc->PITCH * pSrc->SY;
Base = 0.0f;
Inc = (float)FactorX / (float)pSrc->SY;
if (InvertOrigin)
{
Inc = -Inc;
Base = (float)FactorX;
Base += Inc;
}
while (pCrnt < pLast)
{
MAPTYPECALL(_ShiftLine)(pCrnt,(s32)Base,pSrc->SX);
Base+=Inc;
pCrnt+=pSrc->PITCH;
}
}
void MAPTYPECALL(_PostFilter_H)(MAPTYPE *MapSRC)
{
PIXELMAPTYPE *LAST,*SRC;
s32 *DST;
s32 Accum[2048];
/* MM H */
#define POWERACC_SHIFT 0
#define POWERACC() CurrentV += ((s32)*SRC) << POWERACC_SHIFT;
#define POWERDEC() {CurrentV /= 3.0;};
#define POWERAFFECT() {*SRC = (PIXELMAPTYPE)((((s32)*SRC)<<0) - (*DST>>POWERACC_SHIFT-0));}
for (u32 SizeY = 0; SizeY < MapSRC->SY ;SizeY ++)
{
s32 CurrentV;
DST = Accum;
SRC = MapSRC->GetBase()+SizeY*MapSRC->PITCH;
LAST = SRC + MapSRC->SX;
memset(DST, 0 , sizeof(Accum[0]) * (MapSRC->SX+1));
CurrentV = 0;
while (SRC < LAST)
{
POWERACC();
POWERDEC();
*DST += CurrentV;
SRC++;
DST++;
}
SRC -= MapSRC->SX;
DST -= MapSRC->SX;
while (SRC < LAST)
{
POWERDEC();
*DST += CurrentV;
SRC++;
DST++;
}
CurrentV = 0;
LAST -= MapSRC->SX;
while (SRC > LAST)
{
SRC--;
DST--;
POWERACC();
POWERDEC();
*DST += CurrentV;
}
SRC += MapSRC->SX;
DST += MapSRC->SX;
while (SRC > LAST)
{
SRC--;
DST--;
POWERDEC();
*DST += CurrentV;
}
LAST += MapSRC->SX;
while (SRC < LAST)
{
POWERAFFECT();
SRC++;
DST++;
}
SRC = MapSRC->GetBase()+SizeY*MapSRC->PITCH;
SRC[0] = 0;
SRC[1] = 0;
SRC[2] = 0;
SRC[3] = 0;
SRC[MapSRC->SX-1] = 0;
SRC[MapSRC->SX-2] = 0;
SRC[MapSRC->SX-3] = 0;
SRC[MapSRC->SX-4] = 0;
}
}
#ifndef MAP16_METACALL
#define MAP16_METACALL
#include "MAP16.CPP"
#endif