OpenShot Library | libopenshot  0.5.0
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
openshot::EffectBase Class Reference

This abstract class is the base class, used by all effects in libopenshot. More...

#include <EffectBase.h>

Inheritance diagram for openshot::EffectBase:
[legend]
Collaboration diagram for openshot::EffectBase:
[legend]

Public Types

enum  MaskLoopMode { MASK_LOOP_PLAY_ONCE = 0, MASK_LOOP_REPEAT = 1, MASK_LOOP_PING_PONG = 2 }
 
enum  MaskTimeMode { MASK_TIME_TIMELINE = 0, MASK_TIME_SOURCE_FPS = 1 }
 

Public Member Functions

Json::Value BasePropertiesJSON (int64_t requested_frame) const
 Generate JSON object of base properties (recommended to be used by all effects) More...
 
int constrain (int color_value)
 Constrain a color value from 0 to 255. More...
 
void DisplayInfo (std::ostream *out=&std::cout)
 Display effect information in the standard output stream (stdout) More...
 
virtual std::string GetVisibleObjects (int64_t frame_number) const
 Get the indexes and IDs of all visible objects in the given frame. More...
 
void InitEffectInfo ()
 
virtual std::string Json () const
 Generate JSON string of this object. More...
 
virtual std::string Json (int64_t requested_frame) const
 
Json::Value JsonInfo () const
 Generate JSON object of meta data / info. More...
 
virtual Json::Value JsonValue () const
 Generate Json::Value for this object. More...
 
ReaderBaseMaskReader ()
 Get the common mask reader. More...
 
const ReaderBaseMaskReader () const
 
void MaskReader (ReaderBase *new_reader)
 Set or replace the common mask reader. More...
 
int Order () const
 Get the order that this effect should be executed. More...
 
void Order (int new_order)
 Set the order that this effect should be executed. More...
 
openshot::ClipBaseParentClip ()
 Parent clip object of this effect (which can be unparented and NULL) More...
 
void ParentClip (openshot::ClipBase *new_clip)
 Set parent clip object of this effect. More...
 
std::string ParentClipId () const
 Return the ID of this effect's parent clip. More...
 
std::shared_ptr< openshot::FrameProcessFrame (std::shared_ptr< openshot::Frame > frame, int64_t frame_number)
 Apply effect processing with common mask support (if enabled). More...
 
virtual void SetJson (const std::string value)
 Load JSON string into this object. More...
 
virtual void SetJson (int64_t requested_frame, const std::string value)
 
virtual void SetJsonValue (const Json::Value root)
 Load Json::Value into this object. More...
 
void SetParentEffect (std::string parentEffect_id)
 Set the parent effect from which this properties will be set to. More...
 
virtual ~EffectBase ()
 
- Public Member Functions inherited from openshot::ClipBase
 ClipBase ()
 Constructor for the base clip. More...
 
virtual void End (float value)
 Set end position (in seconds) of clip (trim end of video) More...
 
virtual std::shared_ptr< openshot::FrameGetFrame (int64_t frame_number)=0
 This method is required for all derived classes of ClipBase, and returns a new openshot::Frame object. All Clip keyframes and effects are resolved into pixels. More...
 
virtual std::shared_ptr< openshot::FrameGetFrame (std::shared_ptr< openshot::Frame > frame, int64_t frame_number)=0
 This method is required for all derived classes of ClipBase, and returns a modified openshot::Frame object. More...
 
void Id (std::string value)
 
void Layer (int value)
 Set layer of clip on timeline (lower number is covered by higher numbers) More...
 
bool operator< (ClipBase &a)
 
bool operator<= (ClipBase &a)
 
bool operator> (ClipBase &a)
 
bool operator>= (ClipBase &a)
 
void Position (float value)
 

Set the Id of this clip object

More...
 
virtual std::string PropertiesJSON (int64_t requested_frame) const =0
 
void Start (float value)
 Set start position (in seconds) of clip (trim start of video) More...
 
virtual ~ClipBase ()=default
 

Public Attributes

EffectInfoStruct info
 Information about the current effect. More...
 
bool mask_invert = false
 Invert grayscale mask values before blending. More...
 
int mask_loop_mode = MASK_LOOP_PLAY_ONCE
 Behavior when mask range reaches the end. More...
 
int mask_time_mode = MASK_TIME_SOURCE_FPS
 How effect frames map to mask source frames. More...
 
