尝试修复粉紫屏未果

This commit is contained in:
2026-01-16 21:11:24 +08:00
parent 3f774dfa53
commit e851653fa3
30 changed files with 1377 additions and 238 deletions
+13 -20
View File
@@ -406,23 +406,14 @@ olive::plugin::OliveClipInstance::getImage(OfxTime time,
static_cast<int>(std::floor(rod_d.y1)),
static_cast<int>(std::ceil(rod_d.x2)),
static_cast<int>(std::ceil(rod_d.y2)) };
(void)optionalBounds;
// Always return full-frame images to keep input data consistent.
OfxRectI bounds = rod;
if (optionalBounds) {
bounds.x1 = static_cast<int>(std::floor(optionalBounds->x1));
bounds.y1 = static_cast<int>(std::floor(optionalBounds->y1));
bounds.x2 = static_cast<int>(std::ceil(optionalBounds->x2));
bounds.y2 = static_cast<int>(std::ceil(optionalBounds->y2));
}
// Clamp bounds to ROD to keep host/plugin coords consistent.
bounds.x1 = std::max(bounds.x1, rod.x1);
bounds.y1 = std::max(bounds.y1, rod.y1);
bounds.x2 = std::min(bounds.x2, rod.x2);
bounds.y2 = std::min(bounds.y2, rod.y2);
if (name_ == "Output") {
if (!images_.contains(time)) {
// make a new ref counted image
images_.insert(time, std::make_shared<Image>(*const_cast<OliveClipInstance *>(this),
images_.insert(time, new Image(*const_cast<OliveClipInstance *>(this),
params_, bounds, rod, true));
}
@@ -435,13 +426,13 @@ olive::plugin::OliveClipInstance::getImage(OfxTime time,
images_[time]->EnsureAllocatedFromParams(params_, bounds, rod, true);
// return it
return images_[time].get();
return images_[time];
} else {
if (images_.contains(time)) {
std::shared_ptr<Image> image = images_.value(time);
Image* image = images_.value(time);
image->EnsureAllocatedFromParams(params_, bounds, rod, false);
image->addReference();
return image.get();
return image;
}
// Fetch on demand for the input clip.
@@ -455,7 +446,7 @@ olive::plugin::OliveClipInstance::getImage(OfxTime time,
}
}
std::shared_ptr<OFX::Host::ImageEffect::Image>
OFX::Host::ImageEffect::Image*
olive::plugin::OliveClipInstance::getOutputImage(OfxTime time)
{
if (images_.contains(time)) {
@@ -469,7 +460,7 @@ olive::plugin::OliveClipInstance::getOutputImage(OfxTime time)
static_cast<int>(std::ceil(rod_d.y2)) };
OfxRectI bounds = rod;
auto image = std::make_shared<Image>(*this, params_, bounds, rod, true);
auto image = new Image(*this, params_, bounds, rod, true);
images_.insert(time, image);
return image;
}
@@ -530,18 +521,18 @@ void olive::plugin::OliveClipInstance::setInputTexture(TexturePtr texture, OfxTi
static_cast<int>(std::ceil(rod_d.x2)),
static_cast<int>(std::ceil(rod_d.y2)) };
std::shared_ptr<Image> image;
Image* image;
if (images_.contains(time)) {
image = images_.value(time);
image->EnsureAllocatedFromParams(params_, bounds, regionOfDefinition,
false);
} else {
image = std::make_shared<Image>(*this, params_, bounds,
image = new Image(*this, params_, bounds,
regionOfDefinition, false);
images_.insert(time, image);
}
uint8_t *dst = image->data();
uint8_t *dst = (uint8_t*)image->data();
if (!dst) {
return;
}
@@ -603,6 +594,8 @@ copy_pixels:
std::memcpy(dst + y * dst_row_bytes, src + y * src_row_bytes,
copy_bytes);
}
}
void olive::plugin::OliveClipInstance::setOutputTexture(TexturePtr texture,
+2 -2
View File
@@ -44,7 +44,7 @@ public:
{
params_ = params;
}
std::shared_ptr<OFX::Host::ImageEffect::Image> getOutputImage(OfxTime time);
OFX::Host::ImageEffect::Image* getOutputImage(OfxTime time);
const std::string &getUnmappedBitDepth() const override;
const std::string &getUnmappedComponents() const override;
@@ -83,7 +83,7 @@ private:
OfxRectD defaultRegionOfDefinitions_;
std::string name_;
QMap<OfxTime,std::shared_ptr<Image>> images_;
QMap<OfxTime, Image*> images_;
#ifdef OFX_SUPPORTS_OPENGLRENDER
QMap<OfxTime, TexturePtr> input_textures_;
QMap<OfxTime, TexturePtr> output_textures_;
+13
View File
@@ -160,6 +160,19 @@ const std::string &OlivePluginInstance::getDefaultOutputFielding() const
return FieldOrderForParams(params_);
}
void OlivePluginInstance::setNode(std::shared_ptr<PluginNode> node)
{
node_ = node;
for (const auto &entry : getParams()) {
if (!entry.second) {
continue;
}
if (auto *bound = dynamic_cast<NodeBoundParam *>(entry.second)) {
bound->SetNode(node_);
}
}
}
OfxStatus OlivePluginInstance::vmessage(const char *type, const char *id,
const char *format, va_list args)
{
+3 -2
View File
@@ -74,9 +74,10 @@ public:
{
this->params_=params;
}
void setNode(std::shared_ptr<PluginNode> node)
void setNode(std::shared_ptr<PluginNode> node);
std::shared_ptr<PluginNode> node() const
{
node_ = node;
return node_;
}
void setOpenGLEnabled(bool enabled)
{
+4 -1
View File
@@ -21,10 +21,13 @@
#define OLIVE_EDITOR_PLUGIN_IMAGE_H
#include "ofxCore.h"
#include "ofxImageEffect.h"
#include "ofxhClip.h"
#include "olive/core/render/pixelformat.h"
#include "render/loopmode.h"
#include "render/videoparams.h"
#include <cstdint>
#include <qtypes.h>
#include <string>
#include <vector>
namespace olive
@@ -41,7 +44,7 @@ public:
bool clear = true);
~Image();
uint8_t *data() {
return image_.empty() ? nullptr : image_.data();
return (uint8_t *)getPointerProperty(kOfxImagePropData);
}
int width();
int height();
+84 -13
View File
@@ -42,7 +42,14 @@ inline QString ParamChangeLabel(const OFX::Host::Param::Descriptor &descriptor)
void SubmitUndoCommand(const std::shared_ptr<PluginNode> &node,
UndoCommand *command, const QString &label);
class PushbuttonInstance : public OFX::Host::Param::PushbuttonInstance {
class NodeBoundParam {
public:
virtual ~NodeBoundParam() = default;
virtual void SetNode(const std::shared_ptr<PluginNode> &node) = 0;
};
class PushbuttonInstance : public OFX::Host::Param::PushbuttonInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor *_descriptor;
@@ -54,9 +61,14 @@ public:
{
_descriptor = &descriptor;
};
void SetNode(const std::shared_ptr<PluginNode> &new_node) override
{
node = new_node;
}
};
class IntegerInstance : public OFX::Host::Param::IntegerInstance {
class IntegerInstance : public OFX::Host::Param::IntegerInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> _node;
OFX::Host::Param::Descriptor& _descriptor;
@@ -69,6 +81,10 @@ public:
, _node(node)
, _descriptor(descriptor)
{}
void SetNode(const std::shared_ptr<PluginNode> &new_node) override
{
_node = new_node;
}
OfxStatus get(int &a)
{
if (!_node) {
@@ -137,7 +153,8 @@ public:
}
};
class DoubleInstance : public OFX::Host::Param::DoubleInstance {
class DoubleInstance : public OFX::Host::Param::DoubleInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor& _descriptor;
@@ -151,6 +168,10 @@ public:
{
(void)name;
}
void SetNode(const std::shared_ptr<PluginNode> &new_node) override
{
node = new_node;
}
OfxStatus get(double& data)
{
if (!node) {
@@ -219,7 +240,8 @@ public:
}
};
class BooleanInstance : public OFX::Host::Param::BooleanInstance {
class BooleanInstance : public OFX::Host::Param::BooleanInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor& _descriptor;
@@ -233,6 +255,10 @@ public:
{
(void)name;
}
void SetNode(const std::shared_ptr<PluginNode> &new_node) override
{
node = new_node;
}
OfxStatus get(bool& data)
{
if (!node) {
@@ -293,7 +319,8 @@ public:
}
};
class ChoiceInstance : public OFX::Host::Param::ChoiceInstance {
class ChoiceInstance : public OFX::Host::Param::ChoiceInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor& _descriptor;
@@ -307,6 +334,10 @@ public:
{
(void)name;
}
void SetNode(const std::shared_ptr<PluginNode> &new_node) override
{
node = new_node;
}
OfxStatus get(int& data)
{
if (!node) {
@@ -367,7 +398,8 @@ public:
}
};
class RGBAInstance : public OFX::Host::Param::RGBAInstance {
class RGBAInstance : public OFX::Host::Param::RGBAInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor& _descriptor;
@@ -381,6 +413,10 @@ public:
{
(void)name;
}
void SetNode(const std::shared_ptr<PluginNode> &new_node) override
{
node = new_node;
}
OfxStatus get(double& r,double& g,double& b,double& a)
{
if (!node) {
@@ -472,7 +508,8 @@ public:
};
class RGBInstance : public OFX::Host::Param::RGBInstance {
class RGBInstance : public OFX::Host::Param::RGBInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor& _descriptor;
@@ -486,6 +523,10 @@ public:
{
(void)name;
}
void SetNode(const std::shared_ptr<PluginNode> &new_node) override
{
node = new_node;
}
OfxStatus get(double& r,double& g,double& b)
{
if (!node) {
@@ -568,7 +609,8 @@ public:
}
};
class Double2DInstance : public OFX::Host::Param::Double2DInstance {
class Double2DInstance : public OFX::Host::Param::Double2DInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor& _descriptor;
@@ -582,6 +624,10 @@ public:
{
(void)name;
}
void SetNode(const std::shared_ptr<PluginNode> &new_node) override
{
node = new_node;
}
OfxStatus get(double& x,double& y)
{
if (!node) {
@@ -653,7 +699,8 @@ public:
}
};
class Integer2DInstance : public OFX::Host::Param::Integer2DInstance {
class Integer2DInstance : public OFX::Host::Param::Integer2DInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor& _descriptor;
@@ -667,6 +714,10 @@ public:
{
(void)name;
}
void SetNode(const std::shared_ptr<PluginNode> &new_node) override
{
node = new_node;
}
OfxStatus get(int& x,int& y)
{
if (!node) {
@@ -738,7 +789,8 @@ public:
}
};
class Double3DInstance : public OFX::Host::Param::Double3DInstance {
class Double3DInstance : public OFX::Host::Param::Double3DInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor& _descriptor;
@@ -753,6 +805,10 @@ public:
{
(void)name;
}
void SetNode(const std::shared_ptr<PluginNode> &new_node) override
{
node = new_node;
}
OfxStatus get(double& x,double& y,double& z)
{
if (!node) {
@@ -832,7 +888,8 @@ public:
}
};
class Integer3DInstance : public OFX::Host::Param::Integer3DInstance {
class Integer3DInstance : public OFX::Host::Param::Integer3DInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor& _descriptor;
@@ -847,6 +904,10 @@ public:
{
(void)name;
}
void SetNode(const std::shared_ptr<PluginNode> &new_node) override
{
node = new_node;
}
OfxStatus get(int& x,int& y,int& z)
{
if (!node) {
@@ -926,7 +987,8 @@ public:
}
};
class StringInstance : public OFX::Host::Param::StringInstance {
class StringInstance : public OFX::Host::Param::StringInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor& _descriptor;
@@ -941,6 +1003,10 @@ public:
{
(void)name;
}
void SetNode(const std::shared_ptr<PluginNode> &new_node) override
{
node = new_node;
}
OfxStatus get(std::string &data)
{
if (!node) {
@@ -1002,7 +1068,8 @@ public:
}
};
class CustomInstance : public OFX::Host::Param::CustomInstance {
class CustomInstance : public OFX::Host::Param::CustomInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor& _descriptor;
@@ -1017,6 +1084,10 @@ public:
{
(void)name;
}
void SetNode(const std::shared_ptr<PluginNode> &new_node) override
{
node = new_node;
}
OfxStatus get(std::string &data)
{
if (!node) {