| 305 | |
| 306 | template<bool processR, bool processG, bool processB> |
| 307 | void process(const OfxRectI& procWindow, const OfxPointD& rs) |
| 308 | { |
| 309 | unused(rs); |
| 310 | assert( (!processR && !processG && !processB) || (nComponents == 3 || nComponents == 4) ); |
| 311 | assert(nComponents == 3 || nComponents == 4); |
| 312 | float unpPix[4] = {0.f, 0.f, 0.f, 0.f}; |
| 313 | float tmpPix[4] = {0.f, 0.f, 0.f, 0.f}; |
| 314 | for (int y = procWindow.y1; y < procWindow.y2; y++) { |
| 315 | if ( _effect.abort() ) { |
| 316 | break; |
| 317 | } |
| 318 | |
| 319 | PIX *dstPix = (PIX *) _dstImg->getPixelAddress(procWindow.x1, y); |
| 320 | for (int x = procWindow.x1; x < procWindow.x2; x++) { |
| 321 | const PIX *srcPix = (const PIX *) (_srcImg ? _srcImg->getPixelAddress(x, y) : 0); |
| 322 | ofxsUnPremult<PIX, nComponents, maxValue>(srcPix, unpPix, _premult, _premultChannel); |
| 323 | |
| 324 | // process the pixel (the actual computation goes here) |
| 325 | for (int c = 0; c < 3; ++c) { |
| 326 | tmpPix[c] = log2lin(unpPix[c], c); |
| 327 | } |
| 328 | tmpPix[3] = unpPix[3]; |
| 329 | ofxsPremultMaskMixPix<PIX, nComponents, maxValue, true>(tmpPix, _premult, _premultChannel, x, y, srcPix, _doMasking, _maskImg, (float)_mix, _maskInvert, dstPix); |
| 330 | // copy back original values from unprocessed channels |
| 331 | if (!processR) { |
| 332 | dstPix[0] = srcPix ? srcPix[0] : PIX(); |
| 333 | } |
| 334 | if (!processG) { |
| 335 | dstPix[1] = srcPix ? srcPix[1] : PIX(); |
| 336 | } |
| 337 | if (!processB) { |
| 338 | dstPix[2] = srcPix ? srcPix[2] : PIX(); |
| 339 | } |
| 340 | if (nComponents == 4) { |
| 341 | dstPix[3] = srcPix ? srcPix[3] : PIX(); |
| 342 | } |
| 343 | // increment the dst pixel |
| 344 | dstPix += nComponents; |
| 345 | } |
| 346 | } |
| 347 | } |
| 348 | }; |
| 349 | |
| 350 | template <class PIX, int nComponents, int maxValue> |
no test coverage detected