EffectBaseparentEffect
 Parent effect (which properties will set this effect properties) More...
 
std::map< int, std::shared_ptr< openshot::TrackedObjectBase > > trackedObjects
 Map of Tracked Object's by their indices (used by Effects that track objects on clips) More...
 

Protected Member Functions

virtual void ApplyCustomMaskBlend (std::shared_ptr< QImage > original_image, std::shared_ptr< QImage > effected_image, std::shared_ptr< QImage > mask_image, int64_t frame_number) const
 Optional override for effects with custom mask implementation. More...
 
ReaderBaseCreateReaderFromJson (const Json::Value &reader_json) const
 Create a reader instance from reader JSON. More...
 
virtual bool HandlesMaskInternally () const
 Optional override for effects that apply mask processing inside GetFrame(). More...
 
int64_t MapMaskFrameNumber (int64_t frame_number)
 Convert an effect frame number to a mask source frame number. More...
 
double ResolveMaskHostFps ()
 Determine host FPS used to convert timeline frames to mask source FPS. More...
 
std::shared_ptr< QImage > ResolveMaskImage (std::shared_ptr< QImage > target_image, int64_t frame_number)
 Resolve a cached/scaled mask image for the target frame dimensions. More...
 
double ResolveMaskSourceDuration () const
 Determine mask source duration in seconds. More...
 
virtual bool UseCustomMaskBlend (int64_t frame_number) const
 Optional override for effects that need custom mask behavior. More...
 
- Protected Member Functions inherited from openshot::ClipBase
Json::Value add_property_choice_json (std::string name, int value, int selected_value) const
 Generate JSON choice for a property (dropdown properties) More...
 
Json::Value add_property_json (std::string name, float value, std::string type, std::string memo, const Keyframe *keyframe, float min_value, float max_value, bool readonly, int64_t requested_frame) const
 Generate JSON for a property. More...
 

Protected Attributes

openshot::ClipBaseclip
 Pointer to the parent clip instance (if any) More...
 
- Protected Attributes inherited from openshot::ClipBase
float end
 The position in seconds to end playing (used to trim the ending of a clip) More...
 
std::string id
 ID Property for all derived Clip and Effect classes. More...
 
int layer
 The layer this clip is on. Lower clips are covered up by higher clips. More...
 
float position
 The position on the timeline where this clip should start playing. More...
 
std::string previous_properties
 This string contains the previous JSON properties. More...
 
float start
 The position in seconds to start playing (used to trim the beginning of a clip) More...
 
openshot::TimelineBasetimeline
 Pointer to the parent timeline instance (if any) More...
 

Detailed Description

This abstract class is the base class, used by all effects in libopenshot.

Effects are types of classes that manipulate the image or audio data of an openshot::Frame object. The only requirements for an 'effect', is to derive from this base class, implement the Apply() method, and call the InitEffectInfo() method.

Definition at line 56 of file EffectBase.h.

Member Enumeration Documentation

◆ MaskLoopMode

Enumerator
MASK_LOOP_PLAY_ONCE 
MASK_LOOP_REPEAT 
MASK_LOOP_PING_PONG 

Definition at line 118 of file EffectBase.h.

◆ MaskTimeMode

Enumerator
MASK_TIME_TIMELINE 
MASK_TIME_SOURCE_FPS 

Definition at line 113 of file EffectBase.h.

Constructor & Destructor Documentation

◆ ~EffectBase()

EffectBase::~EffectBase ( )
virtual

Definition at line 593 of file EffectBase.cpp.

Member Function Documentation

◆ ApplyCustomMaskBlend()

virtual void openshot::EffectBase::ApplyCustomMaskBlend ( std::shared_ptr< QImage >  original_image,
std::shared_ptr< QImage >  effected_image,
std::shared_ptr< QImage >  mask_image,
int64_t  frame_number 
) const
inlineprotectedvirtual

Optional override for effects with custom mask implementation.

Reimplemented in openshot::Saturation, openshot::Blur, openshot::Hue, openshot::Brightness, openshot::Pixelate, and openshot::Sharpen.

Definition at line 96 of file EffectBase.h.

Referenced by ProcessFrame().

◆ BasePropertiesJSON()

Json::Value EffectBase::BasePropertiesJSON ( int64_t  requested_frame) const

◆ constrain()

int EffectBase::constrain ( int  color_value)

Constrain a color value from 0 to 255.

