Skip to content

Commit

Permalink
add some Resolve features
Browse files Browse the repository at this point in the history
add OFX::Host::Param::StrChoiceInstance
add ImageEffect properties :
- kOfxImageEffectPropCudaStreamSupported
- kOfxImageEffectPropMetalRenderSupported
correct a use after free error in kOfxActionUnload
  • Loading branch information
r2d3 committed Aug 14, 2023
1 parent c763718 commit 11715df
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 7 deletions.
32 changes: 32 additions & 0 deletions HostSupport/include/ofxhParam.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,38 @@ namespace OFX {
virtual void notify(const std::string &name, bool single, int num) OFX_EXCEPTION_SPEC;
};

#ifdef OFX_EXTENSIONS_RESOLVE
class StrChoiceInstance : public Instance, public KeyframeParam {
std::string _returnValue; ///< location to hold temporary return value. Should delegate this to implementation!!!
public:
StrChoiceInstance(Descriptor& descriptor, Param::SetInstance* instance = 0);

// callback which should set option as appropriate
virtual void setOption(int num);

// Deriving implementatation needs to overide these
virtual OfxStatus get(std::string &) = 0;
virtual OfxStatus get(OfxTime time, std::string &) = 0;
virtual OfxStatus set(const char*) = 0;
virtual OfxStatus set(OfxTime time, const char*) = 0;

/// implementation of var args function
virtual OfxStatus getV(va_list arg);

/// implementation of var args function
virtual OfxStatus getV(OfxTime time, va_list arg);

/// implementation of var args function
virtual OfxStatus setV(va_list arg);

/// implementation of var args function
virtual OfxStatus setV(OfxTime time, va_list arg);

/// overridden from Instance
virtual void notify(const std::string &name, bool single, int num) OFX_EXCEPTION_SPEC;
};
#endif

