add: some changes to add openfx support
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Olive Community Edition - Non-Linear Video Editor
|
||||
* Copyright (C) 2025 Olive CE Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// Created by mikesolar on 25-10-1.
|
||||
//
|
||||
|
||||
#include "OliveClip.h"
|
||||
|
||||
#include "common/Current.h"
|
||||
const std::string &olive::plugin::OliveClipInstance::getUnmappedBitDepth() const
|
||||
{
|
||||
switch (params_.format()) {
|
||||
case PixelFormat::INVALID:
|
||||
return kOfxBitDepthNone;
|
||||
case PixelFormat::U8:
|
||||
return kOfxBitDepthByte;
|
||||
case PixelFormat::U16:
|
||||
return kOfxBitDepthShort;
|
||||
case PixelFormat::F16:
|
||||
return kOfxBitDepthHalf;
|
||||
case PixelFormat::F32:
|
||||
return kOfxBitDepthFloat;
|
||||
default:
|
||||
return kOfxBitDepthNone;
|
||||
}
|
||||
}
|
||||
const std::string &
|
||||
olive::plugin::OliveClipInstance::getUnmappedComponents() const
|
||||
{
|
||||
switch (params_.channel_count()) {
|
||||
case 1:
|
||||
return kOfxImageComponentAlpha;
|
||||
case 3:
|
||||
return kOfxImageComponentRGB;
|
||||
case 4:
|
||||
return kOfxImageComponentRGBA;
|
||||
default:
|
||||
return kOfxImageComponentNone;
|
||||
}
|
||||
}
|
||||
const std::string &olive::plugin::OliveClipInstance::getPremult() const
|
||||
{
|
||||
if (params_.premultiplied_alpha()) {
|
||||
return kOfxImagePreMultiplied;
|
||||
} else {
|
||||
return kOfxImageUnPreMultiplied;
|
||||
}
|
||||
}
|
||||
double olive::plugin::OliveClipInstance::getAspectRatio() const
|
||||
{
|
||||
return params_
|
||||
.pixel_aspect_ratio()
|
||||
.toDouble();
|
||||
}
|
||||
double olive::plugin::OliveClipInstance::getFrameRate() const
|
||||
{
|
||||
return params_.frame_rate().toDouble();
|
||||
}
|
||||
void olive::plugin::OliveClipInstance::getFrameRange(double &startFrame,
|
||||
double &endFrame) const
|
||||
{
|
||||
startFrame =
|
||||
params_.frame_rate().toDouble() *
|
||||
params_.start_time();
|
||||
endFrame =
|
||||
startFrame +
|
||||
params_.frame_rate().toDouble() *
|
||||
params_.duration();
|
||||
}
|
||||
const std::string &olive::plugin::OliveClipInstance::getFieldOrder() const
|
||||
{
|
||||
switch (params_.interlacing()) {
|
||||
case VideoParams::kInterlaceNone:
|
||||
return kOfxImageFieldNone;
|
||||
case VideoParams::kInterlacedTopFirst:
|
||||
return kOfxImageFieldUpper;
|
||||
case VideoParams::kInterlacedBottomFirst:
|
||||
return kOfxImageFieldLower;
|
||||
}
|
||||
return kOfxImageFieldNone;
|
||||
}
|
||||
bool olive::plugin::OliveClipInstance::getConnected() const
|
||||
{
|
||||
return params_.format() ==
|
||||
PixelFormat::INVALID;
|
||||
}
|
||||
double olive::plugin::OliveClipInstance::getUnmappedFrameRate() const
|
||||
{
|
||||
return getFrameRate();
|
||||
}
|
||||
void olive::plugin::OliveClipInstance::getUnmappedFrameRange(
|
||||
double &startFrame, double &endFrame) const
|
||||
{
|
||||
getFrameRange(startFrame, endFrame);
|
||||
}
|
||||
bool olive::plugin::OliveClipInstance::getContinuousSamples() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
OFX::Host::ImageEffect::Image *
|
||||
olive::plugin::OliveClipInstance::getImage(OfxTime time,
|
||||
const OfxRectD *optionalBounds)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Olive Community Edition - Non-Linear Video Editor
|
||||
* Copyright (C) 2025 Olive CE Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// Created by mikesolar on 25-10-1.
|
||||
//
|
||||
|
||||
#ifndef OLIVECLIP_H
|
||||
#define OLIVECLIP_H
|
||||
#include "ofxhClip.h"
|
||||
#include "render/videoparams.h"
|
||||
namespace olive
|
||||
{
|
||||
namespace plugin
|
||||
{
|
||||
class OliveClipInstance: public OFX::Host::ImageEffect::ClipInstance {
|
||||
public:
|
||||
OliveClipInstance(OFX::Host::ImageEffect::Instance* effectInstance,
|
||||
OFX::Host::ImageEffect::ClipDescriptor& desc,VideoParams params)
|
||||
: ClipInstance(effectInstance, desc)
|
||||
{
|
||||
params_ = params;
|
||||
}
|
||||
const std::string &getUnmappedBitDepth() const override;
|
||||
const std::string &getUnmappedComponents() const override;
|
||||
const std::string &getPremult() const override;
|
||||
double getAspectRatio() const override;
|
||||
double getFrameRate() const override;
|
||||
void getFrameRange(double &startFrame, double &endFrame) const override;
|
||||
const std::string &getFieldOrder() const override;
|
||||
bool getConnected() const override;
|
||||
double getUnmappedFrameRate() 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;
|
||||
OfxRectD getRegionOfDefinition(OfxTime time) const override;
|
||||
const std::string &findSupportedComp(const std::string &s) const override;
|
||||
private:
|
||||
VideoParams params_;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif //OLIVECLIP_H
|
||||
@@ -16,6 +16,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "OliveInstance.h"
|
||||
|
||||
#include "OliveClip.h"
|
||||
#include "ofxCore.h"
|
||||
#include "ofxMessage.h"
|
||||
#include "common/Current.h"
|
||||
@@ -101,18 +103,18 @@ OfxStatus OliveInstance::clearPersistentMessage()
|
||||
}
|
||||
void OliveInstance::getProjectSize(double &xSize, double &ySize) const
|
||||
{
|
||||
xSize = Current::getInstance().currentVideoParams().width();
|
||||
ySize = Current::getInstance().currentVideoParams().height();
|
||||
xSize =params_.width();
|
||||
ySize =params_.height();
|
||||
}
|
||||
void OliveInstance::getProjectOffset(double &xOffset, double &yOffset) const
|
||||
{
|
||||
xOffset = Current::getInstance().currentVideoParams().x();
|
||||
yOffset = Current::getInstance().currentVideoParams().y();
|
||||
xOffset =params_.x();
|
||||
yOffset =params_.y();
|
||||
}
|
||||
void OliveInstance::getProjectExtent(double &xSize, double &ySize) const
|
||||
{
|
||||
xSize = Current::getInstance().currentVideoParams().width();
|
||||
ySize = Current::getInstance().currentVideoParams().height();
|
||||
xSize =params_.width();
|
||||
ySize =params_.height();
|
||||
// TODO: Ensure this project does not support this.
|
||||
}
|
||||
double OliveInstance::getProjectPixelAspectRatio() const
|
||||
@@ -124,7 +126,36 @@ double OliveInstance::getProjectPixelAspectRatio() const
|
||||
}
|
||||
double OliveInstance::getFrameRate() const
|
||||
{
|
||||
return Current::getInstance().currentVideoParams().frame_rate().toDouble();
|
||||
return params_.frame_rate().toDouble();
|
||||
}
|
||||
|
||||
double OliveInstance::getEffectDuration() const
|
||||
{
|
||||
// Return a default duration value
|
||||
return 100.0;
|
||||
}
|
||||
|
||||
double OliveInstance::getFrameRecursive() const
|
||||
{
|
||||
// Return current frame (this would typically be set by the host during rendering)
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
void OliveInstance::getRenderScaleRecursive(double &x, double &y) const
|
||||
{
|
||||
// Return default render scale (1.0, 1.0)
|
||||
x = 1.0;
|
||||
y = 1.0;
|
||||
}
|
||||
|
||||
OFX::Host::ImageEffect::ClipInstance *OliveInstance::newClipInstance(
|
||||
OFX::Host::ImageEffect::Instance *plugin,
|
||||
OFX::Host::ImageEffect::ClipDescriptor *descriptor,
|
||||
int index)
|
||||
{
|
||||
// Create a new clip instance
|
||||
OFX::Host::ImageEffect::ClipInstance* clipInstance = new OliveClipInstance(plugin, *descriptor, params_);
|
||||
return clipInstance;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user