Fix OFX plugin render failures and stabilize integration tests

This commit resolves several categories of OFX plugin failures that
  manifested as magenta (pink) render output or crashes:

  1. Param default-value initialization
     - IntegerInstance, DoubleInstance, BooleanInstance, ChoiceInstance,
       and StringInstance now read kOfxParamPropDefault from the descriptor
       at construction time. Previously, when no PluginNode was attached
       (integration-test mode), get() returned 0/0.0/false, causing
       generator plugins to receive invalid extent/format/PAR values and
       crash in coordinate assertions.
     - IntegerInstance also fixed uninitialized `id` that caused
       kOfxStatErrBadHandle in CImg plugins.

  2. Clip property initialization
     - newClipInstance() now seeds pixelDepth and components from the
       host VideoParams instead of leaving them as None. This prevents
       Transform3x3Plugin and similar plugins from asserting on
       getPixelComponentCount() during fetchClip inside createInstance.
     - getAspectRatio() and getProjectPixelAspectRatio() now fall back
       to 1.0 when the project's PAR is not yet set, avoiding division-
       by-zero in coordinate conversion.

  3. Frame-rate and time-base preservation
     - setInputTexture() no longer overwrites the clip's frame_rate or
       time_base with the input texture's values. Multi-input plugins
       were crashing because setupClipPreferencesArgs throws when inputs
     have mismatched rates.

  4. Render loop hardening
     - getClipPreferences() is now wrapped in try/catch so that frame-
       rate mismatch exceptions mark render failure instead of aborting
       the render thread.
     - getRegionOfInterestAction() treats kOfxStatErrBadHandle as non-
       fatal and falls back to default RoI.
     - RenderPlugin syncs all clip instances after setVideoParam so that
       getAspectRatio/getFrameRate return valid values before
       createInstanceAction queries them.

  5. Test suite updates
     - All PluginMisc tests now use F32 input to match the host pipeline
       default.
     - CreateGradientTexture fixed to support F32 pixel format.
     - Added CImgBilateral and CImgGuided_MultiInput tests.
     - Secret parameters are now registered as hidden Node inputs so that
       getClipPreferences can read them (fixes generator pink screen).

  6. Debug logging in HostSupport
     - clipGetImage and clipGetRegionOfDefinition now catch exceptions
       and log the failing clip name for easier debugging.
