Skip to content

Commit

Permalink
ChromaKeyer & DenoiseSharpen: use the new simpler LutManager
Browse files Browse the repository at this point in the history
  • Loading branch information
devernay committed Oct 3, 2016
1 parent 052b95d commit 0f90069
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 34 deletions.
8 changes: 5 additions & 3 deletions ChromaKeyer/ChromaKeyer.cpp
Expand Up @@ -182,6 +182,8 @@ enum SourceAlphaEnum
eSourceAlphaNormal,
};

static OFX::Color::LutManager<Mutex>* gLutManager;


class ChromaKeyerProcessorBase
: public OFX::ImageProcessor
Expand All @@ -192,7 +194,7 @@ class ChromaKeyerProcessorBase
const OFX::Image *_inMaskImg;
const OFX::Image *_outMaskImg;
OfxRGBColourD _keyColor;
const OFX::Color::LutBase* _lut;
const OFX::Color::Lut* _lut;
void (*_to_ypbpr)(float r,
float g,
float b,
Expand Down Expand Up @@ -281,7 +283,7 @@ class ChromaKeyerProcessorBase
case eYPbPrColorspaceCcir601:
case eYPbPrColorspaceRec709:
case eYPbPrColorspaceRec2020:
_lut = OFX::Color::LutManager<Mutex>::Rec709Lut();
_lut = gLutManager->Rec709Lut();
break;
}
}
Expand Down Expand Up @@ -866,7 +868,7 @@ ChromaKeyerPlugin::getClipPreferences(OFX::ClipPreferencesSetter &clipPreference
// note: ChromaKeyer handles correctly inputs with different components: it only uses RGB components from both clips
}

mDeclarePluginFactory(ChromaKeyerPluginFactory, {}, {});
mDeclarePluginFactory(ChromaKeyerPluginFactory, { gLutManager = new OFX::Color::LutManager<Mutex>; }, { delete gLutManager; });
void
ChromaKeyerPluginFactory::describe(OFX::ImageEffectDescriptor &desc)
{
Expand Down
37 changes: 7 additions & 30 deletions DenoiseSharpen/DenoiseSharpen.cpp
Expand Up @@ -394,6 +394,8 @@ static const float noise_b3[] = { 0.8908, 0.2007, 0.0855, 0.0412, 0.02
#define abort_test_loop() abort_test()
#endif

static OFX::Color::LutManager<Mutex>* gLutManager;

template<typename T>
static inline void
unused(const T&) {}
Expand Down Expand Up @@ -679,9 +681,9 @@ class DenoiseSharpenPlugin
public:

/** @brief ctor */
DenoiseSharpenPlugin(OfxImageEffectHandle handle, const OFX::Color::LutBase* lut)
DenoiseSharpenPlugin(OfxImageEffectHandle handle)
: ImageEffect(handle)
, _lut(lut)
, _lut(gLutManager->Rec709Lut()) // TODO: work in different colorspaces
, _dstClip(0)
, _srcClip(0)
, _maskClip(0)
Expand Down Expand Up @@ -908,7 +910,7 @@ class DenoiseSharpenPlugin
}
};

const OFX::Color::LutBase* _lut;
const OFX::Color::Lut* _lut;

// do not need to delete these, the ImageEffect is managing them for us
OFX::Clip *_dstClip;
Expand Down Expand Up @@ -2944,32 +2946,7 @@ class DenoiseSharpenOverlayDescriptor
{
};

class DenoiseSharpenPluginFactory : public OFX::PluginFactoryHelper<DenoiseSharpenPluginFactory>
{
public:

DenoiseSharpenPluginFactory(const std::string& id, unsigned int verMaj, unsigned int verMin)
: OFX::PluginFactoryHelper<DenoiseSharpenPluginFactory>(id, verMaj, verMin)
, _lut(0)
{
}

virtual void load()
{
_lut = OFX::Color::LutManager<Mutex>::Rec709Lut();
}

virtual void unload()
{
OFX::Color::LutManager<Mutex>::releaseLut(_lut->getName());
}

virtual OFX::ImageEffect* createInstance(OfxImageEffectHandle handle, OFX::ContextEnum context);
virtual void describe(OFX::ImageEffectDescriptor &desc);
virtual void describeInContext(OFX::ImageEffectDescriptor &desc, OFX::ContextEnum context);
private:
const OFX::Color::LutBase* _lut;
};
mDeclarePluginFactory(DenoiseSharpenPluginFactory, { gLutManager = new OFX::Color::LutManager<Mutex>; }, { delete gLutManager; });

void
DenoiseSharpenPluginFactory::describe(OFX::ImageEffectDescriptor &desc)
Expand Down Expand Up @@ -3519,7 +3496,7 @@ OFX::ImageEffect*
DenoiseSharpenPluginFactory::createInstance(OfxImageEffectHandle handle,
OFX::ContextEnum /*context*/)
{
return new DenoiseSharpenPlugin(handle, _lut);
return new DenoiseSharpenPlugin(handle);
}

static DenoiseSharpenPluginFactory p(kPluginIdentifier, kPluginVersionMajor, kPluginVersionMinor);
Expand Down
2 changes: 1 addition & 1 deletion SupportExt

0 comments on commit 0f90069

Please sign in to comment.