29 static void AdjBlurDct(num *ATrans, FFT(plan) TransformA,
30 const num *KernelTrans,
31 int Width,
int Height,
int NumChannels, num Alpha)
33 const long NumPixels = ((long)Width) * ((long)Height);
38 FFT(execute)(TransformA);
41 for(k = 0; k < NumChannels; k++, ATrans += NumPixels)
42 for(i = 0; i < NumPixels; i++)
43 ATrans[i] = Alpha * KernelTrans[i] * ATrans[i];
60 num *KernelTrans = S->KernelTrans;
61 num *DenomTrans = S->DenomTrans;
63 const num *Kernel = S->
Opt.Kernel;
64 const int KernelWidth = S->
Opt.KernelWidth;
65 const int KernelHeight = S->
Opt.KernelHeight;
66 const int Width = S->
Width;
67 const int Height = S->
Height;
68 const num Alpha = S->
Alpha;
69 const long NumPixels = ((long)Width) * ((long)Height);
70 const long PadNumPixels = ((long)Width + 1) * ((long)Height + 1);
71 FFT(plan) Plan = NULL;
72 FFT(r2r_kind) Kind[2];
74 int x0, y0, x, y, xi, yi, Size[2];
76 for(i = 0; i < PadNumPixels; i++)
84 for(y = 0; y < y0 + KernelHeight; y++)
88 for(x = 0; x < x0 + KernelWidth; x++)
91 B[xi + (Width + 1)*yi] += Kernel[(x - x0) + KernelWidth*(y - y0)];
96 if(!(Plan = FFT(plan_r2r_2d)(Height + 1, Width + 1, B, KernelTrans,
97 FFTW_REDFT00, FFTW_REDFT00, FFTW_ESTIMATE | FFTW_DESTROY_INPUT)))
101 FFT(destroy_plan)(Plan);
104 for(y = 1, i = Width; y < Height; y++, i += Width)
105 memmove(KernelTrans + i, KernelTrans + i + y,
sizeof(num)*Width);
108 for(y = 0, i = 0; y < Height; y++)
109 for(x = 0; x < Width; x++, i++)
111 (num)(4*NumPixels*(Alpha*KernelTrans[i]*KernelTrans[i]
112 + 2*(2 - cos(x*
M_PI/Width) - cos(y*
M_PI/Height))));
117 Kind[0] = Kind[1] = FFTW_REDFT10;
119 if(!(S->TransformA = FFT(plan_many_r2r)(2, Size, S->
NumChannels,
120 S->A, NULL, 1, NumPixels, S->ATrans, NULL, 1, NumPixels, Kind,
121 FFTW_ESTIMATE | FFTW_DESTROY_INPUT))
122 || !(S->TransformB = FFT(plan_many_r2r)(2, Size, S->
NumChannels,
123 S->B, NULL, 1, NumPixels, S->BTrans, NULL, 1, NumPixels, Kind,
124 FFTW_ESTIMATE | FFTW_DESTROY_INPUT)))
128 Kind[0] = Kind[1] = FFTW_REDFT01;
130 if(!(S->InvTransformA = FFT(plan_many_r2r)(2, Size, S->
NumChannels,
131 S->ATrans, NULL, 1, NumPixels, S->A, NULL, 1, NumPixels, Kind,
132 FFTW_ESTIMATE | FFTW_DESTROY_INPUT))
133 || !(S->InvTransformB = FFT(plan_many_r2r)(2, Size, S->
NumChannels,
134 S->BTrans, NULL, 1, NumPixels, S->B, NULL, 1, NumPixels, Kind,
135 FFTW_ESTIMATE | FFTW_DESTROY_INPUT)))
141 memcpy(S->A, S->
f,
sizeof(num)*NumPixels*S->
NumChannels);
143 KernelTrans, Width, Height, S->
NumChannels, Alpha);
158 num *ATrans,
const numvec2 *dtilde,
159 const num *DenomTrans,
int Width,
int Height,
int NumChannels)
161 const long NumPixels = ((long)Width) * ((long)Height);
166 Divergence(B, Width, Height, dtilde, Width, Height, NumChannels);
169 FFT(execute)(TransformB);
172 for(k = 0; k < NumChannels; k++, ATrans += NumPixels, BTrans += NumPixels)
173 for(i = 0; i < NumPixels; i++)
174 BTrans[i] = (ATrans[i] - BTrans[i]) / DenomTrans[i];
202 FFT(execute)(S->InvTransformB);
208 #if defined(TVREG_USEZ) || defined(DOXYGEN)
223 num *ATrans = S->ATrans;
224 num *BTrans = S->BTrans;
225 const num *KernelTrans = S->KernelTrans;
227 const long NumPixels = ((long)S->
Width) * ((long)S->
Height);
232 memcpy(S->A, S->ztilde,
sizeof(num)*NumPixels*NumChannels);
233 AdjBlurDct(ATrans, S->TransformA, KernelTrans,
240 for(k = 0; k < NumChannels; k++, ATrans += NumPixels, BTrans += NumPixels)
241 for(i = 0; i < NumPixels; i++)
242 ATrans[i] = KernelTrans[i] * BTrans[i];
245 FFT(execute)(S->InvTransformA);
247 FFT(execute)(S->InvTransformB);