mirror of https://github.com/mpv-player/mpv
use shifts instead of division. 15% faster hqdn3d
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17966 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
338e4f8b76
commit
f9ed90fb61
|
@ -69,7 +69,7 @@ static int config(struct vf_instance_s* vf,
|
|||
static inline unsigned int LowPassMul(unsigned int PrevMul, unsigned int CurrMul, int* Coef){
|
||||
// int dMul= (PrevMul&0xFFFFFF)-(CurrMul&0xFFFFFF);
|
||||
int dMul= PrevMul-CurrMul;
|
||||
int d=((dMul+0x10007FF)/(65536/16));
|
||||
int d=((dMul+0x10007FF)>>12);
|
||||
return CurrMul + Coef[d];
|
||||
}
|
||||
|
||||
|
@ -81,13 +81,13 @@ static void deNoiseTemporal(
|
|||
int *Temporal)
|
||||
{
|
||||
int X, Y;
|
||||
int PixelDst;
|
||||
unsigned int PixelDst;
|
||||
|
||||
for (Y = 0; Y < H; Y++){
|
||||
for (X = 0; X < W; X++){
|
||||
PixelDst = LowPassMul(FrameAnt[X]<<8, Frame[X]<<16, Temporal);
|
||||
FrameAnt[X] = ((PixelDst+0x1000007F)/256);
|
||||
FrameDest[X]= ((PixelDst+0x10007FFF)/65536);
|
||||
FrameAnt[X] = ((PixelDst+0x1000007F)>>8);
|
||||
FrameDest[X]= ((PixelDst+0x10007FFF)>>16);
|
||||
}
|
||||
Frame += sStride;
|
||||
FrameDest += dStride;
|
||||
|
@ -105,16 +105,16 @@ static void deNoiseSpacial(
|
|||
int X, Y;
|
||||
int sLineOffs = 0, dLineOffs = 0;
|
||||
unsigned int PixelAnt;
|
||||
int PixelDst;
|
||||
unsigned int PixelDst;
|
||||
|
||||
/* First pixel has no left nor top neighbor. */
|
||||
PixelDst = LineAnt[0] = PixelAnt = Frame[0]<<16;
|
||||
FrameDest[0]= ((PixelDst+0x10007FFF)/65536);
|
||||
FrameDest[0]= ((PixelDst+0x10007FFF)>>16);
|
||||
|
||||
/* First line has no top neighbor, only left. */
|
||||
for (X = 1; X < W; X++){
|
||||
PixelDst = LineAnt[X] = LowPassMul(PixelAnt, Frame[X]<<16, Horizontal);
|
||||
FrameDest[X]= ((PixelDst+0x10007FFF)/65536);
|
||||
FrameDest[X]= ((PixelDst+0x10007FFF)>>16);
|
||||
}
|
||||
|
||||
for (Y = 1; Y < H; Y++){
|
||||
|
@ -123,14 +123,14 @@ static void deNoiseSpacial(
|
|||
/* First pixel on each line doesn't have previous pixel */
|
||||
PixelAnt = Frame[sLineOffs]<<16;
|
||||
PixelDst = LineAnt[0] = LowPassMul(LineAnt[0], PixelAnt, Vertical);
|
||||
FrameDest[dLineOffs]= ((PixelDst+0x10007FFF)/65536);
|
||||
FrameDest[dLineOffs]= ((PixelDst+0x10007FFF)>>16);
|
||||
|
||||
for (X = 1; X < W; X++){
|
||||
int PixelDst;
|
||||
unsigned int PixelDst;
|
||||
/* The rest are normal */
|
||||
PixelAnt = LowPassMul(PixelAnt, Frame[sLineOffs+X]<<16, Horizontal);
|
||||
PixelDst = LineAnt[X] = LowPassMul(LineAnt[X], PixelAnt, Vertical);
|
||||
FrameDest[dLineOffs+X]= ((PixelDst+0x10007FFF)/65536);
|
||||
FrameDest[dLineOffs+X]= ((PixelDst+0x10007FFF)>>16);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ static void deNoise(unsigned char *Frame, // mpi->planes[x]
|
|||
int X, Y;
|
||||
int sLineOffs = 0, dLineOffs = 0;
|
||||
unsigned int PixelAnt;
|
||||
int PixelDst;
|
||||
unsigned int PixelDst;
|
||||
unsigned short* FrameAnt=(*FrameAntPtr);
|
||||
|
||||
if(!FrameAnt){
|
||||
|
@ -171,16 +171,16 @@ static void deNoise(unsigned char *Frame, // mpi->planes[x]
|
|||
/* First pixel has no left nor top neighbor. Only previous frame */
|
||||
LineAnt[0] = PixelAnt = Frame[0]<<16;
|
||||
PixelDst = LowPassMul(FrameAnt[0]<<8, PixelAnt, Temporal);
|
||||
FrameAnt[0] = ((PixelDst+0x1000007F)/256);
|
||||
FrameDest[0]= ((PixelDst+0x10007FFF)/65536);
|
||||
FrameAnt[0] = ((PixelDst+0x1000007F)>>8);
|
||||
FrameDest[0]= ((PixelDst+0x10007FFF)>>16);
|
||||
|
||||
/* First line has no top neighbor. Only left one for each pixel and
|
||||
* last frame */
|
||||
for (X = 1; X < W; X++){
|
||||
LineAnt[X] = PixelAnt = LowPassMul(PixelAnt, Frame[X]<<16, Horizontal);
|
||||
PixelDst = LowPassMul(FrameAnt[X]<<8, PixelAnt, Temporal);
|
||||
FrameAnt[X] = ((PixelDst+0x1000007F)/256);
|
||||
FrameDest[X]= ((PixelDst+0x10007FFF)/65536);
|
||||
FrameAnt[X] = ((PixelDst+0x1000007F)>>8);
|
||||
FrameDest[X]= ((PixelDst+0x10007FFF)>>16);
|
||||
}
|
||||
|
||||
for (Y = 1; Y < H; Y++){
|
||||
|
@ -191,17 +191,17 @@ static void deNoise(unsigned char *Frame, // mpi->planes[x]
|
|||
PixelAnt = Frame[sLineOffs]<<16;
|
||||
LineAnt[0] = LowPassMul(LineAnt[0], PixelAnt, Vertical);
|
||||
PixelDst = LowPassMul(LinePrev[0]<<8, LineAnt[0], Temporal);
|
||||
LinePrev[0] = ((PixelDst+0x1000007F)/256);
|
||||
FrameDest[dLineOffs]= ((PixelDst+0x10007FFF)/65536);
|
||||
LinePrev[0] = ((PixelDst+0x1000007F)>>8);
|
||||
FrameDest[dLineOffs]= ((PixelDst+0x10007FFF)>>16);
|
||||
|
||||
for (X = 1; X < W; X++){
|
||||
int PixelDst;
|
||||
unsigned int PixelDst;
|
||||
/* The rest are normal */
|
||||
PixelAnt = LowPassMul(PixelAnt, Frame[sLineOffs+X]<<16, Horizontal);
|
||||
LineAnt[X] = LowPassMul(LineAnt[X], PixelAnt, Vertical);
|
||||
PixelDst = LowPassMul(LinePrev[X]<<8, LineAnt[X], Temporal);
|
||||
LinePrev[X] = ((PixelDst+0x1000007F)/256);
|
||||
FrameDest[dLineOffs+X]= ((PixelDst+0x10007FFF)/65536);
|
||||
LinePrev[X] = ((PixelDst+0x1000007F)>>8);
|
||||
FrameDest[dLineOffs+X]= ((PixelDst+0x10007FFF)>>16);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue