format: reformatting files

This commit is contained in:
2026-07-13 15:30:43 +08:00
parent 7522543c48
commit e5eeaddf2f
511 changed files with 274803 additions and 207140 deletions
+83 -91
View File
@@ -41,7 +41,8 @@ extern "C" {
#include <libswscale/swscale.h>
#include <libavutil/pixdesc.h>
}
namespace {
namespace
{
const std::string kBitDepthNoneStr(kOfxBitDepthNone);
const std::string kBitDepthByteStr(kOfxBitDepthByte);
const std::string kBitDepthShortStr(kOfxBitDepthShort);
@@ -117,16 +118,16 @@ static bool PackedDstInfo(AVPixelFormat fmt, int *channels,
}
}
static olive::AVFramePtr ReadbackTextureToFrame(olive::TexturePtr texture,
const olive::VideoParams &params)
static olive::AVFramePtr
ReadbackTextureToFrame(olive::TexturePtr texture,
const olive::VideoParams &params)
{
if (!texture || texture->IsDummy() || !texture->renderer()) {
return nullptr;
}
AVPixelFormat pix_fmt =
olive::FFmpegUtils::GetFFmpegPixelFormat(params.format(),
params.channel_count());
AVPixelFormat pix_fmt = olive::FFmpegUtils::GetFFmpegPixelFormat(
params.format(), params.channel_count());
if (pix_fmt == AV_PIX_FMT_NONE) {
return nullptr;
}
@@ -145,15 +146,15 @@ static olive::AVFramePtr ReadbackTextureToFrame(olive::TexturePtr texture,
return nullptr;
}
const int linesize_pixels = BytesToPixels(frame->linesize[0], params);
texture->renderer()->DownloadFromTexture(texture->id(), params,
frame->data[0],
linesize_pixels);
texture->renderer()->DownloadFromTexture(
texture->id(), params, frame->data[0], linesize_pixels);
return frame;
}
olive::VideoParams rgba_params(
params.width(), params.height(), olive::core::PixelFormat::U8, 4,
params.pixel_aspect_ratio(), params.interlacing(), params.divider());
olive::VideoParams rgba_params(params.width(), params.height(),
olive::core::PixelFormat::U8, 4,
params.pixel_aspect_ratio(),
params.interlacing(), params.divider());
olive::AVFramePtr rgba_frame = olive::CreateAVFramePtr();
rgba_frame->format = AV_PIX_FMT_RGBA;
@@ -165,9 +166,8 @@ static olive::AVFramePtr ReadbackTextureToFrame(olive::TexturePtr texture,
const int linesize_pixels =
BytesToPixels(rgba_frame->linesize[0], rgba_params);
texture->renderer()->DownloadFromTexture(texture->id(), rgba_params,
rgba_frame->data[0],
linesize_pixels);
texture->renderer()->DownloadFromTexture(
texture->id(), rgba_params, rgba_frame->data[0], linesize_pixels);
olive::AVFramePtr dst = olive::CreateAVFramePtr();
dst->format = pix_fmt;
@@ -179,9 +179,8 @@ static olive::AVFramePtr ReadbackTextureToFrame(olive::TexturePtr texture,
SwsContext *sws_ctx = sws_getContext(
rgba_frame->width, rgba_frame->height,
static_cast<AVPixelFormat>(rgba_frame->format),
dst->width, dst->height, pix_fmt, SWS_POINT,
nullptr, nullptr, nullptr);
static_cast<AVPixelFormat>(rgba_frame->format), dst->width, dst->height,
pix_fmt, SWS_POINT, nullptr, nullptr, nullptr);
if (!sws_ctx) {
return rgba_frame;
}
@@ -218,9 +217,7 @@ static olive::AVFramePtr ConvertPackedFloatFrame(olive::AVFramePtr src,
return nullptr;
}
auto clamp01 = [](float v) -> float {
return std::clamp(v, 0.0f, 1.0f);
};
auto clamp01 = [](float v) -> float { return std::clamp(v, 0.0f, 1.0f); };
for (int y = 0; y < src->height; ++y) {
const float *src_row = reinterpret_cast<const float *>(
@@ -242,18 +239,14 @@ static olive::AVFramePtr ConvertPackedFloatFrame(olive::AVFramePtr src,
continue;
}
dst_row_u16[x * dst_channels + 0] =
static_cast<uint16_t>(
std::lround(clamp01(r) * 65535.0f));
static_cast<uint16_t>(std::lround(clamp01(r) * 65535.0f));
dst_row_u16[x * dst_channels + 1] =
static_cast<uint16_t>(
std::lround(clamp01(g) * 65535.0f));
static_cast<uint16_t>(std::lround(clamp01(g) * 65535.0f));
dst_row_u16[x * dst_channels + 2] =
static_cast<uint16_t>(
std::lround(clamp01(b) * 65535.0f));
static_cast<uint16_t>(std::lround(clamp01(b) * 65535.0f));
if (dst_channels == 4) {
dst_row_u16[x * dst_channels + 3] =
static_cast<uint16_t>(
std::lround(clamp01(a) * 65535.0f));
dst_row_u16[x * dst_channels + 3] = static_cast<uint16_t>(
std::lround(clamp01(a) * 65535.0f));
}
}
} else {
@@ -270,18 +263,14 @@ static olive::AVFramePtr ConvertPackedFloatFrame(olive::AVFramePtr src,
continue;
}
dst_row[x * dst_channels + 0] =
static_cast<uint8_t>(
std::lround(clamp01(r) * 255.0f));
static_cast<uint8_t>(std::lround(clamp01(r) * 255.0f));
dst_row[x * dst_channels + 1] =
static_cast<uint8_t>(
std::lround(clamp01(g) * 255.0f));
static_cast<uint8_t>(std::lround(clamp01(g) * 255.0f));
dst_row[x * dst_channels + 2] =
static_cast<uint8_t>(
std::lround(clamp01(b) * 255.0f));
static_cast<uint8_t>(std::lround(clamp01(b) * 255.0f));
if (dst_channels == 4) {
dst_row[x * dst_channels + 3] =
static_cast<uint8_t>(
std::lround(clamp01(a) * 255.0f));
static_cast<uint8_t>(std::lround(clamp01(a) * 255.0f));
}
}
}
@@ -385,7 +374,7 @@ bool olive::plugin::OliveClipInstance::getConnected() const
return true;
}
#endif
if(images_.empty())
if (images_.empty())
return false;
return true;
}
@@ -394,7 +383,7 @@ bool olive::plugin::OliveClipInstance::getConnected() const
return true;
}
#endif
if(images_.empty())
if (images_.empty())
return false;
return true;
}
@@ -427,8 +416,9 @@ olive::plugin::OliveClipInstance::getImage(OfxTime time,
if (name_ == "Output") {
if (!images_.contains(time)) {
// make a new ref counted image
images_.insert(time, new Image(*const_cast<OliveClipInstance *>(this),
params_, bounds, rod, true));
images_.insert(time,
new Image(*const_cast<OliveClipInstance *>(this),
params_, bounds, rod, true));
}
// add another reference to the member image for this fetch
@@ -443,7 +433,7 @@ olive::plugin::OliveClipInstance::getImage(OfxTime time,
return images_[time];
} else {
if (images_.contains(time)) {
Image* image = images_.value(time);
Image *image = images_.value(time);
image->EnsureAllocatedFromParams(params_, bounds, rod, false);
image->addReference();
return image;
@@ -468,13 +458,13 @@ olive::plugin::OliveClipInstance::getImage(OfxTime time,
preferred_params.channel_count() <= 0) {
return nullptr;
}
Image *image = new Image(*this, preferred_params, bounds, rod, true);
return image;
}
}
OFX::Host::ImageEffect::Image*
OFX::Host::ImageEffect::Image *
olive::plugin::OliveClipInstance::getOutputImage(OfxTime time)
{
if (images_.contains(time)) {
@@ -504,10 +494,11 @@ olive::plugin::OliveClipInstance::getOutputImage(OfxTime time)
return image;
}
olive::VideoParams olive::plugin::OliveClipInstance::getPluginPreferredParams() const
olive::VideoParams
olive::plugin::OliveClipInstance::getPluginPreferredParams() const
{
VideoParams result = params_;
// Get format from base class _pixelDepth (set by getClipPreferences)
const std::string &depth = getPixelDepth();
if (!depth.empty()) {
@@ -521,7 +512,7 @@ olive::VideoParams olive::plugin::OliveClipInstance::getPluginPreferredParams()
result.set_format(core::PixelFormat::F32);
}
}
// Get channel count from base class _components (set by getClipPreferences)
const std::string &comp = getComponents();
if (!comp.empty()) {
@@ -533,7 +524,7 @@ olive::VideoParams olive::plugin::OliveClipInstance::getPluginPreferredParams()
result.set_channel_count(1);
}
}
return result;
}
OfxRectD
@@ -584,21 +575,24 @@ void olive::plugin::OliveClipInstance::setParams(const VideoParams &params)
setComponents(getUnmappedComponents());
}
void olive::plugin::OliveClipInstance::setInputTexture(TexturePtr texture, OfxTime time, bool readback_cpu){
void olive::plugin::OliveClipInstance::setInputTexture(TexturePtr texture,
OfxTime time,
bool readback_cpu)
{
if (!texture) {
return;
}
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
@@ -622,9 +616,8 @@ void olive::plugin::OliveClipInstance::setInputTexture(TexturePtr texture, OfxTi
if (!frame || !frame->data[0]) {
frame = ReadbackTextureToFrame(texture, params_);
}
AVPixelFormat expected_fmt =
FFmpegUtils::GetFFmpegPixelFormat(params_.format(),
params_.channel_count());
AVPixelFormat expected_fmt = FFmpegUtils::GetFFmpegPixelFormat(
params_.format(), params_.channel_count());
if (expected_fmt == AV_PIX_FMT_NONE) {
return;
}
@@ -635,21 +628,20 @@ void olive::plugin::OliveClipInstance::setInputTexture(TexturePtr texture, OfxTi
static_cast<int>(std::ceil(rod_d.x2)),
static_cast<int>(std::ceil(rod_d.y2)) };
Image* image;
Image *image;
if (images_.contains(time)) {
image = images_.value(time);
image->EnsureAllocatedFromParams(params_, bounds, regionOfDefinition,
false);
} else {
pruneImagesCache();
image = new Image(*this, params_, bounds,
regionOfDefinition, false);
image = new Image(*this, params_, bounds, regionOfDefinition, false);
image->EnsureAllocatedFromParams(params_, bounds, regionOfDefinition,
false);
images_.insert(time, image);
}
uint8_t *dst = (uint8_t*)image->data();
uint8_t *dst = (uint8_t *)image->data();
if (!dst) {
return;
}
@@ -665,36 +657,38 @@ void olive::plugin::OliveClipInstance::setInputTexture(TexturePtr texture, OfxTi
// and SIGSEGV on Apple Silicon (where (int)NaN often evaluates to 0 or
// INT_MIN, causing huge offsets into bgrid._data).
if (params_.format() == core::PixelFormat::F32) {
const float *fptr = reinterpret_cast<const float*>(frame->data[0]);
const float *fptr = reinterpret_cast<const float *>(frame->data[0]);
int row_floats = frame->linesize[0] / static_cast<int>(sizeof(float));
bool has_nan = false;
for (int y = 0; y < params_.height() && !has_nan; ++y) {
for (int x = 0; x < params_.width() * params_.channel_count(); ++x) {
for (int x = 0; x < params_.width() * params_.channel_count();
++x) {
float v = fptr[y * row_floats + x];
if (std::isnan(v) || std::isinf(v)) {
qWarning() << "[PLUGIN] NaN/Inf detected in input frame at pixel ("
<< x / params_.channel_count() << "," << y
<< ") channel=" << (x % params_.channel_count())
<< " value=" << v;
qWarning()
<< "[PLUGIN] NaN/Inf detected in input frame at pixel ("
<< x / params_.channel_count() << "," << y
<< ") channel=" << (x % params_.channel_count())
<< " value=" << v;
has_nan = true;
break;
}
}
}
if (has_nan) {
qWarning() << "[PLUGIN] Filling corrupted input frame with black to avoid CImg crash";
qWarning()
<< "[PLUGIN] Filling corrupted input frame with black to avoid CImg crash";
std::memset(dst, 0, image->row_bytes() * image->height());
return;
}
}
AVFramePtr src_frame = frame;
if (frame->format != expected_fmt ||
frame->width != params_.width() ||
if (frame->format != expected_fmt || frame->width != params_.width() ||
frame->height != params_.height()) {
if (PackedFloatChannels(static_cast<AVPixelFormat>(frame->format)) > 0) {
AVFramePtr converted =
ConvertPackedFloatFrame(frame, expected_fmt);
if (PackedFloatChannels(static_cast<AVPixelFormat>(frame->format)) >
0) {
AVFramePtr converted = ConvertPackedFloatFrame(frame, expected_fmt);
if (converted) {
src_frame = converted;
goto copy_pixels;
@@ -710,9 +704,8 @@ void olive::plugin::OliveClipInstance::setInputTexture(TexturePtr texture, OfxTi
SwsContext *sws_ctx = sws_getContext(
frame->width, frame->height,
static_cast<AVPixelFormat>(frame->format),
converted->width, converted->height,
static_cast<AVPixelFormat>(converted->format),
static_cast<AVPixelFormat>(frame->format), converted->width,
converted->height, static_cast<AVPixelFormat>(converted->format),
SWS_POINT, nullptr, nullptr, nullptr);
if (!sws_ctx) {
return;
@@ -727,18 +720,18 @@ void olive::plugin::OliveClipInstance::setInputTexture(TexturePtr texture, OfxTi
copy_pixels:
int bytes_per_component = params_.format().byte_count();
int bytes_per_row = params_.width() * params_.channel_count() *
bytes_per_component;
int bytes_per_row =
params_.width() * params_.channel_count() * bytes_per_component;
int src_row_bytes = src_frame->linesize[0];
int dst_row_bytes = image->row_bytes();
int copy_bytes = std::min(bytes_per_row,
std::min(src_row_bytes, dst_row_bytes));
int copy_bytes =
std::min(bytes_per_row, std::min(src_row_bytes, dst_row_bytes));
int copy_height = std::min(image->height(), src_frame->height);
const uint8_t *src = src_frame->data[0];
if (params_.format() == core::PixelFormat::F32) {
const float *src_f = reinterpret_cast<const float*>(src);
float *dst_f = reinterpret_cast<float*>(dst);
const float *src_f = reinterpret_cast<const float *>(src);
float *dst_f = reinterpret_cast<float *>(dst);
int src_stride = src_row_bytes / static_cast<int>(sizeof(float));
int dst_stride = dst_row_bytes / static_cast<int>(sizeof(float));
int floats_per_row = copy_bytes / static_cast<int>(sizeof(float));
@@ -754,7 +747,8 @@ copy_pixels:
}
}
if (has_nan) {
qWarning() << "[PLUGIN] NaN/Inf scrubbed from input frame data during copy";
qWarning()
<< "[PLUGIN] NaN/Inf scrubbed from input frame data during copy";
}
} else if (dst_row_bytes == src_row_bytes && src_row_bytes == copy_bytes) {
std::memcpy(dst, src, copy_bytes * copy_height);
@@ -764,8 +758,6 @@ copy_pixels:
copy_bytes);
}
}
}
void olive::plugin::OliveClipInstance::setOutputTexture(TexturePtr texture,
@@ -818,18 +810,18 @@ olive::plugin::OliveClipInstance::loadTexture(OfxTime time, const char *format,
bounds.x2 = std::min(bounds.x2, rod.x2);
bounds.y2 = std::min(bounds.y2, rod.y2);
const int bytes_per_row =
params_.width() * params_.channel_count() * params_.format().byte_count();
const int bytes_per_row = params_.width() * params_.channel_count() *
params_.format().byte_count();
const std::string &field = getFieldOrder();
const std::string unique_id = std::to_string(
reinterpret_cast<uintptr_t>(gl_texture.get())) + "_" +
const std::string unique_id =
std::to_string(reinterpret_cast<uintptr_t>(gl_texture.get())) + "_" +
std::to_string(static_cast<long long>(time));
const int texture_id = gl_texture->id().value<GLuint>();
OFX::Host::ImageEffect::Texture *texture =
new OFX::Host::ImageEffect::Texture(
*this, 1.0, 1.0, texture_id, GL_TEXTURE_2D, bounds, rod,
bytes_per_row, field, unique_id);
new OFX::Host::ImageEffect::Texture(*this, 1.0, 1.0, texture_id,
GL_TEXTURE_2D, bounds, rod,
bytes_per_row, field, unique_id);
texture->addReference();
return texture;
}
+18 -16
View File
@@ -35,17 +35,18 @@ namespace olive
{
namespace plugin
{
class OliveClipInstance: public OFX::Host::ImageEffect::ClipInstance {
class OliveClipInstance : public OFX::Host::ImageEffect::ClipInstance {
public:
OliveClipInstance(OFX::Host::ImageEffect::Instance* effectInstance,
OFX::Host::ImageEffect::ClipDescriptor& desc,VideoParams &params)
OliveClipInstance(OFX::Host::ImageEffect::Instance *effectInstance,
OFX::Host::ImageEffect::ClipDescriptor &desc,
VideoParams &params)
: ClipInstance(effectInstance, desc)
, params_(params)
, defaultRegionOfDefinitions_{0, 0, 0, 0}
, defaultRegionOfDefinitions_{ 0, 0, 0, 0 }
, name_(desc.getName())
{
}
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;
@@ -56,21 +57,24 @@ public:
const std::string &getFieldOrder() const override;
bool getConnected() const override;
double getUnmappedFrameRate() const override;
void getUnmappedFrameRange(double &startFrame, double &endFrame) const override;
void getUnmappedFrameRange(double &startFrame,
double &endFrame) const override;
bool getContinuousSamples() const override;
OFX::Host::ImageEffect::Image* getImage(OfxTime time, const OfxRectD *optionalBounds) override;
OFX::Host::ImageEffect::Image *
getImage(OfxTime time, const OfxRectD *optionalBounds) override;
OfxRectD getRegionOfDefinition(OfxTime time) const override;
void setRegionOfDefinition(OfxRectD regionOfDefinition, OfxTime time);
void setDefaultRegionOfDefinition(OfxRectD regionOfDefinition);
void setParams(const VideoParams &params);
# ifdef OFX_SUPPORTS_OPENGLRENDER
OFX::Host::ImageEffect::Texture* loadTexture(OfxTime time,
const char *format,
const OfxRectD *optionalBounds) override;
# endif
#ifdef OFX_SUPPORTS_OPENGLRENDER
OFX::Host::ImageEffect::Texture *
loadTexture(OfxTime time, const char *format,
const OfxRectD *optionalBounds) override;
#endif
void setInputTexture(TexturePtr texture, OfxTime time, bool readback_cpu = true);
void setInputTexture(TexturePtr texture, OfxTime time,
bool readback_cpu = true);
void setOutputTexture(TexturePtr texture, OfxTime time);
// Get the plugin-preferred VideoParams based on base class _pixelDepth/_components
@@ -90,7 +94,7 @@ private:
OfxRectD defaultRegionOfDefinitions_;
std::string name_;
QMap<OfxTime, Image*> images_;
QMap<OfxTime, Image *> images_;
#ifdef OFX_SUPPORTS_OPENGLRENDER
QMap<OfxTime, TexturePtr> input_textures_;
QMap<OfxTime, TexturePtr> output_textures_;
@@ -99,6 +103,4 @@ private:
}
}
#endif //OLIVECLIP_H
+33 -25
View File
@@ -22,7 +22,7 @@
#include <cstdio>
#include <cstring>
#include <memory>
#include <ofxhPluginCache.h>
#include <ofxhPluginCache.h>
#include <ofxhBinary.h>
#include <QApplication>
@@ -37,14 +37,18 @@
using namespace OFX::Host;
using namespace olive::plugin;
namespace olive {
namespace plugin {
namespace olive
{
namespace plugin
{
class PluginNode;
}
}
namespace {
void AddPluginPath(OFX::Host::PluginCache *cache, const QString &path, bool recurse = true)
namespace
{
void AddPluginPath(OFX::Host::PluginCache *cache, const QString &path,
bool recurse = true)
{
if (!cache || path.isEmpty()) {
return;
@@ -80,7 +84,8 @@ void olive::plugin::loadPlugins(QString path)
host = std::make_shared<OliveHost>();
Current::getInstance().setPluginHost(host);
imageEffectPluginCache = std::make_shared<ImageEffect::PluginCache>(*host);
imageEffectPluginCache =
std::make_shared<ImageEffect::PluginCache>(*host);
Current::getInstance().setPluginCache(imageEffectPluginCache);
imageEffectPluginCache->registerInCache(
@@ -92,7 +97,8 @@ void olive::plugin::loadPlugins(QString path)
const QString home_path = QDir::homePath();
AddPluginPath(cache, QDir(home_path).filePath(".OFX/Plugins"));
AddPluginPath(cache, QDir(home_path).filePath(".local/share/OFX/Plugins"));
AddPluginPath(cache, QDir(home_path).filePath(".local/share/olive/ofx/Plugins"));
AddPluginPath(cache,
QDir(home_path).filePath(".local/share/olive/ofx/Plugins"));
const QString app_dir = QCoreApplication::applicationDirPath();
AddPluginPath(cache, QDir(app_dir).filePath("../OFX/Plugins"));
@@ -109,10 +115,9 @@ void olive::plugin::loadPlugins(QString path)
}
OliveHost::~OliveHost()
{
}
void OliveHost::destroyInstance(OFX::Host::ImageEffect::Instance* instance)
void OliveHost::destroyInstance(OFX::Host::ImageEffect::Instance *instance)
{
if (!instance) {
return;
@@ -151,11 +156,12 @@ OliveHost::makeDescriptor(const std::string &bundlePath,
return desc;
}
ImageEffect::Instance* OliveHost::newInstance(void *clientData,
ImageEffect::ImageEffectPlugin* plugin,
ImageEffect::Descriptor& desc,
const std::string& context){
auto* instance = new OlivePluginInstance(
ImageEffect::Instance *
OliveHost::newInstance(void *clientData, ImageEffect::ImageEffectPlugin *plugin,
ImageEffect::Descriptor &desc,
const std::string &context)
{
auto *instance = new OlivePluginInstance(
plugin, desc, context, Current::getInstance().interactive());
if (clientData) {
auto *node = static_cast<PluginNode *>(clientData);
@@ -165,8 +171,9 @@ ImageEffect::Instance* OliveHost::newInstance(void *clientData,
instances_.append(std::shared_ptr<OlivePluginInstance>(instance));
return instance;
};
OfxStatus olive::plugin::OliveHost::vmessage(const char *type, const char *id, const char *format,
va_list args){
OfxStatus olive::plugin::OliveHost::vmessage(const char *type, const char *id,
const char *format, va_list args)
{
if (!type || !format) {
return kOfxStatFailed;
}
@@ -178,8 +185,7 @@ OfxStatus olive::plugin::OliveHost::vmessage(const char *type, const char *id, c
auto *app = qobject_cast<QApplication *>(QCoreApplication::instance());
if (!app) {
qWarning().noquote()
<< "OFX message:" << type << message;
qWarning().noquote() << "OFX message:" << type << message;
if (strcmp(type, kOfxMessageQuestion) == 0) {
return kOfxStatReplyNo;
}
@@ -187,8 +193,8 @@ OfxStatus olive::plugin::OliveHost::vmessage(const char *type, const char *id, c
}
if (strcmp(type, kOfxMessageQuestion) == 0) {
auto ret = QMessageBox::question(nullptr, "", message,
QMessageBox::Ok, QMessageBox::Cancel);
auto ret = QMessageBox::question(nullptr, "", message, QMessageBox::Ok,
QMessageBox::Cancel);
return (ret == QMessageBox::Ok) ? kOfxStatReplyYes : kOfxStatReplyNo;
}
@@ -203,8 +209,10 @@ OfxStatus olive::plugin::OliveHost::vmessage(const char *type, const char *id, c
return kOfxStatOK;
}
// TODO: Persistent messages shouldn't use pop-up window.
OfxStatus olive::plugin::OliveHost::setPersistentMessage(
const char *type, const char *id, const char *format, va_list args)
OfxStatus olive::plugin::OliveHost::setPersistentMessage(const char *type,
const char *id,
const char *format,
va_list args)
{
if (!type || !format) {
return kOfxStatFailed;
@@ -216,13 +224,13 @@ OfxStatus olive::plugin::OliveHost::setPersistentMessage(
QString message(buffer);
if (strcmp(type, kOfxMessageError) == 0) {
persistent_messages_.append({HostMessageType::Error, message});
persistent_messages_.append({ HostMessageType::Error, message });
QMessageBox::critical(nullptr, "", message);
} else if (strcmp(type, kOfxMessageWarning) == 0) {
persistent_messages_.append({HostMessageType::Warning, message});
persistent_messages_.append({ HostMessageType::Warning, message });
QMessageBox::warning(nullptr, "", message);
} else if (strcmp(type, kOfxMessageMessage) == 0) {
persistent_messages_.append({HostMessageType::Message, message});
persistent_messages_.append({ HostMessageType::Message, message });
QMessageBox::information(nullptr, "", message);
} else {
return kOfxStatFailed;
+35 -29
View File
@@ -43,7 +43,8 @@ namespace olive
{
namespace plugin
{
namespace {
namespace
{
const std::string kImageFieldNoneStr(kOfxImageFieldNone);
const std::string kImageFieldUpperStr(kOfxImageFieldUpper);
const std::string kImageFieldLowerStr(kOfxImageFieldLower);
@@ -62,7 +63,8 @@ QString FormatOfxMessage(const char *format, va_list args)
return QString::fromUtf8(buffer);
}
QByteArray dynamic_buffer(needed + 1, 0);
const int written = vsnprintf(dynamic_buffer.data(), dynamic_buffer.size(), format, args);
const int written =
vsnprintf(dynamic_buffer.data(), dynamic_buffer.size(), format, args);
if (written < 0) {
return QString();
}
@@ -136,7 +138,8 @@ ViewerOutput *GetActiveViewerOutput()
}
}
QList<TimelinePanel *> timelines = manager->GetPanelsOfType<TimelinePanel>();
QList<TimelinePanel *> timelines =
manager->GetPanelsOfType<TimelinePanel>();
for (TimelinePanel *panel : timelines) {
if (panel && panel->GetConnectedViewer()) {
return panel->GetConnectedViewer();
@@ -166,7 +169,7 @@ void OlivePluginInstance::setNode(std::shared_ptr<PluginNode> node)
}
OfxStatus OlivePluginInstance::vmessage(const char *type, const char *id,
const char *format, va_list args)
const char *format, va_list args)
{
const QString message = FormatOfxMessage(format, args);
if (message.isEmpty()) {
@@ -180,7 +183,8 @@ OfxStatus OlivePluginInstance::vmessage(const char *type, const char *id,
if (is_question) {
const auto ret = QMessageBox::question(
nullptr, "", message, QMessageBox::Ok, QMessageBox::Cancel);
result = (ret == QMessageBox::Ok) ? kOfxStatReplyYes : kOfxStatReplyNo;
result = (ret == QMessageBox::Ok) ? kOfxStatReplyYes :
kOfxStatReplyNo;
} else {
QMessageBox::information(nullptr, "", message);
result = kOfxStatOK;
@@ -191,7 +195,8 @@ OfxStatus OlivePluginInstance::vmessage(const char *type, const char *id,
show_message();
} else if (auto *app = QCoreApplication::instance()) {
if (is_question) {
QMetaObject::invokeMethod(app, show_message, Qt::BlockingQueuedConnection);
QMetaObject::invokeMethod(app, show_message,
Qt::BlockingQueuedConnection);
} else {
QMetaObject::invokeMethod(app, show_message, Qt::QueuedConnection);
}
@@ -201,8 +206,10 @@ OfxStatus OlivePluginInstance::vmessage(const char *type, const char *id,
return result;
}
OfxStatus OlivePluginInstance::setPersistentMessage(const char *type, const char *id,
const char *format, va_list args)
OfxStatus OlivePluginInstance::setPersistentMessage(const char *type,
const char *id,
const char *format,
va_list args)
{
const QString message = FormatOfxMessage(format, args);
if (message.isEmpty()) {
@@ -215,11 +222,13 @@ OfxStatus OlivePluginInstance::setPersistentMessage(const char *type, const char
error_type = ErrorType::Error;
}
// A warning
else if (strncmp(type, kOfxMessageWarning, strlen(kOfxMessageWarning)) == 0) {
else if (strncmp(type, kOfxMessageWarning, strlen(kOfxMessageWarning)) ==
0) {
error_type = ErrorType::Warning;
}
// A simple information
else if (strncmp(type, kOfxMessageMessage, strlen(kOfxMessageMessage)) == 0) {
else if (strncmp(type, kOfxMessageMessage, strlen(kOfxMessageMessage)) ==
0) {
error_type = ErrorType::Message;
} else {
return kOfxStatFailed;
@@ -272,7 +281,8 @@ void OlivePluginInstance::getProjectSize(double &xSize, double &ySize) const
xSize = params_.width() * par;
ySize = params_.height();
}
void OlivePluginInstance::getProjectOffset(double &xOffset, double &yOffset) const
void OlivePluginInstance::getProjectOffset(double &xOffset,
double &yOffset) const
{
double par = params_.pixel_aspect_ratio().toDouble();
xOffset = params_.x() * par;
@@ -317,7 +327,7 @@ void OlivePluginInstance::getRenderScaleRecursive(double &x, double &y) const
}
OFX::Host::Param::Instance *
OlivePluginInstance::newParam(const std::string &name,
OFX::Host::Param::Descriptor &desc)
OFX::Host::Param::Descriptor &desc)
{
const std::string &type = desc.getType();
@@ -343,8 +353,7 @@ OlivePluginInstance::newParam(const std::string &name,
return new Double3DInstance(node_, name, desc, this);
} else if (type == kOfxParamTypeInteger3D) {
return new Integer3DInstance(node_, name, desc, this);
} else if (type == kOfxParamTypeCustom ||
type == kOfxParamTypeBytes) {
} else if (type == kOfxParamTypeCustom || type == kOfxParamTypeBytes) {
return new CustomInstance(node_, name, desc, this);
} else if (type == kOfxParamTypeGroup) {
return new GroupInstance(desc, this);
@@ -366,8 +375,7 @@ OfxStatus OlivePluginInstance::editBegin(const std::string &name)
edit_param_count_ = 0;
if (!name.empty()) {
edit_first_label_ =
QCoreApplication::translate(
"OlivePluginInstance", "Change %1")
QCoreApplication::translate("OlivePluginInstance", "Change %1")
.arg(QString::fromStdString(name));
}
}
@@ -383,15 +391,14 @@ OfxStatus OlivePluginInstance::editEnd()
if (label.isEmpty()) {
if (edit_param_count_ <= 1 && !edit_first_label_.isEmpty()) {
label = edit_first_label_;
} else if (edit_param_count_ > 1 &&
!edit_first_label_.isEmpty()) {
label = QCoreApplication::translate(
"OlivePluginInstance", "%1 (+%2)")
} else if (edit_param_count_ > 1 && !edit_first_label_.isEmpty()) {
label = QCoreApplication::translate("OlivePluginInstance",
"%1 (+%2)")
.arg(edit_first_label_)
.arg(edit_param_count_ - 1);
} else {
label = QCoreApplication::translate(
"OlivePluginInstance", "Edit Parameters");
label = QCoreApplication::translate("OlivePluginInstance",
"Edit Parameters");
}
}
Core::instance()->undo_stack()->push(edit_command_, label);
@@ -450,9 +457,8 @@ void OlivePluginInstance::progressStart(const std::string &message,
progress_dialog_->deleteLater();
}
QString dialog_message = message.empty()
? QStringLiteral("Processing...")
: QString::fromStdString(message);
QString dialog_message = message.empty() ? QStringLiteral("Processing...") :
QString::fromStdString(message);
progress_dialog_ = new ::olive::ProgressDialog(
dialog_message, QStringLiteral("OpenFX"), nullptr);
@@ -547,17 +553,17 @@ void OlivePluginInstance::setCustomInArgs(const std::string &action,
OFX::Host::ImageEffect::ClipInstance *OlivePluginInstance::newClipInstance(
OFX::Host::ImageEffect::Instance *plugin,
OFX::Host::ImageEffect::ClipDescriptor *descriptor,
int index)
OFX::Host::ImageEffect::ClipDescriptor *descriptor, int index)
{
// Create a new clip instance
OliveClipInstance* 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 depth = kOfxBitDepthFloat; // host default
std::string comp = kOfxImageComponentRGBA; // host default
switch (params_.format()) {
+47 -48
View File
@@ -33,7 +33,8 @@
#include <qcontainerfwd.h>
#include <qlist.h>
namespace olive {
namespace olive
{
inline bool IsGuiThread()
{
@@ -43,48 +44,44 @@ inline bool IsGuiThread()
return true;
}
class ProgressDialog;
namespace plugin {
namespace plugin
{
class PluginNode;
enum class ErrorType{
Error,
Warning,
Message
};
struct PersistentErrors{
enum class ErrorType { Error, Warning, Message };
struct PersistentErrors {
ErrorType type;
QString message;
};
class OlivePluginInstance : public OFX::Host::ImageEffect::Instance {
public:
OlivePluginInstance(
OFX::Host::ImageEffect::ImageEffectPlugin* plugin,
OFX::Host::ImageEffect::Descriptor& desc,
const std::string& context,
bool interactive)
OlivePluginInstance(OFX::Host::ImageEffect::ImageEffectPlugin *plugin,
OFX::Host::ImageEffect::Descriptor &desc,
const std::string &context, bool interactive)
: OFX::Host::ImageEffect::Instance(plugin, desc, context, interactive)
{
}
OlivePluginInstance(OlivePluginInstance& instance)
OlivePluginInstance(OlivePluginInstance &instance)
: Instance(instance._plugin, *instance._descriptor, instance._context,
instance._interactive)
{
// 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;
_frameVarying=instance._frameVarying;
_outputPreMultiplication=instance._outputPreMultiplication;
_outputFielding=instance._outputFielding;
_outputFrameRate=instance._outputFrameRate;
_created = instance._created;
_clipPrefsDirty = instance._clipPrefsDirty;
_continuousSamples = instance._continuousSamples;
_frameVarying = instance._frameVarying;
_outputPreMultiplication = instance._outputPreMultiplication;
_outputFielding = instance._outputFielding;
_outputFrameRate = instance._outputFrameRate;
}
explicit OlivePluginInstance(Instance & instance):Instance(instance){};
explicit OlivePluginInstance(Instance &instance)
: Instance(instance) {};
~OlivePluginInstance() override;
const std::string &getDefaultOutputFielding() const override;
void setVideoParam(VideoParams params)
{
this->params_=params;
this->params_ = params;
}
void setNode(std::shared_ptr<PluginNode> node);
std::shared_ptr<PluginNode> node() const
@@ -99,21 +96,17 @@ public:
{
return _created;
}
OFX::Host::ImageEffect::ClipInstance *newClipInstance(
OFX::Host::ImageEffect::Instance *plugin,
OFX::Host::ImageEffect::ClipDescriptor *descriptor,
int index) override;
OFX::Host::ImageEffect::ClipInstance *
newClipInstance(OFX::Host::ImageEffect::Instance *plugin,
OFX::Host::ImageEffect::ClipDescriptor *descriptor,
int index) override;
OfxStatus vmessage(const char* type,
const char* id,
const char* format,
va_list args) override;
OfxStatus vmessage(const char *type, const char *id, const char *format,
va_list args) override;
OfxStatus setPersistentMessage(const char *type, const char *id,
const char *format, va_list args) override;
OfxStatus setPersistentMessage(const char* type,
const char* id,
const char* format,
va_list args) override;
OfxStatus clearPersistentMessage() override;
int persistentMessageCount() const
{
@@ -124,21 +117,21 @@ public:
return persistentErrors_;
}
void getProjectSize(double& xSize, double& ySize) const override;
void getProjectOffset(double& xOffset, double& yOffset) const override;
void getProjectExtent(double& xSize, double& ySize) const override;
// The pixel aspect ratio of the current project
void getProjectSize(double &xSize, double &ySize) const override;
void getProjectOffset(double &xOffset, double &yOffset) const override;
void getProjectExtent(double &xSize, double &ySize) const override;
// The pixel aspect ratio of the current project
double getProjectPixelAspectRatio() const override;
// The duration of the effect
// This contains the duration of the plug-in effect, in frames.
// The duration of the effect
// This contains the duration of the plug-in effect, in frames.
double getEffectDuration() const override;
// For an instance, this is the frame rate of the project the effect is in.
// For an instance, this is the frame rate of the project the effect is in.
double getFrameRate() const override;
/// This is called whenever a param is changed by the plugin so that
/// the recursive instanceChangedAction will be fed the correct frame
/// the recursive instanceChangedAction will be fed the correct frame
double getFrameRecursive() const override;
/// This is called whenever a param is changed by the plugin so that
@@ -153,14 +146,16 @@ public:
/// make a parameter instance
///
/// Client host code needs to implement this
OFX::Host::Param::Instance* newParam(const std::string& name, OFX::Host::Param::Descriptor& Descriptor) override;
OFX::Host::Param::Instance *
newParam(const std::string &name,
OFX::Host::Param::Descriptor &Descriptor) override;
void SubmitUndoCommand(UndoCommand *command, const QString &label);
/// Triggered when the plug-in calls OfxParameterSuiteV1::paramEditBegin
///
/// Client host code needs to implement this
virtual OfxStatus editBegin(const std::string& name) override;
virtual OfxStatus editBegin(const std::string &name) override;
/// Triggered when the plug-in calls OfxParameterSuiteV1::paramEditEnd
///
@@ -210,7 +205,6 @@ public:
void setCustomInArgs(const std::string &action,
OFX::Host::Property::Set &inArgs) override;
private:
QList<PersistentErrors> persistentErrors_;
VideoParams params_;
@@ -224,8 +218,13 @@ private:
bool progress_cancelled_ = false;
bool progress_active_ = false;
bool open_gl_enabled_ = false;
public:
std::mutex& mutex() { return mutex_; }
std::mutex &mutex()
{
return mutex_;
}
private:
std::mutex mutex_;
};
+23 -36
View File
@@ -23,8 +23,10 @@
#include <algorithm>
namespace olive {
namespace plugin {
namespace olive
{
namespace plugin
{
static const char *PixelDepthToOfx(core::PixelFormat format)
{
@@ -69,16 +71,14 @@ Image::Image(OFX::Host::ImageEffect::ClipInstance &clip_instance)
, premultiplied_alpha_(false)
, channel_count_(0)
, row_bytes_(0)
, bounds_{0, 0, 0, 0}
, rod_{0, 0, 0, 0}
, bounds_{ 0, 0, 0, 0 }
, rod_{ 0, 0, 0, 0 }
{
}
Image::Image(OFX::Host::ImageEffect::ClipInstance &clip_instance,
const VideoParams &params,
const OfxRectI &bounds,
const OfxRectI &rod,
bool clear)
const VideoParams &params, const OfxRectI &bounds,
const OfxRectI &rod, bool clear)
: OFX::Host::ImageEffect::Image(clip_instance)
, width_(0)
, height_(0)
@@ -86,8 +86,8 @@ Image::Image(OFX::Host::ImageEffect::ClipInstance &clip_instance,
, premultiplied_alpha_(false)
, channel_count_(0)
, row_bytes_(0)
, bounds_{0, 0, 0, 0}
, rod_{0, 0, 0, 0}
, bounds_{ 0, 0, 0, 0 }
, rod_{ 0, 0, 0, 0 }
{
AllocateFromParams(params, bounds, rod, clear);
}
@@ -97,24 +97,17 @@ Image::~Image()
}
void Image::AllocateFromParams(const VideoParams &params,
const OfxRectI &bounds,
const OfxRectI &rod,
const OfxRectI &bounds, const OfxRectI &rod,
bool clear)
{
Allocate(bounds.x2 - bounds.x1,
bounds.y2 - bounds.y1,
params.format(),
params.channel_count(),
params.premultiplied_alpha(),
bounds,
rod,
Allocate(bounds.x2 - bounds.x1, bounds.y2 - bounds.y1, params.format(),
params.channel_count(), params.premultiplied_alpha(), bounds, rod,
clear);
}
void Image::EnsureAllocatedFromParams(const VideoParams &params,
const OfxRectI &bounds,
const OfxRectI &rod,
bool clear)
const OfxRectI &rod, bool clear)
{
bool same = (width_ == bounds.x2 - bounds.x1) &&
(height_ == bounds.y2 - bounds.y1) &&
@@ -133,14 +126,9 @@ void Image::EnsureAllocatedFromParams(const VideoParams &params,
}
}
void Image::Allocate(int width,
int height,
core::PixelFormat format,
int channel_count,
bool premultiplied_alpha,
const OfxRectI &bounds,
const OfxRectI &rod,
bool clear)
void Image::Allocate(int width, int height, core::PixelFormat format,
int channel_count, bool premultiplied_alpha,
const OfxRectI &bounds, const OfxRectI &rod, bool clear)
{
width_ = width;
height_ = height;
@@ -173,12 +161,11 @@ void Image::Allocate(int width,
setIntProperty(kOfxImagePropRegionOfDefinition, rod.x2, 2);
setIntProperty(kOfxImagePropRegionOfDefinition, rod.y2, 3);
setStringProperty(kOfxImageEffectPropComponents,
ComponentsToOfx(channel_count_));
setStringProperty(kOfxImageEffectPropPixelDepth,
PixelDepthToOfx(format_));
ComponentsToOfx(channel_count_));
setStringProperty(kOfxImageEffectPropPixelDepth, PixelDepthToOfx(format_));
setStringProperty(kOfxImageEffectPropPreMultiplication,
premultiplied_alpha_ ? kOfxImagePreMultiplied
: kOfxImageUnPreMultiplied);
premultiplied_alpha_ ? kOfxImagePreMultiplied :
kOfxImageUnPreMultiplied);
}
core::PixelFormat Image::pixel_format()
@@ -212,7 +199,7 @@ bool Image::premultiplied_alpha()
int Image::width()
{
int bounds[4] = {0};
int bounds[4] = { 0 };
getIntPropertyN(kOfxImagePropBounds, bounds, 4);
width_ = bounds[2] - bounds[0];
return width_;
@@ -220,7 +207,7 @@ int Image::width()
int Image::height()
{
int bounds[4] = {0};
int bounds[4] = { 0 };
getIntPropertyN(kOfxImagePropBounds, bounds, 4);
height_ = bounds[3] - bounds[1];
return height_;
+11 -18
View File
@@ -37,12 +37,11 @@ class Image : public OFX::Host::ImageEffect::Image {
public:
Image(OFX::Host::ImageEffect::ClipInstance &clip_instance);
Image(OFX::Host::ImageEffect::ClipInstance &clip_instance,
const VideoParams &params,
const OfxRectI &bounds,
const OfxRectI &rod,
bool clear = true);
const VideoParams &params, const OfxRectI &bounds,
const OfxRectI &rod, bool clear = true);
~Image();
uint8_t *data() {
uint8_t *data()
{
return (uint8_t *)getPointerProperty(kOfxImagePropData);
}
int width();
@@ -51,26 +50,20 @@ public:
bool premultiplied_alpha();
int channel_count();
void AllocateFromParams(const VideoParams &params,
const OfxRectI &bounds,
const OfxRectI &rod,
bool clear = true);
void AllocateFromParams(const VideoParams &params, const OfxRectI &bounds,
const OfxRectI &rod, bool clear = true);
void EnsureAllocatedFromParams(const VideoParams &params,
const OfxRectI &bounds,
const OfxRectI &rod,
const OfxRectI &bounds, const OfxRectI &rod,
bool clear = false);
void Allocate(int width,
int height,
core::PixelFormat format,
int channel_count,
bool premultiplied_alpha,
const OfxRectI &bounds,
const OfxRectI &rod,
void Allocate(int width, int height, core::PixelFormat format,
int channel_count, bool premultiplied_alpha,
const OfxRectI &bounds, const OfxRectI &rod,
bool clear = true);
int row_bytes() const
{
return row_bytes_;
}
protected:
std::vector<uint8_t> image_;
int width_;
+1 -3
View File
@@ -17,7 +17,6 @@
*
*/
#include "paraminstance.h"
#include "OlivePluginInstance.h"
@@ -35,8 +34,7 @@ void SubmitUndoCommand(const std::shared_ptr<PluginNode> &node,
if (node) {
auto *instance = node->getPluginInstance();
auto *olive_instance =
dynamic_cast<OlivePluginInstance *>(instance);
auto *olive_instance = dynamic_cast<OlivePluginInstance *>(instance);
if (olive_instance) {
olive_instance->SubmitUndoCommand(command, label);
return;
+207 -184
View File
@@ -41,8 +41,8 @@ namespace olive
namespace plugin
{
inline bool IsNormalisedCoordinateSystem(
const OFX::Host::Param::Descriptor &descriptor)
inline bool
IsNormalisedCoordinateSystem(const OFX::Host::Param::Descriptor &descriptor)
{
return descriptor.getDefaultCoordinateSystem() ==
kOfxParamCoordinatesNormalised;
@@ -80,12 +80,14 @@ public:
};
class PushbuttonInstance : public OFX::Host::Param::PushbuttonInstance,
public NodeBoundParam {
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor *_descriptor;
public:
PushbuttonInstance(std::shared_ptr<PluginNode> effect, const std::string &name,
PushbuttonInstance(std::shared_ptr<PluginNode> effect,
const std::string &name,
OFX::Host::Param::Descriptor &descriptor,
OFX::Host::Param::SetInstance *paramSet = nullptr)
: OFX::Host::Param::PushbuttonInstance(descriptor, paramSet)
@@ -102,22 +104,25 @@ public:
class IntegerInstance : public OFX::Host::Param::IntegerInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> _node;
OFX::Host::Param::Descriptor& _descriptor;
std::shared_ptr<PluginNode> _node;
OFX::Host::Param::Descriptor &_descriptor;
QString id;
mutable std::mutex no_node_mutex_;
bool has_value_ = false;
int value_ = 0;
public:
IntegerInstance(std::shared_ptr<PluginNode>node, OFX::Host::Param::Descriptor &descriptor,
OFX::Host::Param::SetInstance *paramSet = nullptr)
IntegerInstance(std::shared_ptr<PluginNode> node,
OFX::Host::Param::Descriptor &descriptor,
OFX::Host::Param::SetInstance *paramSet = nullptr)
: OFX::Host::Param::IntegerInstance(descriptor, paramSet)
, _node(node)
, _descriptor(descriptor)
, id(_descriptor.getName().c_str())
{
try {
value_ = _descriptor.getProperties().getIntProperty(kOfxParamPropDefault);
value_ = _descriptor.getProperties().getIntProperty(
kOfxParamPropDefault);
has_value_ = true;
} catch (...) {
value_ = 0;
@@ -138,13 +143,13 @@ public:
if (id.isEmpty()) {
return kOfxStatErrBadHandle;
}
QVariant variant=_node->GetStandardValue(id);
QVariant variant = _node->GetStandardValue(id);
if (variant.canConvert<int>()) {
a=variant.toInt();
a = variant.toInt();
return kOfxStatOK;
}
a=0;
a = 0;
return kOfxStatErrValue;
}
OfxStatus get(OfxTime time, int &data)
@@ -157,12 +162,13 @@ public:
if (id.isEmpty()) {
return kOfxStatErrBadHandle;
}
QVariant variant=_node->GetValueAtTime(id, rational::fromDouble(time));
QVariant variant =
_node->GetValueAtTime(id, rational::fromDouble(time));
if (variant.canConvert<int>()) {
data=variant.toInt();
data = variant.toInt();
return kOfxStatOK;
}
data=0;
data = 0;
return kOfxStatErrValue;
}
OfxStatus set(int data)
@@ -201,20 +207,23 @@ public:
class DoubleInstance : public OFX::Host::Param::DoubleInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor& _descriptor;
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor &_descriptor;
bool has_value_ = false;
double value_ = 0.0;
public:
DoubleInstance(std::shared_ptr<PluginNode> effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor,
OFX::Host::Param::SetInstance *paramSet = nullptr)
DoubleInstance(std::shared_ptr<PluginNode> effect, const std::string &name,
OFX::Host::Param::Descriptor &descriptor,
OFX::Host::Param::SetInstance *paramSet = nullptr)
: OFX::Host::Param::DoubleInstance(descriptor, paramSet)
, node(effect)
, _descriptor(descriptor)
{
(void)name;
try {
value_ = _descriptor.getProperties().getDoubleProperty(kOfxParamPropDefault);
value_ = _descriptor.getProperties().getDoubleProperty(
kOfxParamPropDefault);
has_value_ = true;
} catch (...) {
value_ = 0.0;
@@ -225,13 +234,14 @@ public:
{
node = new_node;
}
OfxStatus get(double& data)
OfxStatus get(double &data)
{
if (!node) {
data = has_value_ ? value_ : 0.0;
return kOfxStatOK;
}
QVariant variant = node->GetStandardValue(_descriptor.getName().c_str());
QVariant variant =
node->GetStandardValue(_descriptor.getName().c_str());
if (variant.canConvert<double>()) {
data = variant.toDouble();
if (IsNormalisedCoordinateSystem(_descriptor)) {
@@ -244,15 +254,14 @@ public:
data = 0.0;
return kOfxStatErrValue;
}
OfxStatus get(OfxTime time, double& data)
OfxStatus get(OfxTime time, double &data)
{
if (!node) {
data = has_value_ ? value_ : 0.0;
return kOfxStatOK;
}
QVariant variant =
node->GetValueAtTime(_descriptor.getName().c_str(),
rational::fromDouble(time));
QVariant variant = node->GetValueAtTime(_descriptor.getName().c_str(),
rational::fromDouble(time));
if (variant.canConvert<double>()) {
data = variant.toDouble();
if (IsNormalisedCoordinateSystem(_descriptor)) {
@@ -299,17 +308,17 @@ public:
val = ToCanonical(val, xSize);
}
auto command = new MultiUndoCommand();
Node::SetValueAtTime(
NodeInput(node.get(), _descriptor.getName().c_str()),
rational::fromDouble(time), val, 0, command, true);
Node::SetValueAtTime(NodeInput(node.get(),
_descriptor.getName().c_str()),
rational::fromDouble(time), val, 0, command, true);
SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor));
return kOfxStatOK;
}
OfxStatus derive(OfxTime, double&)
OfxStatus derive(OfxTime, double &)
{
return kOfxStatErrUnsupported;
}
OfxStatus integrate(OfxTime, OfxTime, double&)
OfxStatus integrate(OfxTime, OfxTime, double &)
{
return kOfxStatErrUnsupported;
}
@@ -318,18 +327,20 @@ public:
class BooleanInstance : public OFX::Host::Param::BooleanInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor& _descriptor;
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor &_descriptor;
bool has_value_ = false;
bool value_ = false;
bool DefaultValue() const
{
return _descriptor.getProperties()
.getIntProperty(kOfxParamPropDefault) != 0;
return _descriptor.getProperties().getIntProperty(
kOfxParamPropDefault) != 0;
}
public:
BooleanInstance(std::shared_ptr<PluginNode> effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor,
OFX::Host::Param::SetInstance *paramSet = nullptr)
BooleanInstance(std::shared_ptr<PluginNode> effect, const std::string &name,
OFX::Host::Param::Descriptor &descriptor,
OFX::Host::Param::SetInstance *paramSet = nullptr)
: OFX::Host::Param::BooleanInstance(descriptor, paramSet)
, node(effect)
, _descriptor(descriptor)
@@ -342,13 +353,14 @@ public:
{
node = new_node;
}
OfxStatus get(bool& data)
OfxStatus get(bool &data)
{
if (!node) {
data = has_value_ ? value_ : false;
return kOfxStatOK;
}
QVariant variant = node->GetStandardValue(_descriptor.getName().c_str());
QVariant variant =
node->GetStandardValue(_descriptor.getName().c_str());
if (variant.canConvert<bool>()) {
data = variant.toBool();
return kOfxStatOK;
@@ -356,17 +368,18 @@ public:
data = DefaultValue();
return kOfxStatOK;
}
OfxStatus get(OfxTime time, bool& data)
OfxStatus get(OfxTime time, bool &data)
{
if (!node) {
data = has_value_ ? value_ : false;
return kOfxStatOK;
}
QVariant variant =
node->GetValueAtTime(_descriptor.getName().c_str(),
rational::fromDouble(time));
if (variant.isNull()){
qWarning().noquote()<<"Boolean get failed: Varient is null" << time << rational::fromDouble(time).toDouble();
QVariant variant = node->GetValueAtTime(_descriptor.getName().c_str(),
rational::fromDouble(time));
if (variant.isNull()) {
qWarning().noquote()
<< "Boolean get failed: Varient is null" << time
<< rational::fromDouble(time).toDouble();
}
if (!variant.isValid()) {
qWarning().noquote()
@@ -413,20 +426,23 @@ public:
class ChoiceInstance : public OFX::Host::Param::ChoiceInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor& _descriptor;
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor &_descriptor;
bool has_value_ = false;
int value_ = 0;
public:
ChoiceInstance(std::shared_ptr<PluginNode> effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor,
OFX::Host::Param::SetInstance *paramSet = nullptr)
ChoiceInstance(std::shared_ptr<PluginNode> effect, const std::string &name,
OFX::Host::Param::Descriptor &descriptor,
OFX::Host::Param::SetInstance *paramSet = nullptr)
: OFX::Host::Param::ChoiceInstance(descriptor, paramSet)
, node(effect)
, _descriptor(descriptor)
{
(void)name;
try {
value_ = _descriptor.getProperties().getIntProperty(kOfxParamPropDefault);
value_ = _descriptor.getProperties().getIntProperty(
kOfxParamPropDefault);
has_value_ = true;
} catch (...) {
value_ = 0;
@@ -437,13 +453,14 @@ public:
{
node = new_node;
}
OfxStatus get(int& data)
OfxStatus get(int &data)
{
if (!node) {
data = has_value_ ? value_ : 0;
return kOfxStatOK;
}
QVariant variant = node->GetStandardValue(_descriptor.getName().c_str());
QVariant variant =
node->GetStandardValue(_descriptor.getName().c_str());
if (variant.canConvert<int>()) {
data = variant.toInt();
return kOfxStatOK;
@@ -451,15 +468,14 @@ public:
data = 0;
return kOfxStatErrValue;
}
OfxStatus get(OfxTime time, int& data)
OfxStatus get(OfxTime time, int &data)
{
if (!node) {
data = has_value_ ? value_ : 0;
return kOfxStatOK;
}
QVariant variant =
node->GetValueAtTime(_descriptor.getName().c_str(),
rational::fromDouble(time));
QVariant variant = node->GetValueAtTime(_descriptor.getName().c_str(),
rational::fromDouble(time));
if (variant.canConvert<int>()) {
data = variant.toInt();
return kOfxStatOK;
@@ -500,12 +516,14 @@ public:
class RGBAInstance : public OFX::Host::Param::RGBAInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor& _descriptor;
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor &_descriptor;
bool has_value_ = false;
double value_[4] = {0.0, 0.0, 0.0, 0.0};
double value_[4] = { 0.0, 0.0, 0.0, 0.0 };
public:
RGBAInstance(std::shared_ptr<PluginNode> effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor,
RGBAInstance(std::shared_ptr<PluginNode> effect, const std::string &name,
OFX::Host::Param::Descriptor &descriptor,
OFX::Host::Param::SetInstance *paramSet = nullptr)
: OFX::Host::Param::RGBAInstance(descriptor, paramSet)
, node(effect)
@@ -517,7 +535,7 @@ public:
{
node = new_node;
}
OfxStatus get(double& r,double& g,double& b,double& a)
OfxStatus get(double &r, double &g, double &b, double &a)
{
if (!node) {
if (has_value_) {
@@ -540,7 +558,7 @@ public:
a = static_cast<double>(c.alpha());
return kOfxStatOK;
}
OfxStatus get(OfxTime time, double& r,double& g,double& b,double& a)
OfxStatus get(OfxTime time, double &r, double &g, double &b, double &a)
{
if (!node) {
if (has_value_) {
@@ -564,7 +582,7 @@ public:
a = static_cast<double>(c.alpha());
return kOfxStatOK;
}
OfxStatus set(double r,double g,double b,double a)
OfxStatus set(double r, double g, double b, double a)
{
if (!node) {
value_[0] = r;
@@ -582,7 +600,7 @@ public:
SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor));
return kOfxStatOK;
}
OfxStatus set(OfxTime time, double r,double g,double b,double a)
OfxStatus set(OfxTime time, double r, double g, double b, double a)
{
if (!node) {
value_[0] = r;
@@ -594,29 +612,30 @@ public:
}
auto command = new MultiUndoCommand();
const QString name = _descriptor.getName().c_str();
Node::SetValueAtTime(NodeInput(node.get(), name), rational::fromDouble(time),
r, 0, command, true);
Node::SetValueAtTime(NodeInput(node.get(), name), rational::fromDouble(time),
g, 1, command, true);
Node::SetValueAtTime(NodeInput(node.get(), name), rational::fromDouble(time),
b, 2, command, true);
Node::SetValueAtTime(NodeInput(node.get(), name), rational::fromDouble(time),
a, 3, command, true);
Node::SetValueAtTime(NodeInput(node.get(), name),
rational::fromDouble(time), r, 0, command, true);
Node::SetValueAtTime(NodeInput(node.get(), name),
rational::fromDouble(time), g, 1, command, true);
Node::SetValueAtTime(NodeInput(node.get(), name),
rational::fromDouble(time), b, 2, command, true);
Node::SetValueAtTime(NodeInput(node.get(), name),
rational::fromDouble(time), a, 3, command, true);
SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor));
return kOfxStatOK;
}
};
class RGBInstance : public OFX::Host::Param::RGBInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor& _descriptor;
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor &_descriptor;
bool has_value_ = false;
double value_[3] = {0.0, 0.0, 0.0};
double value_[3] = { 0.0, 0.0, 0.0 };
public:
RGBInstance(std::shared_ptr<PluginNode> effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor,
RGBInstance(std::shared_ptr<PluginNode> effect, const std::string &name,
OFX::Host::Param::Descriptor &descriptor,
OFX::Host::Param::SetInstance *paramSet = nullptr)
: OFX::Host::Param::RGBInstance(descriptor, paramSet)
, node(effect)
@@ -628,7 +647,7 @@ public:
{
node = new_node;
}
OfxStatus get(double& r,double& g,double& b)
OfxStatus get(double &r, double &g, double &b)
{
if (!node) {
if (has_value_) {
@@ -649,7 +668,7 @@ public:
b = static_cast<double>(c.blue());
return kOfxStatOK;
}
OfxStatus get(OfxTime time, double& r,double& g,double& b)
OfxStatus get(OfxTime time, double &r, double &g, double &b)
{
if (!node) {
if (has_value_) {
@@ -671,7 +690,7 @@ public:
b = static_cast<double>(c.blue());
return kOfxStatOK;
}
OfxStatus set(double r,double g,double b)
OfxStatus set(double r, double g, double b)
{
if (!node) {
value_[0] = r;
@@ -688,7 +707,7 @@ public:
SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor));
return kOfxStatOK;
}
OfxStatus set(OfxTime time, double r,double g,double b)
OfxStatus set(OfxTime time, double r, double g, double b)
{
if (!node) {
value_[0] = r;
@@ -699,12 +718,12 @@ public:
}
auto command = new MultiUndoCommand();
const QString name = _descriptor.getName().c_str();
Node::SetValueAtTime(NodeInput(node.get(), name), rational::fromDouble(time),
r, 0, command, true);
Node::SetValueAtTime(NodeInput(node.get(), name), rational::fromDouble(time),
g, 1, command, true);
Node::SetValueAtTime(NodeInput(node.get(), name), rational::fromDouble(time),
b, 2, command, true);
Node::SetValueAtTime(NodeInput(node.get(), name),
rational::fromDouble(time), r, 0, command, true);
Node::SetValueAtTime(NodeInput(node.get(), name),
rational::fromDouble(time), g, 1, command, true);
Node::SetValueAtTime(NodeInput(node.get(), name),
rational::fromDouble(time), b, 2, command, true);
SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor));
return kOfxStatOK;
}
@@ -713,12 +732,15 @@ public:
class Double2DInstance : public OFX::Host::Param::Double2DInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor& _descriptor;
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor &_descriptor;
bool has_value_ = false;
double value_[2] = {0.0, 0.0};
double value_[2] = { 0.0, 0.0 };
public:
Double2DInstance(std::shared_ptr<PluginNode> effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor,
Double2DInstance(std::shared_ptr<PluginNode> effect,
const std::string &name,
OFX::Host::Param::Descriptor &descriptor,
OFX::Host::Param::SetInstance *paramSet = nullptr)
: OFX::Host::Param::Double2DInstance(descriptor, paramSet)
, node(effect)
@@ -730,7 +752,7 @@ public:
{
node = new_node;
}
OfxStatus get(double& x,double& y)
OfxStatus get(double &x, double &y)
{
if (!node) {
if (has_value_) {
@@ -741,9 +763,8 @@ public:
}
return kOfxStatOK;
}
QVector2D vec =
node->GetStandardValue(_descriptor.getName().c_str())
.value<QVector2D>();
QVector2D vec = node->GetStandardValue(_descriptor.getName().c_str())
.value<QVector2D>();
x = static_cast<double>(vec.x());
y = static_cast<double>(vec.y());
if (IsNormalisedCoordinateSystem(_descriptor)) {
@@ -754,7 +775,7 @@ public:
}
return kOfxStatOK;
}
OfxStatus get(OfxTime time,double& x,double& y)
OfxStatus get(OfxTime time, double &x, double &y)
{
if (!node) {
if (has_value_) {
@@ -765,10 +786,9 @@ public:
}
return kOfxStatOK;
}
QVector2D vec =
node->GetValueAtTime(_descriptor.getName().c_str(),
rational::fromDouble(time))
.value<QVector2D>();
QVector2D vec = node->GetValueAtTime(_descriptor.getName().c_str(),
rational::fromDouble(time))
.value<QVector2D>();
x = static_cast<double>(vec.x());
y = static_cast<double>(vec.y());
if (IsNormalisedCoordinateSystem(_descriptor)) {
@@ -779,7 +799,7 @@ public:
}
return kOfxStatOK;
}
OfxStatus set(double x,double y)
OfxStatus set(double x, double y)
{
if (!node) {
value_[0] = x;
@@ -801,7 +821,7 @@ public:
SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor));
return kOfxStatOK;
}
OfxStatus set(OfxTime time,double x,double y)
OfxStatus set(OfxTime time, double x, double y)
{
if (!node) {
value_[0] = x;
@@ -818,10 +838,10 @@ public:
}
auto command = new MultiUndoCommand();
const QString name = _descriptor.getName().c_str();
Node::SetValueAtTime(NodeInput(node.get(), name), rational::fromDouble(time),
xv, 0, command, true);
Node::SetValueAtTime(NodeInput(node.get(), name), rational::fromDouble(time),
yv, 1, command, true);
Node::SetValueAtTime(NodeInput(node.get(), name),
rational::fromDouble(time), xv, 0, command, true);
Node::SetValueAtTime(NodeInput(node.get(), name),
rational::fromDouble(time), yv, 1, command, true);
SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor));
return kOfxStatOK;
}
@@ -830,12 +850,15 @@ public:
class Integer2DInstance : public OFX::Host::Param::Integer2DInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor& _descriptor;
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor &_descriptor;
bool has_value_ = false;
int value_[2] = {0, 0};
int value_[2] = { 0, 0 };
public:
Integer2DInstance(std::shared_ptr<PluginNode> effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor,
Integer2DInstance(std::shared_ptr<PluginNode> effect,
const std::string &name,
OFX::Host::Param::Descriptor &descriptor,
OFX::Host::Param::SetInstance *paramSet = nullptr)
: OFX::Host::Param::Integer2DInstance(descriptor, paramSet)
, node(effect)
@@ -847,7 +870,7 @@ public:
{
node = new_node;
}
OfxStatus get(int& x,int& y)
OfxStatus get(int &x, int &y)
{
if (!node) {
if (has_value_) {
@@ -858,14 +881,13 @@ public:
}
return kOfxStatOK;
}
QVector2D vec =
node->GetStandardValue(_descriptor.getName().c_str())
.value<QVector2D>();
QVector2D vec = node->GetStandardValue(_descriptor.getName().c_str())
.value<QVector2D>();
x = static_cast<int>(vec.x());
y = static_cast<int>(vec.y());
return kOfxStatOK;
}
OfxStatus get(OfxTime time,int& x,int& y)
OfxStatus get(OfxTime time, int &x, int &y)
{
if (!node) {
if (has_value_) {
@@ -876,15 +898,14 @@ public:
}
return kOfxStatOK;
}
QVector2D vec =
node->GetValueAtTime(_descriptor.getName().c_str(),
rational::fromDouble(time))
.value<QVector2D>();
QVector2D vec = node->GetValueAtTime(_descriptor.getName().c_str(),
rational::fromDouble(time))
.value<QVector2D>();
x = static_cast<int>(vec.x());
y = static_cast<int>(vec.y());
return kOfxStatOK;
}
OfxStatus set(int x,int y)
OfxStatus set(int x, int y)
{
if (!node) {
value_[0] = x;
@@ -899,7 +920,7 @@ public:
SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor));
return kOfxStatOK;
}
OfxStatus set(OfxTime time,int x,int y)
OfxStatus set(OfxTime time, int x, int y)
{
if (!node) {
value_[0] = x;
@@ -909,10 +930,10 @@ public:
}
auto command = new MultiUndoCommand();
const QString name = _descriptor.getName().c_str();
Node::SetValueAtTime(NodeInput(node.get(), name), rational::fromDouble(time),
x, 0, command, true);
Node::SetValueAtTime(NodeInput(node.get(), name), rational::fromDouble(time),
y, 1, command, true);
Node::SetValueAtTime(NodeInput(node.get(), name),
rational::fromDouble(time), x, 0, command, true);
Node::SetValueAtTime(NodeInput(node.get(), name),
rational::fromDouble(time), y, 1, command, true);
SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor));
return kOfxStatOK;
}
@@ -921,13 +942,15 @@ public:
class Double3DInstance : public OFX::Host::Param::Double3DInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor& _descriptor;
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor &_descriptor;
bool has_value_ = false;
double value_[3] = {0.0, 0.0, 0.0};
double value_[3] = { 0.0, 0.0, 0.0 };
public:
Double3DInstance(std::shared_ptr<PluginNode> effect, const std::string& name,
OFX::Host::Param::Descriptor& descriptor,
Double3DInstance(std::shared_ptr<PluginNode> effect,
const std::string &name,
OFX::Host::Param::Descriptor &descriptor,
OFX::Host::Param::SetInstance *paramSet = nullptr)
: OFX::Host::Param::Double3DInstance(descriptor, paramSet)
, node(effect)
@@ -939,7 +962,7 @@ public:
{
node = new_node;
}
OfxStatus get(double& x,double& y,double& z)
OfxStatus get(double &x, double &y, double &z)
{
if (!node) {
if (has_value_) {
@@ -951,9 +974,8 @@ public:
}
return kOfxStatOK;
}
QVector3D vec =
node->GetStandardValue(_descriptor.getName().c_str())
.value<QVector3D>();
QVector3D vec = node->GetStandardValue(_descriptor.getName().c_str())
.value<QVector3D>();
x = static_cast<double>(vec.x());
y = static_cast<double>(vec.y());
z = static_cast<double>(vec.z());
@@ -966,7 +988,7 @@ public:
}
return kOfxStatOK;
}
OfxStatus get(OfxTime time,double& x,double& y,double& z)
OfxStatus get(OfxTime time, double &x, double &y, double &z)
{
if (!node) {
if (has_value_) {
@@ -978,10 +1000,9 @@ public:
}
return kOfxStatOK;
}
QVector3D vec =
node->GetValueAtTime(_descriptor.getName().c_str(),
rational::fromDouble(time))
.value<QVector3D>();
QVector3D vec = node->GetValueAtTime(_descriptor.getName().c_str(),
rational::fromDouble(time))
.value<QVector3D>();
x = static_cast<double>(vec.x());
y = static_cast<double>(vec.y());
z = static_cast<double>(vec.z());
@@ -994,7 +1015,7 @@ public:
}
return kOfxStatOK;
}
OfxStatus set(double x,double y,double z)
OfxStatus set(double x, double y, double z)
{
if (!node) {
value_[0] = x;
@@ -1018,7 +1039,7 @@ public:
SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor));
return kOfxStatOK;
}
OfxStatus set(OfxTime time,double x,double y,double z)
OfxStatus set(OfxTime time, double x, double y, double z)
{
if (!node) {
value_[0] = x;
@@ -1051,13 +1072,15 @@ public:
class Integer3DInstance : public OFX::Host::Param::Integer3DInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor& _descriptor;
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor &_descriptor;
bool has_value_ = false;
int value_[3] = {0, 0, 0};
int value_[3] = { 0, 0, 0 };
public:
Integer3DInstance(std::shared_ptr<PluginNode> effect, const std::string& name,
OFX::Host::Param::Descriptor& descriptor,
Integer3DInstance(std::shared_ptr<PluginNode> effect,
const std::string &name,
OFX::Host::Param::Descriptor &descriptor,
OFX::Host::Param::SetInstance *paramSet = nullptr)
: OFX::Host::Param::Integer3DInstance(descriptor, paramSet)
, node(effect)
@@ -1069,7 +1092,7 @@ public:
{
node = new_node;
}
OfxStatus get(int& x,int& y,int& z)
OfxStatus get(int &x, int &y, int &z)
{
if (!node) {
if (has_value_) {
@@ -1081,15 +1104,14 @@ public:
}
return kOfxStatOK;
}
QVector3D vec =
node->GetStandardValue(_descriptor.getName().c_str())
.value<QVector3D>();
QVector3D vec = node->GetStandardValue(_descriptor.getName().c_str())
.value<QVector3D>();
x = static_cast<int>(vec.x());
y = static_cast<int>(vec.y());
z = static_cast<int>(vec.z());
return kOfxStatOK;
}
OfxStatus get(OfxTime time,int& x,int& y,int& z)
OfxStatus get(OfxTime time, int &x, int &y, int &z)
{
if (!node) {
if (has_value_) {
@@ -1101,16 +1123,15 @@ public:
}
return kOfxStatOK;
}
QVector3D vec =
node->GetValueAtTime(_descriptor.getName().c_str(),
rational::fromDouble(time))
.value<QVector3D>();
QVector3D vec = node->GetValueAtTime(_descriptor.getName().c_str(),
rational::fromDouble(time))
.value<QVector3D>();
x = static_cast<int>(vec.x());
y = static_cast<int>(vec.y());
z = static_cast<int>(vec.z());
return kOfxStatOK;
}
OfxStatus set(int x,int y,int z)
OfxStatus set(int x, int y, int z)
{
if (!node) {
value_[0] = x;
@@ -1126,7 +1147,7 @@ public:
SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor));
return kOfxStatOK;
}
OfxStatus set(OfxTime time,int x,int y,int z)
OfxStatus set(OfxTime time, int x, int y, int z)
{
if (!node) {
value_[0] = x;
@@ -1151,13 +1172,14 @@ public:
class StringInstance : public OFX::Host::Param::StringInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor& _descriptor;
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor &_descriptor;
bool has_value_ = false;
std::string value_;
public:
StringInstance(std::shared_ptr<PluginNode> effect, const std::string& name,
OFX::Host::Param::Descriptor& descriptor,
StringInstance(std::shared_ptr<PluginNode> effect, const std::string &name,
OFX::Host::Param::Descriptor &descriptor,
OFX::Host::Param::SetInstance *paramSet = nullptr)
: OFX::Host::Param::StringInstance(descriptor, paramSet)
, node(effect)
@@ -1165,7 +1187,8 @@ public:
{
(void)name;
try {
value_ = _descriptor.getProperties().getStringProperty(kOfxParamPropDefault);
value_ = _descriptor.getProperties().getStringProperty(
kOfxParamPropDefault);
has_value_ = true;
} catch (...) {
value_.clear();
@@ -1182,7 +1205,8 @@ public:
data = has_value_ ? value_ : std::string();
return kOfxStatOK;
}
QVariant variant = node->GetStandardValue(_descriptor.getName().c_str());
QVariant variant =
node->GetStandardValue(_descriptor.getName().c_str());
if (variant.canConvert<QString>()) {
data = variant.toString().toStdString();
return kOfxStatOK;
@@ -1196,9 +1220,8 @@ public:
data = has_value_ ? value_ : std::string();
return kOfxStatOK;
}
QVariant variant =
node->GetValueAtTime(_descriptor.getName().c_str(),
rational::fromDouble(time));
QVariant variant = node->GetValueAtTime(_descriptor.getName().c_str(),
rational::fromDouble(time));
if (variant.canConvert<QString>()) {
data = variant.toString().toStdString();
return kOfxStatOK;
@@ -1229,9 +1252,10 @@ public:
return kOfxStatOK;
}
auto command = new MultiUndoCommand();
Node::SetValueAtTime(
NodeInput(node.get(), _descriptor.getName().c_str()),
rational::fromDouble(time), QString::fromUtf8(data), 0, command, true);
Node::SetValueAtTime(NodeInput(node.get(),
_descriptor.getName().c_str()),
rational::fromDouble(time),
QString::fromUtf8(data), 0, command, true);
SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor));
return kOfxStatOK;
}
@@ -1240,13 +1264,14 @@ public:
class CustomInstance : public OFX::Host::Param::CustomInstance,
public NodeBoundParam {
protected:
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor& _descriptor;
std::shared_ptr<PluginNode> node;
OFX::Host::Param::Descriptor &_descriptor;
bool has_value_ = false;
std::string value_;
public:
CustomInstance(std::shared_ptr<PluginNode> effect, const std::string& name,
OFX::Host::Param::Descriptor& descriptor,
CustomInstance(std::shared_ptr<PluginNode> effect, const std::string &name,
OFX::Host::Param::Descriptor &descriptor,
OFX::Host::Param::SetInstance *paramSet = nullptr)
: OFX::Host::Param::CustomInstance(descriptor, paramSet)
, node(effect)
@@ -1264,7 +1289,8 @@ public:
data = has_value_ ? value_ : std::string();
return kOfxStatOK;
}
QVariant variant = node->GetStandardValue(_descriptor.getName().c_str());
QVariant variant =
node->GetStandardValue(_descriptor.getName().c_str());
if (variant.canConvert<QByteArray>()) {
data = variant.toByteArray().toStdString();
return kOfxStatOK;
@@ -1282,9 +1308,8 @@ public:
data = has_value_ ? value_ : std::string();
return kOfxStatOK;
}
QVariant variant =
node->GetValueAtTime(_descriptor.getName().c_str(),
rational::fromDouble(time));
QVariant variant = node->GetValueAtTime(_descriptor.getName().c_str(),
rational::fromDouble(time));
if (variant.canConvert<QByteArray>()) {
data = variant.toByteArray().toStdString();
return kOfxStatOK;
@@ -1329,8 +1354,8 @@ public:
class GroupInstance : public OFX::Host::Param::GroupInstance {
public:
GroupInstance(OFX::Host::Param::Descriptor& descriptor,
OFX::Host::Param::SetInstance *paramSet = nullptr)
GroupInstance(OFX::Host::Param::Descriptor &descriptor,
OFX::Host::Param::SetInstance *paramSet = nullptr)
: OFX::Host::Param::GroupInstance(descriptor, paramSet)
{
}
@@ -1338,8 +1363,8 @@ public:
class PageInstance : public OFX::Host::Param::PageInstance {
public:
PageInstance(OFX::Host::Param::Descriptor& descriptor,
OFX::Host::Param::SetInstance *paramSet = nullptr)
PageInstance(OFX::Host::Param::Descriptor &descriptor,
OFX::Host::Param::SetInstance *paramSet = nullptr)
: OFX::Host::Param::PageInstance(descriptor, paramSet)
{
}
@@ -1347,6 +1372,4 @@ public:
}
}
#endif // HOST_DEMO_PARAM_INSTANCE_H