Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/operations/COM_GlareFogGlowOperation.cc
| Show First 20 Lines • Show All 249 Lines • ▼ Show 20 Lines | for (j = 1; j < n2; j++) { | ||||
| b = d1[k + mj] * d2[i + mL] + d1[i + mL] * d2[k + mj]; | b = d1[k + mj] * d2[i + mL] + d1[i + mL] * d2[k + mj]; | ||||
| d1[i + mL] = (b + a) * (fREAL)0.5; | d1[i + mL] = (b + a) * (fREAL)0.5; | ||||
| d1[k + mj] = (b - a) * (fREAL)0.5; | d1[k + mj] = (b - a) * (fREAL)0.5; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| //------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ | ||||
| static void convolve(float *dst, MemoryBuffer *in1, MemoryBuffer *in2) | static void convolve(float *dst, MemoryBuffer *input_image, MemoryBuffer *kernel) | ||||
| { | { | ||||
| fREAL *data1, *data2, *fp; | fREAL *data1, *data2, *fp; | ||||
| unsigned int w2, h2, hw, hh, log2_w, log2_h; | unsigned int w2, h2, hw, hh, log2_w, log2_h; | ||||
| fRGB wt, *colp; | fRGB wt, *colp; | ||||
| int x, y, ch; | int x, y, ch; | ||||
| int xbl, ybl, nxb, nyb, xbsz, ybsz; | int xbl, ybl, nxb, nyb, xbsz, ybsz; | ||||
| bool in2done = false; | bool in2done = false; | ||||
| const unsigned int kernelWidth = in2->getWidth(); | const unsigned int kernelWidth = kernel->getWidth(); | ||||
| const unsigned int kernelHeight = in2->getHeight(); | const unsigned int kernelHeight = kernel->getHeight(); | ||||
| const unsigned int imageWidth = in1->getWidth(); | const unsigned int imageWidth = input_image->getWidth(); | ||||
| const unsigned int imageHeight = in1->getHeight(); | const unsigned int imageHeight = input_image->getHeight(); | ||||
| float *kernelBuffer = in2->getBuffer(); | float *kernelBuffer = kernel->getBuffer(); | ||||
| float *imageBuffer = in1->getBuffer(); | |||||
| MemoryBuffer *rdst = new MemoryBuffer(DataType::Color, in1->get_rect()); | MemoryBuffer *rdst = new MemoryBuffer(DataType::Color, input_image->get_rect()); | ||||
| memset(rdst->getBuffer(), | memset(rdst->getBuffer(), | ||||
| 0, | 0, | ||||
| rdst->getWidth() * rdst->getHeight() * COM_DATA_TYPE_COLOR_CHANNELS * sizeof(float)); | rdst->getWidth() * rdst->getHeight() * COM_DATA_TYPE_COLOR_CHANNELS * sizeof(float)); | ||||
| // convolution result width & height | // convolution result width & height | ||||
| w2 = 2 * kernelWidth - 1; | w2 = 2 * kernelWidth - 1; | ||||
| h2 = 2 * kernelHeight - 1; | h2 = 2 * kernelHeight - 1; | ||||
| // FFT pow2 required size & log2 | // FFT pow2 required size & log2 | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | for (xbl = 0; xbl < nxb; xbl++) { | ||||
| for (x = 0; x < kernelWidth; x++) { | for (x = 0; x < kernelWidth; x++) { | ||||
| fp[x] = colp[x][ch]; | fp[x] = colp[x][ch]; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| // in1, channel ch -> data2 | // in1, channel ch -> data2 | ||||
| memset(data2, 0, w2 * h2 * sizeof(fREAL)); | memset(data2, 0, w2 * h2 * sizeof(fREAL)); | ||||
| float *colp_image; | |||||
| int image_elem_jump = input_image->elem_jump; | |||||
| for (y = 0; y < ybsz; y++) { | for (y = 0; y < ybsz; y++) { | ||||
| int yy = ybl * ybsz + y; | int yy = ybl * ybsz + y; | ||||
| if (yy >= imageHeight) { | if (yy >= imageHeight) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| fp = &data2[y * w2]; | fp = &data2[y * w2]; | ||||
| colp = (fRGB *)&imageBuffer[yy * imageWidth * COM_DATA_TYPE_COLOR_CHANNELS]; | colp_image = input_image->get_elem(0, y); | ||||
| for (x = 0; x < xbsz; x++) { | for (x = 0; x < xbsz; x++) { | ||||
| int xx = xbl * xbsz + x; | int xx = xbl * xbsz + x; | ||||
| if (xx >= imageWidth) { | if (xx >= imageWidth) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| fp[x] = colp[xx][ch]; | fp[x] = colp_image[xx * image_elem_jump + ch]; | ||||
| } | } | ||||
| } | } | ||||
| // forward FHT | // forward FHT | ||||
| // zero pad data start is different for each == height+1 | // zero pad data start is different for each == height+1 | ||||
| if (!in2done) { | if (!in2done) { | ||||
| FHT2D(data1ch, log2_w, log2_h, kernelHeight + 1, 0); | FHT2D(data1ch, log2_w, log2_h, kernelHeight + 1, 0); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines | |||||