Definition at line 77 of file EffectBase.cpp.

Referenced by openshot::Hue::GetFrame(), and openshot::ColorMap::GetFrame().

◆ CreateReaderFromJson()

ReaderBase * EffectBase::CreateReaderFromJson ( const Json::Value &  reader_json) const
protected

Create a reader instance from reader JSON.

Definition at line 277 of file EffectBase.cpp.

Referenced by openshot::Mask::Mask(), openshot::Mask::Reader(), and SetJsonValue().

◆ DisplayInfo()

void EffectBase::DisplayInfo ( std::ostream *  out = &std::cout)

Display effect information in the standard output stream (stdout)

Definition at line 62 of file EffectBase.cpp.

◆ GetVisibleObjects()

virtual std::string openshot::EffectBase::GetVisibleObjects ( int64_t  frame_number) const
inlinevirtual

Get the indexes and IDs of all visible objects in the given frame.

Reimplemented in openshot::ObjectDetection, and openshot::Tracker.

Definition at line 150 of file EffectBase.h.

◆ HandlesMaskInternally()

virtual bool openshot::EffectBase::HandlesMaskInternally ( ) const
inlineprotectedvirtual

Optional override for effects that apply mask processing inside GetFrame().

Reimplemented in openshot::Mask.

Definition at line 100 of file EffectBase.h.

Referenced by ProcessFrame().

◆ InitEffectInfo()

void EffectBase::InitEffectInfo ( )

Initialize the values of the EffectInfo struct. It is important for derived classes to call this method, or the EffectInfo struct values will not be initialized.

Definition at line 37 of file EffectBase.cpp.

Referenced by openshot::Negate::Negate().

◆ Json() [1/2]

std::string EffectBase::Json ( ) const
virtual

◆ Json() [2/2]

virtual std::string openshot::EffectBase::Json ( int64_t  requested_frame) const
inlinevirtual

Definition at line 158 of file EffectBase.h.

◆ JsonInfo()

Json::Value EffectBase::JsonInfo ( ) const

Generate JSON object of meta data / info.

Definition at line 221 of file EffectBase.cpp.

◆ JsonValue()

Json::Value EffectBase::JsonValue ( ) const
virtual

Generate Json::Value for this object.

Implements openshot::ClipBase.

Reimplemented in openshot::AnalogTape, openshot::ObjectDetection, openshot::Caption, openshot::ChromaKey, openshot::Stabilizer, openshot::Saturation, openshot::SphericalProjection, openshot::Blur, openshot::Pixelate, openshot::Crop, openshot::ColorMap, openshot::ColorShift, openshot::Brightness, openshot::Sharpen, openshot::Outline, openshot::Bars, openshot::Hue, openshot::Mask, openshot::Wave, openshot::Expander, openshot::Compressor, openshot::Tracker, openshot::Shift, openshot::Deinterlace, openshot::Robotization, openshot::Echo, openshot::Whisperization, openshot::Delay, openshot::ParametricEQ, openshot::Distortion, openshot::Negate, openshot::Noise, and openshot::LensFlare.

Definition at line 96 of file EffectBase.cpp.

Referenced by Json(), openshot::LensFlare::JsonValue(), openshot::Noise::JsonValue(), openshot::Negate::JsonValue(), openshot::Distortion::JsonValue(), openshot::ParametricEQ::JsonValue(), openshot::Delay::JsonValue(), openshot::Whisperization::JsonValue(), openshot::Echo::JsonValue(), openshot::Robotization::JsonValue(), openshot::Deinterlace::JsonValue(), openshot::Shift::JsonValue(), openshot::Compressor::JsonValue(), openshot::Expander::JsonValue(), openshot::Wave::JsonValue(), openshot::Hue::JsonValue(), openshot::Mask::JsonValue(), openshot::Bars::JsonValue(), openshot::Outline::JsonValue(), openshot::Brightness::JsonValue(), openshot::Sharpen::JsonValue(), openshot::ColorShift::JsonValue(), openshot::ColorMap::JsonValue(), openshot::Crop::JsonValue(), openshot::Pixelate::JsonValue(), openshot::Blur::JsonValue(), openshot::SphericalProjection::JsonValue(), openshot::Saturation::JsonValue(), openshot::ChromaKey::JsonValue(), openshot::Stabilizer::JsonValue(), openshot::Caption::JsonValue(), openshot::ObjectDetection::JsonValue(), openshot::AnalogTape::JsonValue(), SetJsonValue(), and SetParentEffect().

◆ MapMaskFrameNumber()

int64_t EffectBase::MapMaskFrameNumber ( int64_t  frame_number)
protected

Convert an effect frame number to a mask source frame number.

Definition at line 357 of file EffectBase.cpp.

◆ MaskReader() [1/3]

ReaderBase* openshot::EffectBase::MaskReader ( )
inline

Get the common mask reader.

Definition at line 175 of file EffectBase.h.

Referenced by openshot::Mask::Mask(), openshot::Mask::Reader(), SetJsonValue(), and ~EffectBase().

◆ MaskReader() [2/3]

const ReaderBase* openshot::EffectBase::MaskReader ( ) const
inline

Definition at line 176 of file EffectBase.h.

◆ MaskReader() [3/3]

void EffectBase::MaskReader ( ReaderBase new_reader)

Set or replace the common mask reader.

Definition at line 308 of file EffectBase.cpp.

◆ Order() [1/2]

int openshot::EffectBase::Order ( ) const
inline

Get the order that this effect should be executed.

Definition at line 182 of file EffectBase.h.

Referenced by InitEffectInfo(), JsonValue(), openshot::CompareClipEffects::operator()(), openshot::CompareEffects::operator()(), and SetJsonValue().

◆ Order() [2/2]

void openshot::EffectBase::Order ( int  new_order)
inline

Set the order that this effect should be executed.

Definition at line 185 of file EffectBase.h.

◆ ParentClip() [1/2]

openshot::ClipBase * EffectBase::ParentClip ( )

Parent clip object of this effect (which can be unparented and NULL)

Parent clip object of this reader (which can be unparented and NULL)

Definition at line 549 of file EffectBase.cpp.

Referenced by openshot::Clip::AddEffect(), openshot::Caption::GetFrame(), InitEffectInfo(), and openshot::ObjectDetection::LoadObjDetectdData().

◆ ParentClip() [2/2]

void EffectBase::ParentClip ( openshot::ClipBase new_clip)

Set parent clip object of this effect.

Set parent clip object of this reader.

Definition at line 554 of file EffectBase.cpp.

◆ ParentClipId()

std::string EffectBase::ParentClipId ( ) const

Return the ID of this effect's parent clip.

Definition at line 586 of file EffectBase.cpp.

◆ ProcessFrame()

std::shared_ptr< openshot::Frame > EffectBase::ProcessFrame ( std::shared_ptr< openshot::Frame frame,
int64_t  frame_number 
)

Apply effect processing with common mask support (if enabled).

Definition at line 514 of file EffectBase.cpp.

◆ ResolveMaskHostFps()

double EffectBase::ResolveMaskHostFps ( )
protected

Determine host FPS used to convert timeline frames to mask source FPS.

Definition at line 325 of file EffectBase.cpp.

Referenced by MapMaskFrameNumber().

◆ ResolveMaskImage()

std::shared_ptr<QImage> openshot::EffectBase::ResolveMaskImage ( std::shared_ptr< QImage >  target_image,
int64_t  frame_number 
)
inlineprotected

Resolve a cached/scaled mask image for the target frame dimensions.

Definition at line 88 of file EffectBase.h.

Referenced by openshot::Mask::GetFrame().

◆ ResolveMaskSourceDuration()

double EffectBase::ResolveMaskSourceDuration ( ) const
protected

Determine mask source duration in seconds.

Definition at line 342 of file EffectBase.cpp.

Referenced by MapMaskFrameNumber().

◆ SetJson() [1/2]

void EffectBase::SetJson ( const std::string  value)
virtual

◆ SetJson() [2/2]

virtual void openshot::EffectBase::SetJson ( int64_t  requested_frame,
const std::string  value 
)
inlinevirtual

Definition at line 161 of file EffectBase.h.

◆ SetJsonValue()

void EffectBase::SetJsonValue ( const Json::Value  root)
virtual

Load Json::Value into this object.

Implements openshot::ClipBase.

Reimplemented in openshot::SphericalProjection, openshot::AnalogTape, openshot::ObjectDetection, openshot::Caption, openshot::ChromaKey, openshot::Stabilizer, openshot::Saturation, openshot::Blur, openshot::Pixelate, openshot::Crop, openshot::ColorMap, openshot::ColorShift, openshot::Sharpen, openshot::Brightness, openshot::Outline, openshot::Bars, openshot::Hue, openshot::Mask, openshot::Wave, openshot::Expander, openshot::Compressor, openshot::Tracker, openshot::Shift, openshot::Deinterlace, openshot::Robotization, openshot::Echo, openshot::Whisperization, openshot::Delay, openshot::ParametricEQ, openshot::Distortion, openshot::Negate, openshot::Noise, and openshot::LensFlare.

Definition at line 139 of file EffectBase.cpp.

Referenced by SetJson(), openshot::LensFlare::SetJsonValue(), openshot::Noise::SetJsonValue(), openshot::Negate::SetJsonValue(), openshot::Distortion::SetJsonValue(), openshot::ParametricEQ::SetJsonValue(), openshot::Delay::SetJsonValue(), openshot::Whisperization::SetJsonValue(), openshot::Echo::SetJsonValue(), openshot::Robotization::SetJsonValue(), openshot::Deinterlace::SetJsonValue(), openshot::Shift::SetJsonValue(), openshot::Compressor::SetJsonValue(), openshot::Expander::SetJsonValue(), openshot::Wave::SetJsonValue(), openshot::Hue::SetJsonValue(), openshot::Mask::SetJsonValue(), openshot::Bars::SetJsonValue(), openshot::Outline::SetJsonValue(), openshot::Brightness::SetJsonValue(), openshot::Sharpen::SetJsonValue(), openshot::ColorShift::SetJsonValue(), openshot::ColorMap::SetJsonValue(), openshot::Crop::SetJsonValue(), openshot::Pixelate::SetJsonValue(), openshot::Blur::SetJsonValue(), openshot::SphericalProjection::SetJsonValue(), openshot::Saturation::SetJsonValue(), openshot::ChromaKey::SetJsonValue(), openshot::Stabilizer::SetJsonValue(), openshot::Caption::SetJsonValue(), openshot::ObjectDetection::SetJsonValue(), openshot::AnalogTape::SetJsonValue(), openshot::Clip::SetJsonValue(), openshot::Timeline::SetJsonValue(), and SetParentEffect().

◆ SetParentEffect()

void EffectBase::SetParentEffect ( std::string  parentEffect_id)

Set the parent effect from which this properties will be set to.

Definition at line 561 of file EffectBase.cpp.

Referenced by SetJsonValue().

◆ UseCustomMaskBlend()

virtual bool openshot::EffectBase::UseCustomMaskBlend ( int64_t  frame_number) const
inlineprotectedvirtual

Optional override for effects that need custom mask behavior.

Reimplemented in openshot::Saturation, openshot::Blur, openshot::Hue, openshot::Brightness, openshot::Pixelate, and openshot::Sharpen.

Definition at line 93 of file EffectBase.h.

Referenced by ProcessFrame().

Member Data Documentation

◆ clip

openshot::ClipBase* openshot::EffectBase::clip
protected

Pointer to the parent clip instance (if any)

Definition at line 73 of file EffectBase.h.

Referenced by openshot::Caption::GetFrame(), MapMaskFrameNumber(), MaskReader(), ParentClip(), ParentClipId(), and ResolveMaskHostFps().

◆ info

EffectInfoStruct openshot::EffectBase::info

◆ mask_invert

bool openshot::EffectBase::mask_invert = false

◆ mask_loop_mode

int openshot::EffectBase::mask_loop_mode = MASK_LOOP_PLAY_ONCE

Behavior when mask range reaches the end.

Definition at line 125 of file EffectBase.h.

Referenced by BasePropertiesJSON(), InitEffectInfo(), JsonValue(), MapMaskFrameNumber(), and SetJsonValue().

◆ mask_time_mode

int openshot::EffectBase::mask_time_mode = MASK_TIME_SOURCE_FPS

How effect frames map to mask source frames.

Definition at line 124 of file EffectBase.h.

Referenced by BasePropertiesJSON(), InitEffectInfo(), JsonValue(), MapMaskFrameNumber(), and SetJsonValue().

◆ parentEffect

EffectBase* openshot::EffectBase::parentEffect

Parent effect (which properties will set this effect properties)

Definition at line 104 of file EffectBase.h.

Referenced by InitEffectInfo(), SetJsonValue(), and SetParentEffect().

◆ trackedObjects

std::map<int, std::shared_ptr<openshot::TrackedObjectBase> > openshot::EffectBase::trackedObjects

The documentation for this class was generated from the following files: