Skip to content

Commit

Permalink
disable sanity checks if NDEBUG
Browse files Browse the repository at this point in the history
  • Loading branch information
devernay committed Jul 19, 2019
1 parent 144838f commit b8c0ab6
Show file tree
Hide file tree
Showing 82 changed files with 430 additions and 51 deletions.
5 changes: 5 additions & 0 deletions Add/Add.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ AddPlugin::setupAndProcess(AddProcessorBase &processor,
if ( !dst.get() ) {
throwSuiteStatusException(kOfxStatFailed);
}
# ifndef NDEBUG
BitDepthEnum dstBitDepth = dst->getPixelDepth();
PixelComponentEnum dstComponents = dst->getPixelComponents();
if ( ( dstBitDepth != _dstClip->getPixelDepth() ) ||
Expand All @@ -468,15 +469,19 @@ AddPlugin::setupAndProcess(AddProcessorBase &processor,
throwSuiteStatusException(kOfxStatFailed);
}
checkBadRenderScaleOrField(dst, args);
# endif
auto_ptr<const Image> src( ( _srcClip && _srcClip->isConnected() ) ?
_srcClip->fetchImage(args.time) : 0 );
# ifndef NDEBUG
if ( src.get() ) {
checkBadRenderScaleOrField(src, args);
BitDepthEnum srcBitDepth = src->getPixelDepth();
PixelComponentEnum srcComponents = src->getPixelComponents();
if ( (srcBitDepth != dstBitDepth) || (srcComponents != dstComponents) ) {
throwSuiteStatusException(kOfxStatErrImageFormat);
}
}
# endif
bool doMasking = ( ( !_maskApply || _maskApply->getValueAtTime(args.time) ) && _maskClip && _maskClip->isConnected() );
auto_ptr<const Image> mask(doMasking ? _maskClip->fetchImage(args.time) : 0);
// do we do masking
Expand Down
2 changes: 2 additions & 0 deletions AdjustRoD/AdjustRoD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ AdjustRoDPlugin::setupAndCopy(PixelProcessorFilterBase & processor,
checkBadRenderScaleOrField(dst, args);
auto_ptr<const Image> src( ( _srcClip && _srcClip->isConnected() ) ?
_srcClip->fetchImage(args.time) : 0 );
# ifndef NDEBUG
if ( src.get() && dst.get() ) {
BitDepthEnum dstBitDepth = dst->getPixelDepth();
PixelComponentEnum dstComponents = dst->getPixelComponents();
Expand All @@ -163,6 +164,7 @@ AdjustRoDPlugin::setupAndCopy(PixelProcessorFilterBase & processor,
throwSuiteStatusException(kOfxStatFailed);
}
}
# endif

// set the images
processor.setDstImg( dst.get() );
Expand Down
8 changes: 7 additions & 1 deletion Anaglyph/Anaglyph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ AnaglyphPlugin::setupAndProcess(AnaglyphBase &processor,
if ( !dst.get() ) {
throwSuiteStatusException(kOfxStatFailed);
}
# ifndef NDEBUG
BitDepthEnum dstBitDepth = dst->getPixelDepth();
PixelComponentEnum dstComponents = dst->getPixelComponents();
if ( ( dstBitDepth != _dstClip->getPixelDepth() ) ||
Expand All @@ -252,6 +253,7 @@ AnaglyphPlugin::setupAndProcess(AnaglyphBase &processor,
throwSuiteStatusException(kOfxStatFailed);
}
checkBadRenderScaleOrField(dst, args);
# endif

// fetch main input image
auto_ptr<const Image> srcLeft( ( _srcClip && _srcClip->isConnected() ) ?
Expand All @@ -265,6 +267,7 @@ AnaglyphPlugin::setupAndProcess(AnaglyphBase &processor,
checkBadRenderScaleOrField(srcRight, args);
}

# ifndef NDEBUG
// make sure bit depths are sane
if ( srcLeft.get() ) {
BitDepthEnum srcBitDepth = srcLeft->getPixelDepth();
Expand All @@ -284,6 +287,7 @@ AnaglyphPlugin::setupAndProcess(AnaglyphBase &processor,
throwSuiteStatusException(kOfxStatErrImageFormat);
}
}
# endif

double amtcolour = _amtcolour->getValueAtTime(args.time);
bool swap = _swap->getValueAtTime(args.time);
Expand Down Expand Up @@ -326,11 +330,13 @@ AnaglyphPlugin::render(const RenderArguments &args)
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();
#ifndef NDEBUG
PixelComponentEnum dstComponents = _dstClip->getPixelComponents();

// do the rendering
assert(dstComponents == ePixelComponentRGBA);

#endif

switch (dstBitDepth) {
case eBitDepthUByte: {
ImageAnaglypher<unsigned char, 255> fred(*this);
Expand Down
10 changes: 9 additions & 1 deletion AppendClip/AppendClip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ class AppendClipPlugin
////////////////////////////////////////////////////////////////////////////////
// basic plugin render function, just a skelington to instantiate templates from

#ifndef NDEBUG
// make sure components are sane
static void
checkComponents(const Image &src,
Expand All @@ -220,6 +221,7 @@ checkComponents(const Image &src,
throwSuiteStatusException(kOfxStatErrImageFormat);
}
}
#endif

void
AppendClipPlugin::getSources(int firstFrame,
Expand Down Expand Up @@ -556,6 +558,7 @@ AppendClipPlugin::setupAndProcess(ImageBlenderBase &processor,
if ( !dst.get() ) {
throwSuiteStatusException(kOfxStatFailed);
}
# ifndef NDEBUG
BitDepthEnum dstBitDepth = dst->getPixelDepth();
PixelComponentEnum dstComponents = dst->getPixelComponents();
if ( ( dstBitDepth != _dstClip->getPixelDepth() ) ||
Expand All @@ -564,7 +567,8 @@ AppendClipPlugin::setupAndProcess(ImageBlenderBase &processor,
throwSuiteStatusException(kOfxStatFailed);
}
checkBadRenderScaleOrField(dst, args);

# endif

const double time = args.time;
int firstFrame;
_firstFrame->getValueAtTime(time, firstFrame);
Expand Down Expand Up @@ -594,6 +598,7 @@ AppendClipPlugin::setupAndProcess(ImageBlenderBase &processor,
//assert(0);
auto_ptr<const Image> src( ( _srcClip[clip0] && _srcClip[clip0]->isConnected() ) ?
_srcClip[clip0]->fetchImage(t0) : 0 );
# ifndef NDEBUG
if ( src.get() ) {
checkBadRenderScaleOrField(src, args);
BitDepthEnum srcBitDepth = src->getPixelDepth();
Expand All @@ -602,6 +607,7 @@ AppendClipPlugin::setupAndProcess(ImageBlenderBase &processor,
throwSuiteStatusException(kOfxStatErrImageFormat);
}
}
# endif
copyPixels( *this, args.renderWindow, args.renderScale, src.get(), dst.get() );

return;
Expand All @@ -613,6 +619,7 @@ AppendClipPlugin::setupAndProcess(ImageBlenderBase &processor,
auto_ptr<const Image> toImg( ( clip1 != -1 && _srcClip[clip1] && _srcClip[clip1]->isConnected() ) ?
_srcClip[clip1]->fetchImage(t1) : 0 );

# ifndef NDEBUG
// make sure bit depths are sane
if ( fromImg.get() ) {
checkBadRenderScaleOrField(fromImg, args);
Expand All @@ -622,6 +629,7 @@ AppendClipPlugin::setupAndProcess(ImageBlenderBase &processor,
checkBadRenderScaleOrField(toImg, args);
checkComponents(*toImg, dstBitDepth, dstComponents);
}
# endif

// set the images
processor.setDstImg( dst.get() );
Expand Down
2 changes: 2 additions & 0 deletions CImg/CImgFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ CImgFilterPluginHelperBase::setupAndCopy(PixelProcessorFilterBase & processor,
double mix,
bool maskInvert)
{
# ifndef NDEBUG
// src may not be valid over the renderWindow
//assert(srcPixelData &&
// srcBounds.x1 <= renderWindow.x1 && renderWindow.x2 <= srcBounds.x2 &&
Expand All @@ -361,6 +362,7 @@ CImgFilterPluginHelperBase::setupAndCopy(PixelProcessorFilterBase & processor,
if ( srcPixelData && (srcBitDepth != dstPixelDepth) ) {
throwSuiteStatusException(kOfxStatErrFormat);
}
# endif

if ( Coords::rectIsEmpty(renderWindow) ) {
return;
Expand Down
10 changes: 10 additions & 0 deletions CImg/CImgFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,11 @@ template <class Params, bool sourceIsOptional>
void
CImgFilterPluginHelper<Params, sourceIsOptional>::render(const OFX::RenderArguments &args)
{
# ifndef NDEBUG
if ( !_supportsRenderScale && ( (args.renderScale.x != 1.) || (args.renderScale.y != 1.) ) ) {
OFX::throwSuiteStatusException(kOfxStatFailed);
}
# endif

const double time = args.time;
const OfxPointD& renderScale = args.renderScale;
Expand All @@ -452,12 +454,14 @@ CImgFilterPluginHelper<Params, sourceIsOptional>::render(const OFX::RenderArgume
OFX::auto_ptr<const OFX::Image> src( ( _srcClip && _srcClip->isConnected() ) ?
_srcClip->fetchImage(args.time) : 0 );
if ( src.get() ) {
# ifndef NDEBUG
OFX::BitDepthEnum srcBitDepth = src->getPixelDepth();
OFX::PixelComponentEnum srcPixelComponents = src->getPixelComponents();
if ( (srcBitDepth != dstBitDepth) || (srcPixelComponents != dstPixelComponents) ) {
OFX::throwSuiteStatusException(kOfxStatErrImageFormat);
}
checkBadRenderScaleOrField(src, args);
# endif
#if 0
} else {
// src is considered black and transparent, just fill black to dst and return
Expand Down Expand Up @@ -1032,9 +1036,11 @@ void
CImgFilterPluginHelper<Params, sourceIsOptional>::getRegionsOfInterest(const OFX::RegionsOfInterestArguments &args,
OFX::RegionOfInterestSetter &rois)
{
# ifndef NDEBUG
if ( !_supportsRenderScale && ( (args.renderScale.x != 1.) || (args.renderScale.y != 1.) ) ) {
OFX::throwSuiteStatusException(kOfxStatFailed);
}
# endif
const double time = args.time;
const OfxRectD& regionOfInterest = args.regionOfInterest;
OfxRectD srcRoI;
Expand Down Expand Up @@ -1076,9 +1082,11 @@ bool
CImgFilterPluginHelper<Params, sourceIsOptional>::getRegionOfDefinition(const OFX::RegionOfDefinitionArguments &args,
OfxRectD &rod)
{
# ifndef NDEBUG
if ( !_supportsRenderScale && ( (args.renderScale.x != 1.) || (args.renderScale.y != 1.) ) ) {
OFX::throwSuiteStatusException(kOfxStatFailed);
}
# endif
Params params;
getValuesAtTime(args.time, params);

Expand Down Expand Up @@ -1108,9 +1116,11 @@ CImgFilterPluginHelper<Params, sourceIsOptional>::isIdentity(const OFX::IsIdenti
double & /*identityTime*/
, int& /*view*/, std::string& /*plane*/)
{
# ifndef NDEBUG
if ( !_supportsRenderScale && ( (args.renderScale.x != 1.) || (args.renderScale.y != 1.) ) ) {
OFX::throwSuiteStatusException(kOfxStatFailed);
}
# endif
const double time = args.time;
double mix;
_mix->getValueAtTime(time, mix);
Expand Down
12 changes: 12 additions & 0 deletions CImg/CImgOperator.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,11 @@ template <class Params>
void
CImgOperatorPluginHelper<Params>::render(const OFX::RenderArguments &args)
{
# ifndef NDEBUG
if ( !_supportsRenderScale && ( (args.renderScale.x != 1.) || (args.renderScale.y != 1.) ) ) {
OFX::throwSuiteStatusException(kOfxStatFailed);
}
# endif

const double time = args.time;
const OfxPointD& renderScale = args.renderScale;
Expand All @@ -155,6 +157,7 @@ CImgOperatorPluginHelper<Params>::render(const OFX::RenderArguments &args)

OFX::auto_ptr<const OFX::Image> srcA( ( _srcAClip && _srcAClip->isConnected() ) ?
_srcAClip->fetchImage(args.time) : 0 );
# ifndef NDEBUG
if ( srcA.get() ) {
OFX::BitDepthEnum srcABitDepth = srcA->getPixelDepth();
OFX::PixelComponentEnum srcAPixelComponents = srcA->getPixelComponents();
Expand All @@ -163,6 +166,7 @@ CImgOperatorPluginHelper<Params>::render(const OFX::RenderArguments &args)
}
checkBadRenderScaleOrField(srcA, args);
}
# endif

const void *srcAPixelData;
OfxRectI srcABounds;
Expand Down Expand Up @@ -198,6 +202,7 @@ CImgOperatorPluginHelper<Params>::render(const OFX::RenderArguments &args)

OFX::auto_ptr<const OFX::Image> srcB( ( _srcBClip && _srcBClip->isConnected() ) ?
_srcBClip->fetchImage(args.time) : 0 );
# ifndef NDEBUG
if ( srcB.get() ) {
OFX::BitDepthEnum srcBBitDepth = srcB->getPixelDepth();
OFX::PixelComponentEnum srcBPixelComponents = srcB->getPixelComponents();
Expand All @@ -206,6 +211,7 @@ CImgOperatorPluginHelper<Params>::render(const OFX::RenderArguments &args)
}
checkBadRenderScaleOrField(srcB, args);
}
# endif

const void *srcBPixelData;
OfxRectI srcBBounds;
Expand Down Expand Up @@ -550,9 +556,11 @@ void
CImgOperatorPluginHelper<Params>::getRegionsOfInterest(const OFX::RegionsOfInterestArguments &args,
OFX::RegionOfInterestSetter &rois)
{
# ifndef NDEBUG
if ( !_supportsRenderScale && ( (args.renderScale.x != 1.) || (args.renderScale.y != 1.) ) ) {
OFX::throwSuiteStatusException(kOfxStatFailed);
}
# endif
const double time = args.time;
const OfxRectD& regionOfInterest = args.regionOfInterest;
Params params;
Expand Down Expand Up @@ -587,9 +595,11 @@ bool
CImgOperatorPluginHelper<Params>::getRegionOfDefinition(const OFX::RegionOfDefinitionArguments &args,
OfxRectD &rod)
{
# ifndef NDEBUG
if ( !_supportsRenderScale && ( (args.renderScale.x != 1.) || (args.renderScale.y != 1.) ) ) {
OFX::throwSuiteStatusException(kOfxStatFailed);
}
# endif
Params params;
getValuesAtTime(args.time, params);

Expand Down Expand Up @@ -624,9 +634,11 @@ CImgOperatorPluginHelper<Params>::isIdentity(const OFX::IsIdentityArguments &arg
double & /*identityTime*/
, int& /*view*/, std::string& /*plane*/)
{
# ifndef NDEBUG
if ( !_supportsRenderScale && ( (args.renderScale.x != 1.) || (args.renderScale.y != 1.) ) ) {
OFX::throwSuiteStatusException(kOfxStatFailed);
}
# endif
const double time = args.time;
Params params;
getValuesAtTime(time, params);
Expand Down
4 changes: 3 additions & 1 deletion CheckerBoard/CheckerBoard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ CheckerBoardPlugin::setupAndProcess(CheckerBoardProcessorBase &processor,
if ( !dst.get() ) {
throwSuiteStatusException(kOfxStatFailed);
}
# ifndef NDEBUG
BitDepthEnum dstBitDepth = dst->getPixelDepth();
PixelComponentEnum dstComponents = dst->getPixelComponents();
if ( ( dstBitDepth != _dstClip->getPixelDepth() ) ||
Expand All @@ -425,7 +426,8 @@ CheckerBoardPlugin::setupAndProcess(CheckerBoardProcessorBase &processor,
throwSuiteStatusException(kOfxStatFailed);
}
checkBadRenderScaleOrField(dst, args);

# endif

// set the images
processor.setDstImg( dst.get() );

Expand Down
9 changes: 8 additions & 1 deletion ChromaKeyer/ChromaKeyer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ ChromaKeyerPlugin::setupAndProcess(ChromaKeyerProcessorBase &processor,
if ( !dst.get() ) {
throwSuiteStatusException(kOfxStatFailed);
}
# ifndef NDEBUG
BitDepthEnum dstBitDepth = dst->getPixelDepth();
PixelComponentEnum dstComponents = dst->getPixelComponents();
if ( ( dstBitDepth != _dstClip->getPixelDepth() ) ||
Expand All @@ -720,10 +721,13 @@ ChromaKeyerPlugin::setupAndProcess(ChromaKeyerProcessorBase &processor,
throwSuiteStatusException(kOfxStatFailed);
}
checkBadRenderScaleOrField(dst, args);
# endif

auto_ptr<const Image> src( ( _srcClip && _srcClip->isConnected() ) ?
_srcClip->fetchImage(time) : 0 );
auto_ptr<const Image> bg( ( _bgClip && _bgClip->isConnected() ) ?
_bgClip->fetchImage(time) : 0 );
# ifndef NDEBUG
if ( src.get() ) {
BitDepthEnum srcBitDepth = src->getPixelDepth();
//PixelComponentEnum srcComponents = src->getPixelComponents();
Expand All @@ -741,6 +745,7 @@ ChromaKeyerPlugin::setupAndProcess(ChromaKeyerProcessorBase &processor,
}
checkBadRenderScaleOrField(bg, args);
}
# endif

// auto ptr for the masks.
auto_ptr<const Image> inMask( ( _inMaskClip && _inMaskClip->isConnected() ) ?
Expand Down Expand Up @@ -778,17 +783,19 @@ ChromaKeyerPlugin::render(const RenderArguments &args)
{
// instantiate the render code based on the pixel depth of the dst clip
BitDepthEnum dstBitDepth = _dstClip->getPixelDepth();
PixelComponentEnum dstComponents = _dstClip->getPixelComponents();

assert( kSupportsMultipleClipPARs || !_srcClip || !_srcClip->isConnected() || _srcClip->getPixelAspectRatio() == _dstClip->getPixelAspectRatio() );
assert( kSupportsMultipleClipDepths || !_srcClip || !_srcClip->isConnected() || _srcClip->getPixelDepth() == _dstClip->getPixelDepth() );

# ifndef NDEBUG
PixelComponentEnum dstComponents = _dstClip->getPixelComponents();
if (dstComponents != ePixelComponentRGBA) {
setPersistentMessage(Message::eMessageError, "", "OFX Host dit not take into account output components");
throwSuiteStatusException(kOfxStatErrImageFormat);

return;
}
# endif

switch (dstBitDepth) {
//case eBitDepthUByte: {
Expand Down
Loading

0 comments on commit b8c0ab6

Please sign in to comment.