This commit is contained in:
2026-05-15 21:32:28 +08:00
parent e85c6cf60a
commit 7ebfebb29a
8 changed files with 308 additions and 66 deletions
+15 -1
View File
@@ -346,7 +346,11 @@ const std::string &olive::plugin::OliveClipInstance::getPremult() const
}
double olive::plugin::OliveClipInstance::getAspectRatio() const
{
return params_.pixel_aspect_ratio().toDouble();
double par = params_.pixel_aspect_ratio().toDouble();
if (par == 0.0) {
return 1.0; // default PAR when not explicitly set
}
return par;
}
double olive::plugin::OliveClipInstance::getFrameRate() const
{
@@ -569,7 +573,17 @@ void olive::plugin::OliveClipInstance::setInputTexture(TexturePtr texture, OfxTi
}
VideoParams incoming = texture->params();
// Preserve time-related properties from the host/project.
// The frame rate of an OFX clip should reflect the project's frame rate,
// not the individual input texture's frame rate. If different inputs
// have different frame rates, setupClipPreferencesArgs throws an exception.
rational saved_frame_rate = params_.frame_rate();
rational saved_time_base = params_.time_base();
this->params_ = incoming;
params_.set_frame_rate(saved_frame_rate);
params_.set_time_base(saved_time_base);
// Note: We do NOT call setPixelDepth/setComponents here because
// those should be set by getClipPreferences to reflect the PLUGIN's
// preferred format, not the input texture's format.
+48 -5
View File
@@ -286,10 +286,11 @@ void OlivePluginInstance::getProjectExtent(double &xSize, double &ySize) const
}
double OlivePluginInstance::getProjectPixelAspectRatio() const
{
return Current::getInstance()
.currentVideoParams()
.pixel_aspect_ratio()
.toDouble();
double par = params_.pixel_aspect_ratio().toDouble();
if (par == 0.0) {
return 1.0; // default PAR when not explicitly set
}
return par;
}
double OlivePluginInstance::getFrameRate() const
{
@@ -550,7 +551,49 @@ OFX::Host::ImageEffect::ClipInstance *OlivePluginInstance::newClipInstance(
int index)
{
// Create a new clip instance
OFX::Host::ImageEffect::ClipInstance* clipInstance = new OliveClipInstance(plugin, *descriptor, params_);
OliveClipInstance* clipInstance = new OliveClipInstance(plugin, *descriptor, params_);
// Initialize base class clip properties from VideoParams so that
// setupClipPreferencesArgs and plugin constructors (which may fetch
// clips and query their properties before getClipPreferences is called)
// have valid defaults instead of kOfxImageComponentNone / kOfxBitDepthNone.
std::string depth = kOfxBitDepthFloat; // host default
std::string comp = kOfxImageComponentRGBA; // host default
switch (params_.format()) {
case core::PixelFormat::U8:
depth = kOfxBitDepthByte;
break;
case core::PixelFormat::U16:
depth = kOfxBitDepthShort;
break;
case core::PixelFormat::F16:
depth = kOfxBitDepthHalf;
break;
case core::PixelFormat::F32:
depth = kOfxBitDepthFloat;
break;
default:
break; // keep F32 default
}
switch (params_.channel_count()) {
case 1:
comp = kOfxImageComponentAlpha;
break;
case 3:
comp = kOfxImageComponentRGB;
break;
case 4:
comp = kOfxImageComponentRGBA;
break;
default:
break; // keep RGBA default
}
clipInstance->setPixelDepth(depth);
clipInstance->setComponents(comp);
return clipInstance;
}
+2 -2
View File
@@ -67,7 +67,8 @@ public:
: Instance(instance._plugin, *instance._descriptor, instance._context,
instance._interactive)
{
_clips=instance._clips;
// Do NOT shallow-copy _clips: Instance::~Instance() deletes them,
// which would cause a double-free. Clips are re-created in populate().
_created=instance._created;
_clipPrefsDirty=instance._clipPrefsDirty;
_continuousSamples=instance._continuousSamples;
@@ -75,7 +76,6 @@ public:
_outputPreMultiplication=instance._outputPreMultiplication;
_outputFielding=instance._outputFielding;
_outputFrameRate=instance._outputFrameRate;
}
explicit OlivePluginInstance(Instance & instance):Instance(instance){};
~OlivePluginInstance() override;
+35 -5
View File
@@ -112,7 +112,16 @@ public:
: OFX::Host::Param::IntegerInstance(descriptor, paramSet)
, _node(node)
, _descriptor(descriptor)
{}
, id(_descriptor.getName().c_str())
{
try {
value_ = _descriptor.getProperties().getIntProperty(kOfxParamPropDefault);
has_value_ = true;
} catch (...) {
value_ = 0;
has_value_ = false;
}
}
void SetNode(const std::shared_ptr<PluginNode> &new_node) override
{
_node = new_node;
@@ -128,7 +137,7 @@ public:
}
QVariant variant=_node->GetStandardValue(id);
if (variant.typeId()==QVariant::Int) {
if (variant.canConvert<int>()) {
a=variant.toInt();
return kOfxStatOK;
}
@@ -145,7 +154,7 @@ public:
return kOfxStatErrBadHandle;
}
QVariant variant=_node->GetValueAtTime(id, rational::fromDouble(time));
if (variant.typeId()==QVariant::Int) {
if (variant.canConvert<int>()) {
data=variant.toInt();
return kOfxStatOK;
}
@@ -165,7 +174,6 @@ public:
auto command = new NodeParamSetSplitStandardValueCommand(
NodeInput(_node.get(), _descriptor.getName().c_str()), split);
SubmitUndoCommand(_node, command, ParamChangeLabel(_descriptor));
id=_descriptor.getName().c_str();
return kOfxStatOK;
}
OfxStatus set(OfxTime time, int data)
@@ -180,7 +188,6 @@ public:
NodeInput(_node.get(), _descriptor.getName().c_str()),
rational::fromDouble(time), data, 0, command, true);
SubmitUndoCommand(_node, command, ParamChangeLabel(_descriptor));
id=_descriptor.getName().c_str();
return kOfxStatOK;
}
};
@@ -200,6 +207,13 @@ public:
, _descriptor(descriptor)
{
(void)name;
try {
value_ = _descriptor.getProperties().getDoubleProperty(kOfxParamPropDefault);
has_value_ = true;
} catch (...) {
value_ = 0.0;
has_value_ = false;
}
}
void SetNode(const std::shared_ptr<PluginNode> &new_node) override
{
@@ -315,6 +329,8 @@ public:
, _descriptor(descriptor)
{
(void)name;
value_ = DefaultValue();
has_value_ = true;
}
void SetNode(const std::shared_ptr<PluginNode> &new_node) override
{
@@ -403,6 +419,13 @@ public:
, _descriptor(descriptor)
{
(void)name;
try {
value_ = _descriptor.getProperties().getIntProperty(kOfxParamPropDefault);
has_value_ = true;
} catch (...) {
value_ = 0;
has_value_ = false;
}
}
void SetNode(const std::shared_ptr<PluginNode> &new_node) override
{
@@ -1135,6 +1158,13 @@ public:
, _descriptor(descriptor)
{
(void)name;
try {
value_ = _descriptor.getProperties().getStringProperty(kOfxParamPropDefault);
has_value_ = true;
} catch (...) {
value_.clear();
has_value_ = false;
}
}
void SetNode(const std::shared_ptr<PluginNode> &new_node) override
{