MCPcopy Create free account
hub / github.com/NatronGitHub/openfx-misc / process

Method process

Log2Lin/Log2Lin.cpp:297–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

setupAndProcessMethod · 0.45

Calls 2

unusedFunction · 0.85
getPixelAddressMethod · 0.80

Tested by

no test coverage detected