984 lines
No EOL
25 KiB
C++
984 lines
No EOL
25 KiB
C++
|
|
#include "SCENE.h"
|
|
#define FastPatchReader_H
|
|
#include "FastPatchAnnalysis.cpp"
|
|
|
|
//#pragma optimize("",off)
|
|
#define MAPCOMP_R 3
|
|
#define MAPCOMP (MAPCOMP_R * 2 + 1)
|
|
s32 MAP1[MAPCOMP * MAPCOMP];
|
|
s32 MAP2[MAPCOMP * MAPCOMP];
|
|
s32 MAP3[MAPCOMP * MAPCOMP];
|
|
s32 MAP1_B[MAPCOMP * MAPCOMP];
|
|
s32 MAP2_B[MAPCOMP * MAPCOMP];
|
|
s32 MAP3_B[MAPCOMP * MAPCOMP];
|
|
double LastRot90 = 0;
|
|
double LastNorm = 0;
|
|
int Prs[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
|
|
|
|
|
|
|
float Histogrammm_Pos[16];
|
|
float Histogrammm_Neg[16];
|
|
void MAP32_PowerBLUR_XY(MAP *pSrc,MAP *pTmp,u8 Alpha, u32 Power, u32 Iteration);
|
|
void MAP32_Rotate(MAP *pSrc,MAP *pDst,u32 Alpha);
|
|
//void DrawCross(MAP *image, POINT p, u32 color, int len, char orient = 3);
|
|
void MAP32_PowerBlur_ParraMap(MAP *MapSRC,MAP *MapTmp,MAP8 *MapParram,u32 Iterations);
|
|
void MAP32_PowerBlur_H(MAP *MapSRC,s32 Power);
|
|
void MAP32_PowerBlur_V(MAP *MapSRC,MAP *MapTmp,s32 Power,u32 Iterations);
|
|
void MAP32_PowerBlur_Denoise(MAP *MapSRC,MAP *MapTmp,u32 Power,u32 Iterations);
|
|
void MAP32_PowerBlur_Denoise_XY(MAP *pSrc,MAP *pTmp,u8 Alpha, u32 Power, u32 Iteration);
|
|
void MAP32_XE2(MAP *MapDST);
|
|
void MAP32_YE2(MAP *MapDST);
|
|
|
|
typedef struct Point_
|
|
{
|
|
s32 X,Y;
|
|
float Strenght;
|
|
} Point;
|
|
|
|
void MAP32_X_BLUR_XY(MAP *pSrc,MAP *pTmp,u8 Alpha, u32 Power,
|
|
void CALLBACK_Blur_H(MAP *MapSRC,s32 Power)
|
|
);
|
|
|
|
void TEST_MAX_V(MAP *MapSRC)
|
|
|
|
{
|
|
s32 *LAST,*SRC;
|
|
s32 *DST;
|
|
for (u32 SizeY = 0; SizeY < MapSRC->SY ;SizeY ++)
|
|
{
|
|
s32 CurrentV;
|
|
DST = NULL;
|
|
SRC = MapSRC->GetBase()+SizeY*MapSRC->PITCH;
|
|
LAST = SRC + MapSRC->SX;
|
|
CurrentV = *(SRC);
|
|
while (SRC < LAST)
|
|
{
|
|
*DST = CurrentV;
|
|
SRC++;
|
|
DST++;
|
|
}
|
|
SRC = MapSRC->GetBase()+SizeY*MapSRC->PITCH;
|
|
}
|
|
}
|
|
s32 TTTTERERER[1024*1024];
|
|
void TEST_PowerBlur_H(MAP *MapSRC,s32 u32Power)
|
|
|
|
{
|
|
float Power = (float)u32Power / 256.0f;
|
|
s32 *LAST,*SRC;
|
|
float *DST;
|
|
float OneMinusPower = 1.0f - Power;
|
|
float Accum[2048];
|
|
float Accum2[2048];
|
|
static s32 FactorK = 120;
|
|
static s32 FactorKShift = 5;
|
|
float Power2 = Power *0.25f;
|
|
/*
|
|
|
|
MAP Scnd,Scnd2;
|
|
Scnd2 = Scnd = *MapSRC;
|
|
Scnd.BASE = TTTTERERER;
|
|
Scnd2.BASE = TTTTERERER + Scnd2.PITCH * Scnd2.SY;
|
|
MAP32_Copy(MapSRC,&Scnd);
|
|
MAP32_PowerBlur_V(&Scnd,&Scnd2,Prs[17],4);
|
|
MAP32_Sub(&Scnd,MapSRC);
|
|
|
|
/*MAP32_Copy(MapSRC,&Scnd);
|
|
MAP32_PowerBlur_V(&Scnd,&Scnd2,50,2);
|
|
MAP32_Sub(&Scnd,MapSRC);*/
|
|
|
|
/*MAP Scnd;
|
|
Scnd = *MapSRC;
|
|
Scnd.BASE = TTTTERERER;
|
|
//MAP32_Shift(MapSRC,-4);
|
|
MAP32_Copy(MapSRC,&Scnd);
|
|
MAP32_BLUR_H_Inplace(&Scnd,2);
|
|
MAP32_BLUR_H_Inplace(&Scnd,2);
|
|
MAP32_BLUR_H_Inplace(&Scnd,2);
|
|
MAP32_BLUR_H_Inplace(&Scnd,2);
|
|
MAP32_BLUR_H_Inplace(&Scnd,2);
|
|
MAP32_Sub(&Scnd,MapSRC);
|
|
//MAP32_Shift(MapSRC,-8);
|
|
MAP32_Copy(MapSRC,&Scnd);
|
|
MAP32_BLUR_V_Inplace(&Scnd,1);
|
|
MAP32_BLUR_V_Inplace(&Scnd,1);
|
|
MAP32_BLUR_V_Inplace(&Scnd,1);
|
|
// MAP32_Sqr(&Scnd);
|
|
MAP32_Sub(&Scnd,MapSRC);
|
|
//MAP32_Abs(MapSRC);
|
|
return;//*/
|
|
|
|
|
|
for (u32 SizeY = 0; SizeY < MapSRC->SY ;SizeY ++)
|
|
{
|
|
u32 rEPEAT =2;
|
|
s32 K;
|
|
while (rEPEAT --)
|
|
{
|
|
float CurrentV;
|
|
float CurrentV2,CurrentV3;
|
|
u32 Tenia = 0;
|
|
|
|
DST = Accum;
|
|
SRC = MapSRC->GetBase()+SizeY*MapSRC->PITCH;
|
|
LAST = SRC + MapSRC->SX;
|
|
memset(DST, 0 , sizeof(Accum[0]) * (MapSRC->SX+1));
|
|
CurrentV3 = CurrentV2 = CurrentV = *(SRC);
|
|
CurrentV3 = CurrentV2 = 0;
|
|
while (SRC < LAST)
|
|
{
|
|
float Source = ((s32)*SRC);
|
|
CurrentV = (CurrentV * Power) + (Source * (1.0f-Power));
|
|
CurrentV3 = (CurrentV3 * Power2) + (Source * (1.0f-Power2));
|
|
CurrentV2 = (CurrentV2 * Power2) + (Source * Source * (1.0f-Power2));
|
|
//CurrentV2 = CurrentV;
|
|
s32 Res = CurrentV;
|
|
float Fouck = CurrentV2 - CurrentV3 * CurrentV3;
|
|
//if (!rEPEAT)
|
|
{
|
|
K = 0;
|
|
if (Fouck > 0)
|
|
K = sqrtf(CurrentV2 - CurrentV3 * CurrentV3)/ 0.75f;
|
|
|
|
|
|
if (abs(CurrentV) > K)
|
|
{
|
|
if (CurrentV > 0) CurrentV -= K;
|
|
else CurrentV += K;
|
|
} else
|
|
Res = 0;
|
|
}
|
|
|
|
if ((!rEPEAT) && (abs(Res) < Prs[7]<<1)) Res = 0;
|
|
|
|
*DST = Res;
|
|
|
|
|
|
SRC++;
|
|
DST++;
|
|
}
|
|
CurrentV3 = CurrentV2 = CurrentV = *(SRC-1);
|
|
CurrentV3 = CurrentV2 = 0;
|
|
LAST -= MapSRC->SX;
|
|
Tenia = 0;
|
|
while (SRC > LAST)
|
|
{
|
|
SRC--;
|
|
DST--;
|
|
float Source = ((s32)*SRC);
|
|
CurrentV = (CurrentV * Power) + (Source * (1.0f-Power));
|
|
CurrentV3 = (CurrentV3 * Power2) + (Source * (1.0f-Power2));
|
|
CurrentV2 = (CurrentV2 * Power2) + (Source * Source * (1.0f-Power2));
|
|
//CurrentV2 = CurrentV;
|
|
s32 Res = CurrentV;
|
|
float Fouck = CurrentV2 - CurrentV3 * CurrentV3;
|
|
//if (!rEPEAT)
|
|
{
|
|
K = 0;
|
|
if (Fouck > 0)
|
|
K = sqrtf(CurrentV2 - CurrentV3 * CurrentV3)/ 0.75f;
|
|
|
|
|
|
if (abs(CurrentV) > K)
|
|
{
|
|
if (CurrentV > 0) CurrentV -= K;
|
|
else CurrentV += K;
|
|
} else Res = 0;
|
|
}
|
|
|
|
|
|
if ((!rEPEAT) && (abs(Res) < Prs[7]<<1)) Res = 0;
|
|
|
|
|
|
Res += *DST;
|
|
*SRC = Res>>1;
|
|
|
|
}
|
|
SRC = MapSRC->GetBase()+SizeY*MapSRC->PITCH;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
_inline u32 AndAutoRotate(u32 Value,u32 Shift)
|
|
{
|
|
u32 V2;
|
|
V2 = (Value>>Shift) + (Value<<(32-Shift));
|
|
return V2 & Value;
|
|
}
|
|
|
|
void MAP32_OrCross(MAP *MapSRC,MAP *MapDST)
|
|
{
|
|
s32 *LAST,*DST,*SRC;
|
|
for (u32 SizeY = 2; SizeY < MapSRC->SY - 2;SizeY ++)
|
|
{
|
|
SRC = MapSRC->GetBase() + SizeY * MapSRC->PITCH + 2;
|
|
DST = MapDST->GetBase() + SizeY * MapDST->PITCH + 2;
|
|
LAST = SRC + MapSRC->SX - 2 * 2;
|
|
while (SRC < LAST)
|
|
{
|
|
*DST = *(SRC+1);
|
|
*DST |= *(SRC-1);
|
|
*DST |= *(SRC+MapSRC->PITCH);
|
|
*DST |= *(SRC-MapSRC->PITCH);
|
|
*DST |= *SRC;
|
|
SRC++;
|
|
DST++;
|
|
}
|
|
}
|
|
}
|
|
|
|
#define NUMBER_OF_PASSES 1
|
|
#define THRESHOLD_TOL 2
|
|
#define Step_X 20
|
|
#define Step_Y 20
|
|
#define PoinStep 5
|
|
|
|
#define GVS 2
|
|
s32 GAUSSIANMAP[GVS * GVS];
|
|
|
|
void TEST_SETWORKINGPARRAMS(int *P,int num)
|
|
{
|
|
memcpy(Prs,P,num * 4);
|
|
}
|
|
|
|
|
|
void MAP_ComputeGHuaussianKernel(s32 *pDst,s32 Pitch)
|
|
{
|
|
static u32 Init = 0;
|
|
if (!Init)
|
|
{
|
|
Init = 1;
|
|
memset(GAUSSIANMAP,0xff,sizeof(GAUSSIANMAP));
|
|
for (int X = 0 ; X < GVS ; X++)
|
|
for (int Y = 0 ; Y < GVS ; Y++)
|
|
{
|
|
float R = (X - (GVS/2)) * (X - (GVS/2)) + (Y - (GVS/2)) * (Y - (GVS/2));
|
|
R = sqrt(R)*0.75;
|
|
if (R > GVS / 2)
|
|
R = GVS / 2;
|
|
R = (GVS / 2 - R) / (GVS / 2);
|
|
R = 2 * R * R * R - 3 * R * R + 1;
|
|
//R *= R;
|
|
GAUSSIANMAP[X + Y * GVS] = R * 255;
|
|
}
|
|
}
|
|
s32 *GuaussianPtr;
|
|
memset(GAUSSIANMAP,0,sizeof(GAUSSIANMAP));
|
|
pDst -= Pitch * Step_Y/2 + Step_X/2;
|
|
GuaussianPtr = GAUSSIANMAP;
|
|
for (int Y = 0 ; Y < Step_X ; Y++)
|
|
{
|
|
for (int X = 0 ; X < Step_Y ; X++)
|
|
{
|
|
*pDst = 0;//(*pDst * *GuaussianPtr)>>8;
|
|
pDst++;
|
|
GuaussianPtr++;
|
|
}
|
|
pDst -= GVS;
|
|
pDst += Pitch;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
float GetSymmetryFactor(s32 *Pixel,s32 PITCH,u32 BX)
|
|
{
|
|
static u32 Init = 0;
|
|
float fMin = 1000000000,fMax = -10000000000;
|
|
for (int X = -MAPCOMP_R ; X <= MAPCOMP_R ; X++ )
|
|
for (int Y = -MAPCOMP_R ; Y <= MAPCOMP_R ; Y++ )
|
|
{
|
|
s32 ZZ1 = Pixel[X + Y * PITCH];
|
|
s32 ZZ2 = Pixel[X+1 + Y * PITCH];
|
|
s32 ZZ3 = Pixel[X + (Y+1) * PITCH];
|
|
s32 ZZ4 = Pixel[X+1 + (Y+1) * PITCH];
|
|
s32 ZZ = ZZ1;
|
|
if (BX == 1) ZZ = (ZZ1 + ZZ2) / 2;
|
|
if (BX == 2) ZZ = (ZZ1 + ZZ3) / 2;
|
|
if (BX == 3) ZZ = (ZZ1 + ZZ2 + ZZ3 + ZZ4) / 4;
|
|
if (ZZ > fMax)fMax=ZZ;
|
|
if (ZZ < fMin)fMin=ZZ;
|
|
MAP1[X + MAPCOMP_R + (Y + MAPCOMP_R) * MAPCOMP] = ZZ;
|
|
MAP2[-X + MAPCOMP_R + (-Y + MAPCOMP_R) * MAPCOMP] = ZZ;
|
|
MAP3[Y + MAPCOMP_R + (-X + MAPCOMP_R) * MAPCOMP] = ZZ;
|
|
}
|
|
double Sqrp = 0;
|
|
double DotProduct = 0;
|
|
LastRot90 = 0;
|
|
|
|
for (int X = 0; X < MAPCOMP * MAPCOMP; X++ )
|
|
{
|
|
DotProduct += (double)MAP1[X] * (double)MAP2[X];
|
|
LastRot90 += (double)MAP1[X] * (double)MAP3[X];
|
|
Sqrp += (double)MAP1[X] * (double)MAP1[X];
|
|
}
|
|
LastNorm = sqrt(Sqrp) / (MAPCOMP * MAPCOMP);
|
|
Sqrp = 1.0f/ Sqrp;
|
|
LastRot90 *= Sqrp;
|
|
DotProduct *= Sqrp;
|
|
|
|
//LastNorm = fMax - fMin;
|
|
//LastRot90 = abs(LastRot90);
|
|
LastRot90 = 0;
|
|
//DotProduct = 1.0f;
|
|
return (DotProduct);
|
|
}
|
|
float GetSymmetryFactor(s32 *Pixel,s32 PITCH)
|
|
{
|
|
float SF1,SF = GetSymmetryFactor(Pixel,PITCH,0);
|
|
float Best90 = LastRot90;
|
|
SF1 = GetSymmetryFactor(Pixel,PITCH,1);
|
|
if (LastRot90 > Best90) {Best90 = LastRot90;};if (SF1*SF1 > SF * SF) {SF = SF1;};
|
|
SF1 = GetSymmetryFactor(Pixel,PITCH,2);
|
|
if (LastRot90 > Best90) {Best90 = LastRot90;};if (SF1*SF1 > SF * SF) {SF = SF1;};
|
|
SF1 = GetSymmetryFactor(Pixel,PITCH,3);
|
|
if (LastRot90 > Best90) {Best90 = LastRot90;};if (SF1*SF1 > SF * SF) {SF = SF1;};
|
|
|
|
Best90 = LastRot90;
|
|
|
|
return SF;
|
|
}
|
|
|
|
|
|
|
|
void POINTILLIZE(MAP *CurrentMap,MAP *FeatureMap,MAP *SymmetryMap)
|
|
{
|
|
//MAP32_Abs(FeatureMap);
|
|
MAP32_And(CurrentMap,0xfcfcfc);
|
|
MAP32_Shift(CurrentMap,-0);//*/
|
|
|
|
//if (!Init) MAP_ComputeGHuaussianKernel(MAP *pDst)
|
|
|
|
|
|
for (int Iter = 0 ; Iter < NUMBER_OF_PASSES ; Iter++)
|
|
{
|
|
|
|
MAP32_And(CurrentMap,0xfcfcfc);
|
|
for (int Y = Step_Y + 3; Y < FeatureMap->SY-Step_Y -1-3; Y+=PoinStep)
|
|
for (int X = Step_X + 3; X < FeatureMap->SX-Step_X-1-3 ; X+=PoinStep)
|
|
{
|
|
s32 *MninmmPoke = &FeatureMap->GetBase()[X + Y * FeatureMap->PITCH];
|
|
s32 *MninmmCLR = &CurrentMap->GetBase()[X + Y * CurrentMap->PITCH];
|
|
s32 Ditance_X = 1000;
|
|
s32 Ditance_Y = 1000;
|
|
for (int XS = -Step_X+1; XS < Step_X ; XS ++)
|
|
for (int YS = -Step_Y+1; YS < Step_Y ; YS ++)
|
|
{
|
|
if (FeatureMap->GetBase()[X + XS + (Y + YS) * FeatureMap->PITCH] > *MninmmPoke)
|
|
{
|
|
Ditance_X = abs(XS);
|
|
Ditance_Y = abs(YS);
|
|
|
|
MninmmPoke = &FeatureMap->GetBase()[X + XS + (Y + YS) * FeatureMap->PITCH];
|
|
MninmmCLR = &CurrentMap->GetBase()[X + XS + (Y + YS) * CurrentMap->PITCH];
|
|
}
|
|
}
|
|
|
|
if ((Ditance_Y < Step_Y-6) && (Ditance_X > Step_X-6))
|
|
{
|
|
/*s32 Value =
|
|
MninmmPoke[0] * 4 +
|
|
MninmmPoke[-1] + MninmmPoke[1] +
|
|
MninmmPoke[FeatureMap->PITCH] + MninmmPoke[-FeatureMap->PITCH] +
|
|
MninmmPoke[1+FeatureMap->PITCH] + MninmmPoke[1-FeatureMap->PITCH] +
|
|
MninmmPoke[-1+FeatureMap->PITCH] + MninmmPoke[-1-FeatureMap->PITCH] ;
|
|
|
|
if (Value > 400)//*/
|
|
{
|
|
if ((*MninmmCLR & 0xffff00 )== 0xff0000)
|
|
*MninmmCLR = *MninmmCLR + 1;
|
|
else
|
|
*MninmmCLR = 0xff0001;
|
|
}
|
|
}
|
|
|
|
}
|
|
for (int Y = 0; Y < FeatureMap->SY; Y++)
|
|
for (int X = 0 ; X < FeatureMap->SX ; X++)
|
|
{
|
|
s32 *MninmmCLR = &CurrentMap->GetBase()[X + Y * CurrentMap->PITCH];
|
|
if ((*MninmmCLR & 0xffff00) == 0xff0000)
|
|
{
|
|
if ((*MninmmCLR & 0xff) > THRESHOLD_TOL)
|
|
*MninmmCLR = 0xff00ff;
|
|
else
|
|
*MninmmCLR = 0;
|
|
}
|
|
}
|
|
for (int Y = 1; Y < FeatureMap->SY-1; Y++)
|
|
for (int X = 1 ; X < FeatureMap->SX-1 ; X++)
|
|
{
|
|
s32 *MninmmCLR = &CurrentMap->GetBase()[X + Y * CurrentMap->PITCH];
|
|
|
|
if (MninmmCLR[0] == 0xff00ff)
|
|
{
|
|
*MninmmCLR = 0xff0000;
|
|
}
|
|
}
|
|
#define SECURE_1 16
|
|
//if (0)
|
|
for (int Y = SECURE_1; Y < FeatureMap->SY-SECURE_1; Y++)
|
|
for (int X = SECURE_1 ; X < FeatureMap->SX-SECURE_1 ; X++)
|
|
{
|
|
s32 *MninmmCLR = &CurrentMap->GetBase()[X + Y * CurrentMap->PITCH];
|
|
if ((MninmmCLR[0] & 0xff0000) == 0xff0000)
|
|
{
|
|
|
|
|
|
|
|
|
|
POINT p;
|
|
p.x = X;
|
|
p.y = Y;
|
|
|
|
DrawCross(CurrentMap, p, MninmmCLR[0] & 0xfefefefe, 3);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
typedef struct info_
|
|
{
|
|
int moyenne;
|
|
int somme;
|
|
} info;
|
|
s32 Bittos[2048*1024];
|
|
s32 Bittos2[2048*1024];
|
|
|
|
void MAP32_Sqr2(MAP *CurrentMap)
|
|
{
|
|
for (int X = 0 ;X < CurrentMap->SX ; X++)
|
|
for (int Y = 0 ;Y < CurrentMap->SY ; Y++)
|
|
{
|
|
s32 *Ptr = &CurrentMap->GetBase()[X + Y * CurrentMap->PITCH];
|
|
|
|
*Ptr >>= 5;
|
|
if (*Ptr < 0)
|
|
*Ptr = -(*Ptr * *Ptr);
|
|
else
|
|
*Ptr = (*Ptr * *Ptr);
|
|
///*
|
|
//*/
|
|
/*
|
|
*Ptr >>= 2;
|
|
*Ptr = (*Ptr * *Ptr* *Ptr);
|
|
*Ptr >>= 8;
|
|
|
|
//*/
|
|
}
|
|
}
|
|
#ifdef TEST_PHILIPPE
|
|
void MAP32_PowerBlur(MAP *MapSRC,MAP *MapTmp,s32 Power,u32 Iteration);
|
|
void TESTV(MAP *CurrentMap,int CG)
|
|
{
|
|
#if 1
|
|
static u32 Init = 1;
|
|
static u32 Torglaf = 0;
|
|
if (!Prs[0]) return;
|
|
/*FPA_FastHought(CurrentMap->GetBase(),CurrentMap->PITCH);
|
|
return;//*/
|
|
|
|
MAP Test16,Test17,Test18,Test19,Test20,Test21,Test22,Test23;
|
|
MAP8 Testprm;
|
|
MAP DX,DY;
|
|
Test16.SetBase((s32 *)Bittos2);
|
|
Test16.PITCH = Test16.SX = CurrentMap->SX;
|
|
Test16.SY = CurrentMap->SY;
|
|
Test17 = Test16;
|
|
Test17.SetBase(Test17.GetBase()+Test17.PITCH*Test17.SY);
|
|
Test18 = Test17;
|
|
Test18.SetBase(Test18.GetBase()+Test18.PITCH*Test18.SY);
|
|
DX = Test18;
|
|
DX.SetBase(DX.GetBase()+DX.PITCH*DX.SY);
|
|
DY = DX;
|
|
DY.SetBase(DY.GetBase()+DY.PITCH*DY.SY);
|
|
Test19 = DY;
|
|
Test19.SetBase(Test19.GetBase()+Test19.PITCH*Test19.SY);
|
|
Test20 = Test19;
|
|
Test20.SetBase(Test20.GetBase()+Test20.PITCH*Test20.SY);
|
|
Test21 = Test20;
|
|
Test21.SetBase(Test21.GetBase()+Test21.PITCH*Test21.SY);
|
|
Test22 = Test21;
|
|
Test22.SetBase(Test22.GetBase()+Test22.PITCH*Test22.SY);
|
|
Test23 = Test22;
|
|
Test23.SetBase(Test23.GetBase()+Test23.PITCH*Test23.SY);
|
|
|
|
Testprm.SetBase((u8*)(Test23.GetBase()+Test23.PITCH*Test23.SY));
|
|
Testprm.PITCH = Testprm.SX = CurrentMap->SX;
|
|
Testprm.SY = CurrentMap->SY;
|
|
|
|
/*MAP32_AND(CurrentMap,0xfcfcfcfc);
|
|
MAP32_Copy_O2(CurrentMap,CurrentMap);
|
|
MAP32_AND(CurrentMap,0xfcfcfcfc);
|
|
MAP32_Copy_O2(CurrentMap,CurrentMap);//*/
|
|
|
|
|
|
MAP_2_MAP32(CurrentMap,&Test16,Prs[16]);
|
|
|
|
|
|
//MAP32_BLUR_Inplace(&Test16,2,3);
|
|
|
|
/* MAP_2_MAP32(CurrentMap,&Test16,10);
|
|
Test16.SX = Test16.SY;
|
|
DY.SX = DY.SY;
|
|
static u32 Alpo = 0;
|
|
//MAP32_PowerBLUR_XY(&Test16,&DY,32+((Alpo>>2) & 0x7f),Prs[19],3);
|
|
// MAP32_BLUR_XY(&Test16,&DY,32+((Alpo>>2) & 0x7f),Prs[19],3);
|
|
/*MAP32_Rotate(&Test16,&DY,((Alpo<<4) ));
|
|
//MAP32_Rotate(&Test16,&DY,256-((Alpo>>2) & 0xff));
|
|
//MAP32_Rotate(&Test16,&DY,32+((Alpo>>2) & 0x7f));
|
|
//MAP32_Rotate(&Test16,&DY,32+32+((Alpo>>2) & 0x7f));
|
|
Alpo += 1<<0;
|
|
Alpo &= 0xff;
|
|
MAP32_Shift(&Test16,-8);
|
|
MAP32_2_MAP(&Test16,CurrentMap,0);
|
|
MAP32_2_MAP(&Test16,CurrentMap,8);
|
|
MAP32_2_MAP(&Test16,CurrentMap,16);
|
|
return;
|
|
//*/
|
|
|
|
/*
|
|
step 1 : post pseudo-laplacian
|
|
*/
|
|
MAP32_Copy(&Test16,&Test17);
|
|
MAP32_Copy(&Test16,&Test19);
|
|
/*MAP32_PowerBlur(&Test19,&Test23,Prs[17],1);
|
|
//MAP32_BLUR_Inplace(&Test19,1,3);
|
|
MAP32_Sub(&Test19,&Test16);
|
|
|
|
/*MAP32_Copy(&Test17,&Test19);
|
|
MAP32_PowerBlur(&Test19,&Test23,Prs[18],3);
|
|
MAP32_Sub(&Test19,&Test17);
|
|
//MAP32_Shift(&Test17,-2);
|
|
MAP32_Add(&Test17,&Test16);//*/
|
|
/* DENOISE ***********************************************/
|
|
#if 1
|
|
void MAP32_CopyUnAlias(MAP*pSrc,MAP*pDst);
|
|
void MAP32_CopyReAlias(MAP*pSrc,MAP*pDst);
|
|
|
|
MAP32_Copy(&Test16,&Test19);
|
|
MAP32_Copy(&Test16,&Test17);
|
|
MAP32_MIN_CROSS(&Test17,&Test19);
|
|
MAP32_MIN_CROSS(&Test19,&Test18);
|
|
MAP32_MAX_CROSS(&Test17,&Test19);
|
|
MAP32_MAX_CROSS(&Test19,&Test17);
|
|
MAP32_Sub(&Test18,&Test17);
|
|
|
|
MAP32_BLUR_Inplace(&Test17,1,3);
|
|
|
|
MAP32_Shift(&Test17,-(18-Prs[16]));
|
|
|
|
//MAP32_PowerBlur(&Test16,&Test23,Prs[17],3);
|
|
|
|
s32 *Test17BASE = Test17.GetBase();
|
|
s32 *Test19BASE = Test19.GetBase();
|
|
s32 *Test16BASE = Test16.GetBase();
|
|
s32 *Test21BASE = Test21.GetBase();
|
|
s32 *Test22BASE = Test22.GetBase();
|
|
u8 *TestprmBASE = Testprm.GetBase();
|
|
for (int y = 0 ; y < Testprm.SY;y++)
|
|
for (int x = 0 ; x < Testprm.SX;x++)
|
|
{
|
|
s32 p = 1.9*sqrtf(
|
|
(float)(((int)Testprm.SY>>1) - y) * (float)(((int)Testprm.SY>>1) - y) +
|
|
(float)(((int)Testprm.SX>>1) - x) * (float)(((int)Testprm.SX>>1) - x)*0.1);
|
|
|
|
p+=(p * p)>>8;
|
|
p>>=1;
|
|
u32 Dlta = ((Test17BASE [x+y*Test17.PITCH])*Prs[19])>>4;
|
|
if (Dlta > 256) Dlta = 256;
|
|
p = 256 - Dlta;
|
|
//if (p < 40) p = 40;
|
|
|
|
p=(p * p * p)>>16;
|
|
//p=(p * p)>>8;
|
|
//p>>=1;
|
|
|
|
if (p > 250) p = 250;
|
|
//if (x < Testprm.SX>>1) p = 0;
|
|
TestprmBASE[x+y*Test17.PITCH] = p;
|
|
}
|
|
|
|
|
|
|
|
MAP32_PowerBlur_ParraMap(&Test16,&Test23,&Testprm,1);
|
|
//MAP32_PowerBlur(&Test16,&Test23,100,1);
|
|
|
|
|
|
|
|
|
|
/* MAP32_Shift(&Test16,-(18-Prs[16]));
|
|
//MAP32_Add(&Test16,128);
|
|
MAP32_2_MAP(&Test16,CurrentMap,0);
|
|
MAP32_2_MAP(&Test16,CurrentMap,16);
|
|
MAP32_2_MAP(&Test16,CurrentMap,8);
|
|
return;
|
|
//*/
|
|
|
|
|
|
#endif
|
|
/* DENOISE 0**********************************************/
|
|
#if 1
|
|
|
|
if (Prs[18])
|
|
{
|
|
/* MAP32_XO2(&Test16);
|
|
MAP32_YO2(&Test16);
|
|
MAP32_XO2(&Test16);
|
|
MAP32_YO2(&Test16);*/
|
|
|
|
// MAP32_PowerBlur_Denoise(&Test16,&Test23,Prs[18],8);
|
|
MAP32_Set(&Test19,-65536000);
|
|
u32 Iter = 1;
|
|
|
|
while (Iter--)
|
|
{
|
|
for (int i = Prs[8] ; i < 128 ; i+=Prs[9])
|
|
{
|
|
MAP32_Copy(&Test16,&Test17);
|
|
MAP32_PowerBlur_Denoise_XY(&Test17,&DY,i,Prs[18],1);
|
|
MAP32_PowerBlur_Denoise_XY(&Test17,&DY,i+64,Prs[18],1);
|
|
for (int y = 0 ; y < Test17.SY;y++)
|
|
for (int x = 0 ; x < Test17.SX;x++)
|
|
{
|
|
|
|
if (abs(Test17BASE[x+y*Test17.PITCH]-Test16BASE[x+y*Test16.PITCH]) <
|
|
abs(Test19BASE[x+y*Test19.PITCH]-Test16BASE[x+y*Test16.PITCH]))
|
|
{
|
|
Test19BASE[x+y*Test19.PITCH] = Test17BASE[x+y*Test17.PITCH];
|
|
}
|
|
}//*/
|
|
}
|
|
}
|
|
|
|
MAP32_Copy(&Test19,&Test16);
|
|
|
|
|
|
|
|
|
|
MAP32_Copy(&Test19,&Test16);
|
|
|
|
}
|
|
|
|
MAP32_Shift(&Test16,-(18-Prs[16]));
|
|
//if (Prs[17])MAP32_Add(&Test16,128);
|
|
MAP32_2_MAP(&Test16,CurrentMap,0);
|
|
MAP32_2_MAP(&Test16,CurrentMap,16);
|
|
MAP32_2_MAP(&Test16,CurrentMap,8);
|
|
return;//*/
|
|
#endif
|
|
|
|
|
|
|
|
|
|
//MAP32_Shift(&Test16,-8);
|
|
//MAP32_Add(&Test16,128);*/
|
|
|
|
|
|
/* MAP32_Sqrt(&Test16);
|
|
MAP32_Shift(&Test16,7);
|
|
|
|
/*
|
|
step 2 : Local normalization map
|
|
*/
|
|
/* MAP32_Copy(&Test16,&Test18);
|
|
MAP32_Abs(&Test18);
|
|
/* MAP32_MAX_CROSS(&Test18,&Test19);
|
|
MAP32_MAX_CROSS(&Test19,&Test18);*/
|
|
//MAP32_BLUR_Inplace(&Test18,1,3);
|
|
|
|
/*
|
|
step 3 : get strenght of 18 , sign of 16 and put it in 16
|
|
*/
|
|
/* for (int y = 0 ; y < Test17.SY;y++)
|
|
for (int x = 0 ; x < Test17.SX;x++)
|
|
{
|
|
/* if (Test16.BASE[x+y*Test16.PITCH]>0)
|
|
Test16.BASE[x+y*Test16.PITCH] = -Test18.BASE[x+y*Test18.PITCH];
|
|
else*/
|
|
/*Test16.BASE[x+y*Test16.PITCH] = Test18.BASE[x+y*Test18.PITCH];
|
|
}//*/
|
|
|
|
|
|
/* MAP32_Copy(&Test19,&Test16);
|
|
MAP32_Shift(&Test16,-5);
|
|
//MAP32_Add(&Test16,128);
|
|
MAP32_2_MAP(&Test16,CurrentMap,0);
|
|
MAP32_2_MAP(&Test16,CurrentMap,16);
|
|
MAP32_2_MAP(&Test16,CurrentMap,8);
|
|
return;
|
|
|
|
|
|
//*/
|
|
|
|
/* MAP32_Shift(&Test16,-8);
|
|
MAP32_Copy(&Test16,&Test19);
|
|
MAP32_Sqr(&Test16);
|
|
MAP32_PowerBlur(&Test16,&Test23,Prs[17]);
|
|
MAP32_PowerBlur(&Test19,&Test23,Prs[17]);
|
|
MAP32_Sqr(&Test19);
|
|
MAP32_Sub(&Test19,&Test16);//*/
|
|
|
|
MAP32_Copy(&Test16,&Test19);
|
|
MAP32_PowerBlur(&Test19,&Test23,Prs[17],3);
|
|
MAP32_Sub(&Test19,&Test16);//*/
|
|
/*MAP32_Sqrt(&Test16);
|
|
MAP32_Shift(&Test16,8);
|
|
|
|
//MAP32_Sqrt(&Test16);
|
|
//MAP32_Shift(&Test16,8);
|
|
|
|
/*
|
|
MAP32_Copy(&Test16,&Test19);
|
|
|
|
|
|
MAP32_BLUR_Inplace(&Test19,1,3);
|
|
MAP32_Sub(&Test19,&Test16);//*/
|
|
/*MAP32_Sqrt(&Test16);
|
|
MAP32_Shift(&Test16,8);
|
|
/* MAP32_SmallBlur_FAST(&Test16,&Test19);
|
|
MAP32_Sub(&Test19,&Test16);//*/
|
|
|
|
|
|
MAP32_Copy(&Test16,&Test21);
|
|
// MAP32_ONLY_ABS(&Test16);
|
|
//MAP32_Sqr(&Test16);
|
|
/*MAP32_Shift(&Test16,10);
|
|
MAP32_Sqrt(&Test16);//*/
|
|
/*
|
|
for (int y = 02 ; y < Test17.SY;y++)
|
|
for (int x = 0 ; x < Test17.SX;x++)
|
|
{
|
|
if (Test16.BASE[x+y*Test17.PITCH]>0)
|
|
{
|
|
Test16.BASE[x+y*Test17.PITCH]>>=4;
|
|
Test16.BASE[x+y*Test17.PITCH] *= Prs[22];
|
|
}
|
|
if (Test21.BASE[x+y*Test21.PITCH]<0)
|
|
{
|
|
Test21.BASE[x+y*Test17.PITCH]>>=4;
|
|
Test21.BASE[x+y*Test21.PITCH] *= Prs[22];
|
|
}
|
|
}
|
|
*/
|
|
MAP32_Set(&Test19,0);
|
|
MAP32_Set(&Test20,0);
|
|
MAP32_Set(&Test21,0);
|
|
memset(Histogrammm_Pos,0,sizeof(Histogrammm_Pos));
|
|
memset(Histogrammm_Neg,0,sizeof(Histogrammm_Neg));
|
|
|
|
|
|
int RAdius = 16;
|
|
int XFMi = Test16.SX>>1;
|
|
int YFMi = Test16.SY>>1;
|
|
int XFMa = RAdius*2 + XFMi;
|
|
int YFMa = RAdius*2 + YFMi;
|
|
|
|
u32 BitCounter = 0;
|
|
for (int i = Prs[8] ; i < 128 ; i+=Prs[9])
|
|
{
|
|
MAP32_Copy(&Test16,&Test17);
|
|
//MAP32_PowerBLUR_XY(&Test17,&DY,i,Prs[19],1);
|
|
MAP32_X_BLUR_XY(&Test17,&DY,i,Prs[19],&TEST_PowerBlur_H);
|
|
|
|
for (int y = 0 ; y < Test17.SY;y++)
|
|
for (int x = 0 ; x < Test17.SX;x++)
|
|
{
|
|
if (Test17BASE[x+y*Test17.PITCH]>0)
|
|
{
|
|
Test19BASE[x+y*Test19.PITCH] |= 1<<(((i>>3)<<1)+1);
|
|
}
|
|
if (Test17BASE[x+y*Test17.PITCH]<0)
|
|
{
|
|
Test19BASE[x+y*Test19.PITCH] |= 1<<(((i>>3)<<1));
|
|
}
|
|
Test21BASE[x+y*Test21.PITCH] += Test17BASE[x+y*Test17.PITCH];
|
|
}//*/
|
|
|
|
|
|
|
|
|
|
BitCounter+=2;
|
|
}
|
|
|
|
MAP32_AND(CurrentMap,0xfefefefe);
|
|
|
|
|
|
//MAP32_Shift(&Test21,-4);
|
|
/* MAP32_Copy(&Test21,&Test17);
|
|
MAP32_Sqr(&Test21);
|
|
MAP32_BLUR_Inplace(&Test21,1,3);
|
|
MAP32_BLUR_Inplace(&Test17,1,3);
|
|
MAP32_Sqr(&Test17);
|
|
MAP32_Sub(&Test17,&Test21);
|
|
MAP32_Shift(&Test21,-5);//*/
|
|
/*POINTILLIZE(CurrentMap,&Test21,NULL);
|
|
return;
|
|
//*/
|
|
// MAP32_Copy(&Test16,&Test21);
|
|
MAP32_Shift(&Test21,-8);
|
|
MAP32_Add(&Test21,128);
|
|
MAP32_2_MAP(&Test21,CurrentMap,0);
|
|
MAP32_2_MAP(&Test21,CurrentMap,16);
|
|
MAP32_2_MAP(&Test21,CurrentMap,8);
|
|
return;//*/
|
|
|
|
//MAP32_Shift(CurrentMap,-1);
|
|
//MAP32_Add(CurrentMap,0x808080>>1);
|
|
/* MAP32_AND(CurrentMap,0xfefefefe);
|
|
MAP32_Shift(CurrentMap,-1);
|
|
MAP32_Set(CurrentMap,0x808080);
|
|
/*
|
|
MAP32_OrCross(&Test19,&Test16);
|
|
MAP32_Copy(&Test16,&Test19);
|
|
*/
|
|
|
|
MAP32_Set(CurrentMap,0x808080);
|
|
for (int y = 0 ; y < Test17.SY;y++)
|
|
for (int x = 0 ; x < Test17.SX;x++)
|
|
{
|
|
u32 OldC = Test19BASE[x+y*Test17.PITCH];
|
|
Torglaf += GetBitNumber(Test19BASE[x+y*Test17.PITCH] ^ Test22BASE[x+y*Test17.PITCH]);
|
|
/* Test22.BASE[x+y*Test17.PITCH] = Test19.BASE[x+y*Test17.PITCH] ;
|
|
Test19.BASE[x+y*Test17.PITCH] &= Test22.BASE[x+y*Test17.PITCH];*/
|
|
//CurrentMap->GetBase()[x+y*CurrentMap->PITCH] = 0x808080;
|
|
if (!Test19BASE[x+y*Test17.PITCH])
|
|
CurrentMap->GetBase()[x+y*CurrentMap->PITCH] = 0x808080;
|
|
|
|
if (Test19BASE[x+y*Test17.PITCH])
|
|
{
|
|
if ((Test19BASE[x+y*Test17.PITCH]& 0xAA))
|
|
CurrentMap->GetBase()[x+y*CurrentMap->PITCH] |= 0xff0000;
|
|
if ((Test19BASE[x+y*Test17.PITCH]& 0x55))
|
|
CurrentMap->GetBase()[x+y*CurrentMap->PITCH] &=~0xff0000;
|
|
if ((Test19BASE[x+y*Test17.PITCH]& 0xAA00))
|
|
CurrentMap->GetBase()[x+y*CurrentMap->PITCH] |= 0xff00;
|
|
if ((Test19BASE[x+y*Test17.PITCH]& 0x5500))
|
|
CurrentMap->GetBase()[x+y*CurrentMap->PITCH] &=~0xff00;
|
|
if ((Test19BASE[x+y*Test17.PITCH]& 0xAA0000))
|
|
CurrentMap->GetBase()[x+y*CurrentMap->PITCH] |= 0xff;
|
|
if ((Test19BASE[x+y*Test17.PITCH]& 0x550000))
|
|
CurrentMap->GetBase()[x+y*CurrentMap->PITCH] &=~0xff;
|
|
if ((Test19BASE[x+y*Test17.PITCH]& 0xAA000000))
|
|
CurrentMap->GetBase()[x+y*CurrentMap->PITCH] |= 0xff00ff;
|
|
if ((Test19BASE[x+y*Test17.PITCH]& 0x55000000))
|
|
CurrentMap->GetBase()[x+y*CurrentMap->PITCH] &=~0xff00ff;
|
|
|
|
|
|
/* CurrentMap->GetBase()[x+y*CurrentMap->PITCH] &= 0xfefefefe;
|
|
CurrentMap->GetBase()[x+y*CurrentMap->PITCH] >>= 1;
|
|
CurrentMap->GetBase()[x+y*CurrentMap->PITCH] += 0x40404040;//*/
|
|
u32 Zgeg =
|
|
GetBitNumber(AndAutoRotate(Test19BASE[x+y*Test17.PITCH],10))+
|
|
GetBitNumber(AndAutoRotate(Test19BASE[x+y*Test17.PITCH],12))+
|
|
GetBitNumber(AndAutoRotate(Test19BASE[x+y*Test17.PITCH],14))+
|
|
GetBitNumber(AndAutoRotate(Test19BASE[x+y*Test17.PITCH],16))+
|
|
GetBitNumber(AndAutoRotate(Test19BASE[x+y*Test17.PITCH],18))+
|
|
GetBitNumber(AndAutoRotate(Test19BASE[x+y*Test17.PITCH],20))+
|
|
GetBitNumber(AndAutoRotate(Test19BASE[x+y*Test17.PITCH],22))+
|
|
|
|
GetBitNumber(AndAutoRotate(Test19BASE[x+y*Test17.PITCH],11))+
|
|
GetBitNumber(AndAutoRotate(Test19BASE[x+y*Test17.PITCH],13))+
|
|
GetBitNumber(AndAutoRotate(Test19BASE[x+y*Test17.PITCH],15))+
|
|
GetBitNumber(AndAutoRotate(Test19BASE[x+y*Test17.PITCH],17))+
|
|
GetBitNumber(AndAutoRotate(Test19BASE[x+y*Test17.PITCH],19))+
|
|
GetBitNumber(AndAutoRotate(Test19BASE[x+y*Test17.PITCH],21))+
|
|
|
|
0;
|
|
/*if (Zgeg)
|
|
{
|
|
if (Zgeg <3) CurrentMap->GetBase()[x+y*CurrentMap->PITCH] = 0xffffff;
|
|
else
|
|
if (Zgeg <6) CurrentMap->GetBase()[x+y*CurrentMap->PITCH] = 0xff0000;
|
|
else
|
|
if (Zgeg <16) CurrentMap->GetBase()[x+y*CurrentMap->PITCH] = 0xff00;
|
|
}
|
|
/*if (GetBitNumber(Test19BASE[x+y*Test17.PITCH]& (0xAAAAAAAA>>1))>5)
|
|
CurrentMap->GetBase()[x+y*CurrentMap->PITCH] = 0;*/
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// MAP32_Copy(&Test19,CurrentMap);
|
|
|
|
char Fuck[256];
|
|
sprintf(Fuck,"%d",Torglaf>>2);
|
|
DRawTEXT_Soft_B((u8*)Fuck,(u32*)CurrentMap->GetBase(),10,10,CurrentMap->PITCH,CurrentMap->SY,0xffffff);
|
|
Torglaf = 0;
|
|
#endif
|
|
}
|
|
|
|
void TEST(MAP *CurrentMap)
|
|
{
|
|
#if 1
|
|
|
|
u32 Savex = CurrentMap->SX;
|
|
if (Prs[1])
|
|
CurrentMap->SX>>=1;
|
|
static u32 Init = 1;
|
|
u32 Counttttoo = Prs[0];
|
|
while (Counttttoo--)
|
|
{
|
|
/*FPA_FastHought(CurrentMap->GetBase(),CurrentMap->PITCH);
|
|
return;//*/
|
|
//CurrentMap->SY>>=1;
|
|
|
|
MAP Test16,Test17,Test18,Test19;
|
|
MAP DX,DY;
|
|
Test16.SetBase((s32 *)Bittos);
|
|
Test16.PITCH = CurrentMap->PITCH;
|
|
Test16.SX = CurrentMap->SX;
|
|
Test16.SY = CurrentMap->SY;
|
|
Test17 = Test16;
|
|
Test17.SetBase(Test17.GetBase()+Test17.PITCH*Test17.SY);
|
|
Test18 = Test17;
|
|
Test18.SetBase(Test18.GetBase()+Test18.PITCH*Test18.SY);
|
|
DX = Test18;
|
|
DX.SetBase(DX.GetBase()+DX.PITCH*DX.SY);
|
|
DY = DX;
|
|
DY.SetBase(DY.GetBase()+DY.PITCH*DY.SY);
|
|
Test19 = DY;
|
|
Test19.SetBase(Test19.GetBase()+Test19.PITCH*Test19.SY);
|
|
// MAP32_Copy(CurrentMap,&Test16);
|
|
/* TESTV(CurrentMap,1);
|
|
return;*/
|
|
|
|
MAP32_Copy(CurrentMap,&Test16);
|
|
MAP32_Copy(CurrentMap,&Test17);
|
|
MAP32_Copy(CurrentMap,&Test18);
|
|
MAP32_And(&Test16,0xff0000);
|
|
MAP32_And(&Test17,0xff00);
|
|
MAP32_And(&Test18,0xff);
|
|
TESTV(&Test18,1);
|
|
MAP32_And(&Test18,0xff);
|
|
MAP32_Shift(&Test18,2);
|
|
MAP32_Copy(&Test18,CurrentMap);
|
|
TESTV(&Test16,1);
|
|
TESTV(&Test17,1);
|
|
MAP32_And(&Test17,0xff00);
|
|
MAP32_And(&Test16,0xff0000);
|
|
MAP32_Shift(&Test17,1);
|
|
MAP32_Shift(&Test16,2);
|
|
MAP32_Or(&Test16,CurrentMap);
|
|
MAP32_Or(&Test17,CurrentMap);
|
|
MAP32_Or(CurrentMap,0xff000000);
|
|
//MAP32_Copy(&Test18,CurrentMap);
|
|
}
|
|
//CurrentMap->SY<<=1;
|
|
//CurrentMap->SY<<=1;
|
|
|
|
//TESTV(CurrentMap);
|
|
//TESTV(&Test16);
|
|
//MAP32_Copy(&Test16,CurrentMap);
|
|
//TESTV(CurrentMap);
|
|
CurrentMap->SX = Savex;
|
|
#endif
|
|
void Segmenting(MAP *CurrentMap);
|
|
Segmenting(CurrentMap);
|
|
return;
|
|
}
|
|
|
|
#endif |