OpenShot Library | libopenshot
0.2.4
|
This class is a memory-based cache manager for Frame objects. More...
#include <CacheMemory.h>
Public Member Functions | |
void | Add (std::shared_ptr< openshot::Frame > frame) |
Add a Frame to the cache. More... | |
CacheMemory () | |
Default constructor, no max bytes. More... | |
CacheMemory (int64_t max_bytes) | |
Constructor that sets the max bytes to cache. More... | |
void | Clear () |
Clear the cache of all frames. More... | |
int64_t | Count () |
Count the frames in the queue. More... | |
int64_t | GetBytes () |
Gets the maximum bytes value. More... | |
std::shared_ptr< openshot::Frame > | GetFrame (int64_t frame_number) |
Get a frame from the cache. More... | |
std::shared_ptr< openshot::Frame > | GetSmallestFrame () |
Get the smallest frame number. More... | |
std::string | Json () |
Get and Set JSON methods. More... | |
Json::Value | JsonValue () |
Generate Json::JsonValue for this object. More... | |
void | MoveToFront (int64_t frame_number) |
Move frame to front of queue (so it lasts longer) More... | |
void | Remove (int64_t frame_number) |
Remove a specific frame. More... | |
void | Remove (int64_t start_frame_number, int64_t end_frame_number) |
Remove a range of frames. More... | |
void | SetJson (std::string value) |
Load JSON string into this object. More... | |
void | SetJsonValue (Json::Value root) |
Load Json::JsonValue into this object. More... | |
virtual | ~CacheMemory () |
![]() | |
CacheBase () | |
Default constructor, no max bytes. More... | |
CacheBase (int64_t max_bytes) | |
Constructor that sets the max bytes to cache. More... | |
int64_t | GetMaxBytes () |
Gets the maximum bytes value. More... | |
void | SetMaxBytes (int64_t number_of_bytes) |
Set maximum bytes to a different amount. More... | |
void | SetMaxBytesFromInfo (int64_t number_of_frames, int width, int height, int sample_rate, int channels) |
Set maximum bytes to a different amount based on a ReaderInfo struct. More... | |
virtual | ~CacheBase ()=default |
Additional Inherited Members | |
![]() | |
std::string | cache_type |
This is a friendly type name of the derived cache instance. More... | |
juce::CriticalSection * | cacheCriticalSection |
Section lock for multiple threads. More... | |
int64_t | max_bytes |
This is the max number of bytes to cache (0 = no limit) More... | |
This class is a memory-based cache manager for Frame objects.
It is used by FileReaders (such as FFmpegReader) to cache recently accessed frames. Due to the high cost of decoding streams, once a frame is decoded, converted to RGB, and a Frame object is created, it critical to keep these Frames cached for performance reasons. However, the larger the cache, the more memory is required. You can set the max number of bytes to cache.
Definition at line 51 of file CacheMemory.h.
CacheMemory::CacheMemory | ( | ) |
Default constructor, no max bytes.
Definition at line 37 of file CacheMemory.cpp.
CacheMemory::CacheMemory | ( | int64_t | max_bytes | ) |
Constructor that sets the max bytes to cache.
max_bytes | The maximum bytes to allow in the cache. Once exceeded, the cache will purge the oldest frames. |
Definition at line 45 of file CacheMemory.cpp.
|
virtual |
Definition at line 53 of file CacheMemory.cpp.
|
virtual |
Add a Frame to the cache.
frame | The openshot::Frame object needing to be cached. |
Implements openshot::CacheBase.
Definition at line 133 of file CacheMemory.cpp.
Referenced by openshot::FrameMapper::GetFrame(), openshot::FFmpegReader::GetFrame(), and DeckLinkInputDelegate::VideoInputFrameArrived().
|
virtual |
Clear the cache of all frames.
Implements openshot::CacheBase.
Definition at line 281 of file CacheMemory.cpp.
Referenced by openshot::FrameMapper::ChangeMapping(), openshot::FrameMapper::Close(), openshot::FFmpegReader::GetFrame(), openshot::FrameMapper::Reader(), and SetJsonValue().
|
virtual |
Count the frames in the queue.
Implements openshot::CacheBase.
Definition at line 293 of file CacheMemory.cpp.
Referenced by openshot::FFmpegReader::GetFrame().
|
virtual |
Gets the maximum bytes value.
Implements openshot::CacheBase.
Definition at line 196 of file CacheMemory.cpp.
Referenced by Count().
|
virtual |
Get a frame from the cache.
frame_number | The frame number of the cached frame |
Implements openshot::CacheBase.
Definition at line 158 of file CacheMemory.cpp.
Referenced by DeckLinkInputDelegate::GetFrame(), openshot::FrameMapper::GetFrame(), openshot::FFmpegReader::GetFrame(), and GetSmallestFrame().
|
virtual |
Get the smallest frame number.
Implements openshot::CacheBase.
Definition at line 174 of file CacheMemory.cpp.
Referenced by openshot::FFmpegReader::GetFrame().
|
virtual |
Get and Set JSON methods.
Generate JSON string of this object
Implements openshot::CacheBase.
Definition at line 324 of file CacheMemory.cpp.
|
virtual |
Generate Json::JsonValue for this object.
Implements openshot::CacheBase.
Definition at line 331 of file CacheMemory.cpp.
Referenced by Json().
void CacheMemory::MoveToFront | ( | int64_t | frame_number | ) |
Move frame to front of queue (so it lasts longer)
frame_number | The frame number of the cached frame |
Definition at line 255 of file CacheMemory.cpp.
Referenced by Add().
|
virtual |
Remove a specific frame.
frame_number | The frame number of the cached frame |
Implements openshot::CacheBase.
Definition at line 214 of file CacheMemory.cpp.
Referenced by Count(), DeckLinkInputDelegate::GetFrame(), and openshot::FFmpegReader::GetFrame().
|
virtual |
Remove a range of frames.
start_frame_number | The starting frame number of the cached frame |
end_frame_number | The ending frame number of the cached frame |
Implements openshot::CacheBase.
Definition at line 220 of file CacheMemory.cpp.
|
virtual |
Load JSON string into this object.
Implements openshot::CacheBase.
Definition at line 362 of file CacheMemory.cpp.
|
virtual |
Load Json::JsonValue into this object.
Implements openshot::CacheBase.
Definition at line 390 of file CacheMemory.cpp.
Referenced by SetJson().