class DoubleInstance : public Instance, public KeyframeParam {
public:
DoubleInstance(Descriptor& descriptor, Param::SetInstance* instance = 0) : Instance(descriptor,instance) {}
Expand Down
4 changes: 4 additions & 0 deletions HostSupport/src/ofxhImageEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ namespace OFX {
#ifdef OFX_EXTENSIONS_RESOLVE
{ kOfxImageEffectPropOpenCLRenderSupported, Property::eString, 1, false, "false"},
{ kOfxImageEffectPropCudaRenderSupported, Property::eString, 1, false, "false" },
{ kOfxImageEffectPropCudaStreamSupported, Property::eString, 1, false, "false" },
{ kOfxImageEffectPropMetalRenderSupported, Property::eString, 1, false, "false" },
#endif
#ifdef OFX_EXTENSIONS_NUKE
{ kFnOfxImageEffectPropMultiPlanar, Property::eInt, 1, false, "0" },
Expand Down Expand Up @@ -4199,6 +4201,8 @@ namespace OFX {
# ifdef OFX_EXTENSIONS_RESOLVE
{ kOfxImageEffectPropOpenCLRenderSupported, Property::eString, 1, false, "false"},
{ kOfxImageEffectPropCudaRenderSupported, Property::eString, 1, false, "false" },
{ kOfxImageEffectPropCudaStreamSupported, Property::eString, 1, false, "false" },
{ kOfxImageEffectPropMetalRenderSupported, Property::eString, 1, false, "false" },
# endif
# ifdef OFX_EXTENSIONS_NUKE
{ kFnOfxImageEffectPropMultiPlanar, Property::eInt, 1, false, "0" },
Expand Down
3 changes: 2 additions & 1 deletion HostSupport/src/ofxhImageEffectAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,11 @@ namespace OFX {
# ifdef OFX_DEBUG_ACTIONS
OfxPlugin *op = _pluginHandle->getOfxPlugin();
std::cout << "OFX: "<<op->pluginIdentifier<<"("<<(void*)op<<")->"<<kOfxActionUnload<<"()"<<std::endl;
std::string pluginIdentifier(op->pluginIdentifier); // save it before it becomes invalid
# endif
stat = (*_pluginHandle)->mainEntry(kOfxActionUnload, 0, 0, 0);
# ifdef OFX_DEBUG_ACTIONS
std::cout << "OFX: "<<op->pluginIdentifier<<"("<<(void*)op<<")->"<<kOfxActionUnload<<"()->"<<StatStr(stat)<<std::endl;
std::cout << "OFX: "<<pluginIdentifier<<"("<<(void*)op<<")->"<<kOfxActionUnload<<"()->"<<StatStr(stat)<<std::endl;
# endif
} CatchAllSetStatus(stat, gImageEffectHost, (*_pluginHandle), kOfxActionUnload);
(void)stat;
Expand Down
89 changes: 83 additions & 6 deletions HostSupport/src/ofxhParam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ namespace OFX {
# endif
return set(time, value);
}

/// overridden from Instance
void ChoiceInstance::notify(const std::string &name, bool single, int num) OFX_EXCEPTION_SPEC
{
Expand All @@ -1010,9 +1010,86 @@ namespace OFX {
}

#ifdef OFX_EXTENSIONS_RESOLVE
#ifdef __GNUC__
#warning "TODO: StrChoiceInstance"
#endif
//
// StrChoiceInstance
//

/// make a parameter, with the given type and name
StrChoiceInstance::StrChoiceInstance(Descriptor& descriptor, Param::SetInstance* instance)
: Instance(descriptor,instance)
{
_properties.addNotifyHook(kOfxParamPropChoiceOption, this);
}

// callback which should set option as appropriate
void StrChoiceInstance::setOption(int /*num*/)
{
}

/// implementation of var args function
OfxStatus StrChoiceInstance::getV(va_list arg)
{
const char **value = va_arg(arg, const char **);

OfxStatus stat = get(_returnValue); // I so don't like this, temp storage should be delegated to the implementation
*value = _returnValue.c_str();
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value;
}
# endif
return stat;
}

/// implementation of var args function
OfxStatus StrChoiceInstance::getV(OfxTime time, va_list arg)
{
if ( OFX::IsNaN(time) ) {
return kOfxStatErrValue;
}
const char **value = va_arg(arg, const char **);

OfxStatus stat = get(time, _returnValue); // I so don't like this, temp storage should be delegated to the implementation
*value = _returnValue.c_str();
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value;
}
# endif
return stat;
}

/// implementation of var args function
OfxStatus StrChoiceInstance::setV(va_list arg)
{
char *value = va_arg(arg, char*);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << value;
# endif
return set(value);
}

/// implementation of var args function
OfxStatus StrChoiceInstance::setV(OfxTime time, va_list arg)
{
if ( OFX::IsNaN(time) ) {
return kOfxStatErrValue;
}
char *value = va_arg(arg, char*);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << value;
# endif
return set(time, value);
}

/// overridden from Instance
void StrChoiceInstance::notify(const std::string &name, bool single, int num) OFX_EXCEPTION_SPEC
{
Instance::notify(name, single, num);
if (name == kOfxParamPropChoiceOption) {
setOption(num);
}
}
#endif

//
Expand Down Expand Up @@ -2364,7 +2441,7 @@ namespace OFX {

va_end(ap);

if (stat == kOfxStatOK) {
if (stat == kOfxStatOK && paramInstance->getParamSetInstance()) {
paramInstance->getParamSetInstance()->paramChangedByPlugin(paramInstance);
}

Expand Down Expand Up @@ -2405,7 +2482,7 @@ namespace OFX {

va_end(ap);

if (stat == kOfxStatOK) {
if (stat == kOfxStatOK && paramInstance->getParamSetInstance()) {
paramInstance->getParamSetInstance()->paramChangedByPlugin(paramInstance);
}

Expand Down
23 changes: 23 additions & 0 deletions include/ofxImageEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -1474,6 +1474,29 @@ using the buffer pointers.
*/
#define kOfxImageEffectPropCudaEnabled "OfxImageEffectPropCudaEnabled"

/** @brief Indicates whether a host or plugin can support Cuda stream
- Type - string X 1
- Property Set - plugin descriptor (read/write), host descriptor (read only)
- Default - "false"
- Valid Values - This must be one of
- "false" - in which case the host or plugin does not support Cuda stream
- "true" - which means a host or plugin can support Cuda stream provided
*/
#define kOfxImageEffectPropCudaStreamSupported "OfxImageEffectPropCudaStreamSupported"

/** @brief The stream of Cuda render
- Type - pointer X 1
- Property Set - plugin descriptor (read only), host descriptor (read/write)
This property contains a pointer to the stream of Cuda render (cudaStream_t).
In order to use it, reinterpret_cast<cudaStream_t>(pointer) is needed.
*/
#define kOfxImageEffectPropCudaStream "OfxImageEffectPropCudaStream"

/** @brief Indicates whether a host or plugin can support Metal render
- Type - string X 1
Expand Down

0 comments on commit 11715df

Please sign in to comment.