Skip to content

Commit

Permalink
update for better compatibility with Fusion
Browse files Browse the repository at this point in the history
  • Loading branch information
devernay committed Jul 18, 2019
1 parent d7586b7 commit 8475347
Show file tree
Hide file tree
Showing 88 changed files with 1,230 additions and 1,294 deletions.
48 changes: 23 additions & 25 deletions Add/Add.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class AddProcessor

private:

void multiThreadProcessImages(OfxRectI procWindow)
void multiThreadProcessImages(const OfxRectI& procWindow, const OfxPointD& rs) OVERRIDE FINAL
{
# ifndef __COVERITY__ // too many coverity[dead_error_line] errors
const bool r = _processR && (nComponents != 1);
Expand All @@ -240,59 +240,59 @@ class AddProcessor
if (g) {
if (b) {
if (a) {
return process<true, true, true, true >(procWindow); // RGBA
return process<true, true, true, true >(procWindow, rs); // RGBA
} else {
return process<true, true, true, false>(procWindow); // RGBa
return process<true, true, true, false>(procWindow, rs); // RGBa
}
} else {
if (a) {
return process<true, true, false, true >(procWindow); // RGbA
return process<true, true, false, true >(procWindow, rs); // RGbA
} else {
return process<true, true, false, false>(procWindow); // RGba
return process<true, true, false, false>(procWindow, rs); // RGba
}
}
} else {
if (b) {
if (a) {
return process<true, false, true, true >(procWindow); // RgBA
return process<true, false, true, true >(procWindow, rs); // RgBA
} else {
return process<true, false, true, false>(procWindow); // RgBa
return process<true, false, true, false>(procWindow, rs); // RgBa
}
} else {
if (a) {
return process<true, false, false, true >(procWindow); // RgbA
return process<true, false, false, true >(procWindow, rs); // RgbA
} else {
return process<true, false, false, false>(procWindow); // Rgba
return process<true, false, false, false>(procWindow, rs); // Rgba
}
}
}
} else {
if (g) {
if (b) {
if (a) {
return process<false, true, true, true >(procWindow); // rGBA
return process<false, true, true, true >(procWindow, rs); // rGBA
} else {
return process<false, true, true, false>(procWindow); // rGBa
return process<false, true, true, false>(procWindow, rs); // rGBa
}
} else {
if (a) {
return process<false, true, false, true >(procWindow); // rGbA
return process<false, true, false, true >(procWindow, rs); // rGbA
} else {
return process<false, true, false, false>(procWindow); // rGba
return process<false, true, false, false>(procWindow, rs); // rGba
}
}
} else {
if (b) {
if (a) {
return process<false, false, true, true >(procWindow); // rgBA
return process<false, false, true, true >(procWindow, rs); // rgBA
} else {
return process<false, false, true, false>(procWindow); // rgBa
return process<false, false, true, false>(procWindow, rs); // rgBa
}
} else {
if (a) {
return process<false, false, false, true >(procWindow); // rgbA
return process<false, false, false, true >(procWindow, rs); // rgbA
} else {
return process<false, false, false, false>(procWindow); // rgba
return process<false, false, false, false>(procWindow, rs); // rgba
}
}
}
Expand All @@ -301,8 +301,9 @@ class AddProcessor
} // multiThreadProcessImages

template<bool processR, bool processG, bool processB, bool processA>
void process(const OfxRectI& procWindow)
void process(const OfxRectI& procWindow, const OfxPointD& rs)
{
unused(rs);
assert(nComponents == 1 || nComponents == 3 || nComponents == 4);
assert(_dstImg);
float unpPix[4];
Expand Down Expand Up @@ -382,8 +383,6 @@ class AddPlugin
, _maskInvert(NULL)
, _premultChanged(NULL)
{
const ImageEffectHostDescription &hostDescription = *getImageEffectHostDescription();
_hostIsResolve = (hostDescription.hostName.substr(0, 14) == "DaVinciResolve"); // Resolve gives bad image properties

_dstClip = fetchClip(kOfxImageEffectOutputClipName);
assert( _dstClip && (!_dstClip->isConnected() || OFX_COMPONENTS_OK( _dstClip->getPixelComponents() )) );
Expand Down Expand Up @@ -442,7 +441,6 @@ class AddPlugin
BooleanParam* _maskApply;
BooleanParam* _maskInvert;
BooleanParam* _premultChanged; // set to true the first time the user connects src
bool _hostIsResolve;
};


Expand All @@ -469,7 +467,7 @@ AddPlugin::setupAndProcess(AddProcessorBase &processor,
setPersistentMessage(Message::eMessageError, "", "OFX Host gave image with wrong depth or components");
throwSuiteStatusException(kOfxStatFailed);
}
checkBadRenderScaleOrField(_hostIsResolve, dst, args);
checkBadRenderScaleOrField(dst, args);
auto_ptr<const Image> src( ( _srcClip && _srcClip->isConnected() ) ?
_srcClip->fetchImage(args.time) : 0 );
if ( src.get() ) {
Expand All @@ -493,7 +491,7 @@ AddPlugin::setupAndProcess(AddProcessorBase &processor,
processor.setDstImg( dst.get() );
processor.setSrcImg( src.get() );
// set the render window
processor.setRenderWindow(args.renderWindow);
processor.setRenderWindow(args.renderWindow, args.renderScale);

bool processR, processG, processB, processA;
_processR->getValueAtTime(args.time, processR);
Expand Down Expand Up @@ -550,8 +548,8 @@ AddPlugin::render(const RenderArguments &args)
BitDepthEnum dstBitDepth = _dstClip->getPixelDepth();
PixelComponentEnum dstComponents = _dstClip->getPixelComponents();

assert( kSupportsMultipleClipPARs || !_srcClip || _srcClip->getPixelAspectRatio() == _dstClip->getPixelAspectRatio() );
assert( kSupportsMultipleClipDepths || !_srcClip || _srcClip->getPixelDepth() == _dstClip->getPixelDepth() );
assert( kSupportsMultipleClipPARs || !_srcClip || !_srcClip->isConnected() || _srcClip->getPixelAspectRatio() == _dstClip->getPixelAspectRatio() );
assert( kSupportsMultipleClipDepths || !_srcClip || !_srcClip->isConnected() || _srcClip->getPixelDepth() == _dstClip->getPixelDepth() );
#ifdef OFX_EXTENSIONS_NATRON
assert(dstComponents == ePixelComponentRGBA || dstComponents == ePixelComponentRGB || dstComponents == ePixelComponentXY || dstComponents == ePixelComponentAlpha);
#else
Expand Down
11 changes: 4 additions & 7 deletions AdjustRoD/AdjustRoD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ class AdjustRoDPlugin
, _srcClip(NULL)
, _size(NULL)
{
const ImageEffectHostDescription &hostDescription = *getImageEffectHostDescription();
_hostIsResolve = (hostDescription.hostName.substr(0, 14) == "DaVinciResolve"); // Resolve gives bad image properties

_dstClip = fetchClip(kOfxImageEffectOutputClipName);
assert( _dstClip && (!_dstClip->isConnected() ||
Expand Down Expand Up @@ -133,7 +131,6 @@ class AdjustRoDPlugin
Clip *_srcClip;
Double2DParam* _size;
ChoiceParam* _boundary;
bool _hostIsResolve;
};


Expand All @@ -154,7 +151,7 @@ AdjustRoDPlugin::setupAndCopy(PixelProcessorFilterBase & processor,
if ( !dst.get() ) {
throwSuiteStatusException(kOfxStatFailed);
}
checkBadRenderScaleOrField(_hostIsResolve, dst, args);
checkBadRenderScaleOrField(dst, args);
auto_ptr<const Image> src( ( _srcClip && _srcClip->isConnected() ) ?
_srcClip->fetchImage(args.time) : 0 );
if ( src.get() && dst.get() ) {
Expand All @@ -172,7 +169,7 @@ AdjustRoDPlugin::setupAndCopy(PixelProcessorFilterBase & processor,
processor.setSrcImg( src.get(), _boundary->getValueAtTime(time) );

// set the render window
processor.setRenderWindow(args.renderWindow);
processor.setRenderWindow(args.renderWindow, args.renderScale);

// Call the base class process member, this will call the derived templated process code
processor.process();
Expand Down Expand Up @@ -266,8 +263,8 @@ AdjustRoDPlugin::render(const RenderArguments &args)
BitDepthEnum dstBitDepth = _dstClip->getPixelDepth();
PixelComponentEnum dstComponents = _dstClip->getPixelComponents();

assert( kSupportsMultipleClipPARs || !_srcClip || _srcClip->getPixelAspectRatio() == _dstClip->getPixelAspectRatio() );
assert( kSupportsMultipleClipDepths || !_srcClip || _srcClip->getPixelDepth() == _dstClip->getPixelDepth() );
assert( kSupportsMultipleClipPARs || !_srcClip || !_srcClip->isConnected() || _srcClip->getPixelAspectRatio() == _dstClip->getPixelAspectRatio() );
assert( kSupportsMultipleClipDepths || !_srcClip || !_srcClip->isConnected() || _srcClip->getPixelDepth() == _dstClip->getPixelDepth() );
assert(OFX_COMPONENTS_OK(dstComponents));
if (dstComponents == ePixelComponentRGBA) {
renderInternal<4>(args, dstBitDepth);
Expand Down
18 changes: 8 additions & 10 deletions Anaglyph/Anaglyph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ class ImageAnaglypher

private:
// and do some processing
void multiThreadProcessImages(OfxRectI procWindow)
void multiThreadProcessImages(const OfxRectI& procWindow, const OfxPointD& rs) OVERRIDE FINAL
{
unused(rs);
const Image *srcRedImg = _srcLeftImg;
const Image *srcCyanImg = _srcRightImg;

Expand Down Expand Up @@ -194,8 +195,6 @@ class AnaglyphPlugin
, _swap(NULL)
, _offset(NULL)
{
const ImageEffectHostDescription &hostDescription = *getImageEffectHostDescription();
_hostIsResolve = (hostDescription.hostName.substr(0, 14) == "DaVinciResolve"); // Resolve gives bad image properties

_dstClip = fetchClip(kOfxImageEffectOutputClipName);
assert( _dstClip && (!_dstClip->isConnected() || _dstClip->getPixelComponents() == ePixelComponentRGBA) );
Expand Down Expand Up @@ -224,7 +223,6 @@ class AnaglyphPlugin
DoubleParam *_amtcolour;
BooleanParam *_swap;
IntParam *_offset;
bool _hostIsResolve;
};


Expand Down Expand Up @@ -253,18 +251,18 @@ AnaglyphPlugin::setupAndProcess(AnaglyphBase &processor,
setPersistentMessage(Message::eMessageError, "", "OFX Host gave image with wrong depth or components");
throwSuiteStatusException(kOfxStatFailed);
}
checkBadRenderScaleOrField(_hostIsResolve, dst, args);
checkBadRenderScaleOrField(dst, args);

// fetch main input image
auto_ptr<const Image> srcLeft( ( _srcClip && _srcClip->isConnected() ) ?
_srcClip->fetchImagePlane(args.time, 0, kFnOfxImagePlaneColour) : 0 );
if ( srcLeft.get() ) {
checkBadRenderScaleOrField(_hostIsResolve, srcLeft, args);
checkBadRenderScaleOrField(srcLeft, args);
}
auto_ptr<const Image> srcRight( ( _srcClip && _srcClip->isConnected() ) ?
_srcClip->fetchImagePlane(args.time, 1, kFnOfxImagePlaneColour) : 0 );
if ( srcRight.get() ) {
checkBadRenderScaleOrField(_hostIsResolve, srcRight, args);
checkBadRenderScaleOrField(srcRight, args);
}

// make sure bit depths are sane
Expand Down Expand Up @@ -297,7 +295,7 @@ AnaglyphPlugin::setupAndProcess(AnaglyphBase &processor,
processor.setSrcRightImg( srcRight.get() );

// set the render window
processor.setRenderWindow(args.renderWindow);
processor.setRenderWindow(args.renderWindow, args.renderScale);

// set the parameters
processor.setAmtColour(amtcolour);
Expand All @@ -324,8 +322,8 @@ AnaglyphPlugin::getFrameViewsNeeded(const FrameViewsNeededArguments& args,
void
AnaglyphPlugin::render(const RenderArguments &args)
{
assert( kSupportsMultipleClipPARs || !_srcClip || _srcClip->getPixelAspectRatio() == _dstClip->getPixelAspectRatio() );
assert( kSupportsMultipleClipDepths || !_srcClip || _srcClip->getPixelDepth() == _dstClip->getPixelDepth() );
assert( kSupportsMultipleClipPARs || !_srcClip || !_srcClip->isConnected() || _srcClip->getPixelAspectRatio() == _dstClip->getPixelAspectRatio() );
assert( kSupportsMultipleClipDepths || !_srcClip || !_srcClip->isConnected() || _srcClip->getPixelDepth() == _dstClip->getPixelDepth() );
// instantiate the render code based on the pixel depth of the dst clip
BitDepthEnum dstBitDepth = _dstClip->getPixelDepth();
PixelComponentEnum dstComponents = _dstClip->getPixelComponents();
Expand Down
21 changes: 9 additions & 12 deletions AppendClip/AppendClip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ class AppendClipPlugin
, _firstFrame(NULL)
, _lastFrame(NULL)
{
const ImageEffectHostDescription &hostDescription = *getImageEffectHostDescription();
_hostIsResolve = (hostDescription.hostName.substr(0, 14) == "DaVinciResolve"); // Resolve gives bad image properties

_dstClip = fetchClip(kOfxImageEffectOutputClipName);
assert( _dstClip && (!_dstClip->isConnected() || _dstClip->getPixelComponents() == ePixelComponentRGB || _dstClip->getPixelComponents() == ePixelComponentRGBA || _dstClip->getPixelComponents() == ePixelComponentAlpha) );
Expand Down Expand Up @@ -199,7 +197,6 @@ class AppendClipPlugin
IntParam* _crossDissolve;
IntParam* _firstFrame;
IntParam* _lastFrame;
bool _hostIsResolve;
};


Expand Down Expand Up @@ -566,7 +563,7 @@ AppendClipPlugin::setupAndProcess(ImageBlenderBase &processor,
setPersistentMessage(Message::eMessageError, "", "OFX Host gave image with wrong depth or components");
throwSuiteStatusException(kOfxStatFailed);
}
checkBadRenderScaleOrField(_hostIsResolve, dst, args);
checkBadRenderScaleOrField(dst, args);

const double time = args.time;
int firstFrame;
Expand All @@ -587,7 +584,7 @@ AppendClipPlugin::setupAndProcess(ImageBlenderBase &processor,

if ( ( (clip0 == -1) && (clip1 == -1) ) || ( (alpha0 == 0.) && (alpha1 == 0.) ) ) {
// no clip, just fill with black
fillBlack( *this, args.renderWindow, dst.get() );
fillBlack( *this, args.renderWindow, args.renderScale, dst.get() );

return;
}
Expand All @@ -598,14 +595,14 @@ AppendClipPlugin::setupAndProcess(ImageBlenderBase &processor,
auto_ptr<const Image> src( ( _srcClip[clip0] && _srcClip[clip0]->isConnected() ) ?
_srcClip[clip0]->fetchImage(t0) : 0 );
if ( src.get() ) {
checkBadRenderScaleOrField(_hostIsResolve, src, args);
checkBadRenderScaleOrField(src, args);
BitDepthEnum srcBitDepth = src->getPixelDepth();
PixelComponentEnum srcComponents = src->getPixelComponents();
if ( (srcBitDepth != dstBitDepth) || (srcComponents != dstComponents) ) {
throwSuiteStatusException(kOfxStatErrImageFormat);
}
}
copyPixels( *this, args.renderWindow, src.get(), dst.get() );
copyPixels( *this, args.renderWindow, args.renderScale, src.get(), dst.get() );

return;
}
Expand All @@ -618,11 +615,11 @@ AppendClipPlugin::setupAndProcess(ImageBlenderBase &processor,

// make sure bit depths are sane
if ( fromImg.get() ) {
checkBadRenderScaleOrField(_hostIsResolve, fromImg, args);
checkBadRenderScaleOrField(fromImg, args);
checkComponents(*fromImg, dstBitDepth, dstComponents);
}
if ( toImg.get() ) {
checkBadRenderScaleOrField(_hostIsResolve, toImg, args);
checkBadRenderScaleOrField(toImg, args);
checkComponents(*toImg, dstBitDepth, dstComponents);
}

Expand All @@ -632,7 +629,7 @@ AppendClipPlugin::setupAndProcess(ImageBlenderBase &processor,
processor.setToImg( toImg.get() );

// set the render window
processor.setRenderWindow(args.renderWindow);
processor.setRenderWindow(args.renderWindow, args.renderScale);

// set the scales
assert(0 < alpha0 && alpha0 <= 1 && 0 <= alpha1 && alpha1 < 1);
Expand All @@ -652,8 +649,8 @@ AppendClipPlugin::render(const RenderArguments &args)
PixelComponentEnum dstComponents = _dstClip->getPixelComponents();

for (unsigned i = 0; i < _srcClip.size(); ++i) {
assert( kSupportsMultipleClipPARs || _srcClip[i]->getPixelAspectRatio() == _dstClip->getPixelAspectRatio() );
assert( kSupportsMultipleClipDepths || _srcClip[i]->getPixelDepth() == _dstClip->getPixelDepth() );
assert( kSupportsMultipleClipPARs || !_srcClip[i] || !_srcClip[i]->isConnected() || _srcClip[i]->getPixelAspectRatio() == _dstClip->getPixelAspectRatio() );
assert( kSupportsMultipleClipDepths || !_srcClip[i] || !_srcClip[i]->isConnected() || _srcClip[i]->getPixelDepth() == _dstClip->getPixelDepth() );
}
// do the rendering
if (dstComponents == ePixelComponentRGBA) {
Expand Down
9 changes: 4 additions & 5 deletions CImg/CImgFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ CImgFilterPluginHelperBase::CImgFilterPluginHelperBase(OfxImageEffectHandle hand
, _defaultUnpremult(defaultUnpremult)
, _premultChanged(NULL)
{
const ImageEffectHostDescription &hostDescription = *getImageEffectHostDescription();
_hostIsResolve = (hostDescription.hostName.substr(0, 14) == "DaVinciResolve"); // Resolve gives bad image properties

_dstClip = fetchClip(kOfxImageEffectOutputClipName);
assert( _dstClip && (!_dstClip->isConnected() || _dstClip->getPixelComponents() == ePixelComponentRGB ||
_dstClip->getPixelComponents() == ePixelComponentRGBA) );
Expand Down Expand Up @@ -305,6 +302,7 @@ CImgFilterPluginHelperBase::describeInContextEnd(ImageEffectDescriptor &desc,
void
CImgFilterPluginHelperBase::setupAndFill(PixelProcessorFilterBase & processor,
const OfxRectI &renderWindow,
const OfxPointD &renderScale,
void *dstPixelData,
const OfxRectI& dstBounds,
PixelComponentEnum dstPixelComponents,
Expand All @@ -319,7 +317,7 @@ CImgFilterPluginHelperBase::setupAndFill(PixelProcessorFilterBase & processor,
processor.setDstImg(dstPixelData, dstBounds, dstPixelComponents, dstPixelComponentCount, dstPixelDepth, dstRowBytes);

// set the render window
processor.setRenderWindow(renderWindow);
processor.setRenderWindow(renderWindow, renderScale);

// Call the base class process member, this will call the derived templated process code
processor.process();
Expand All @@ -330,6 +328,7 @@ void
CImgFilterPluginHelperBase::setupAndCopy(PixelProcessorFilterBase & processor,
double time,
const OfxRectI &renderWindow,
const OfxPointD &renderScale,
const Image* orig,
const Image* mask,
const void *srcPixelData,
Expand Down Expand Up @@ -380,7 +379,7 @@ CImgFilterPluginHelperBase::setupAndCopy(PixelProcessorFilterBase & processor,
processor.setSrcImg(srcPixelData, srcBounds, srcPixelComponents, srcPixelComponentCount, srcBitDepth, srcRowBytes, srcBoundary);

// set the render window
processor.setRenderWindow(renderWindow);
processor.setRenderWindow(renderWindow, renderScale);

processor.setPremultMaskMix(premult, premultChannel, mix);

Expand Down
Loading

0 comments on commit 8475347

Please sign in to comment.