OpenShot Library | libopenshot  0.1.1
Public Member Functions | List of all members
openshot::Cache Class Reference

This class is a cache manager for Frame objects. More...

#include <Cache.h>

Public Member Functions

void Add (long int frame_number, tr1::shared_ptr< Frame > frame)
 Add a Frame to the cache. More...
 
 Cache ()
 Default constructor, no max bytes. More...
 
 Cache (int64 max_bytes)
 Constructor that sets the max bytes to cache. More...
 
void Clear ()
 Clear the cache of all frames. More...
 
long int Count ()
 Count the frames in the queue. More...
 
void Display ()
 Display a list of cached frame numbers. More...
 
int64 GetBytes ()
 Gets the maximum bytes value. More...
 
tr1::shared_ptr< FrameGetFrame (long int frame_number)
 Get a frame from the cache. More...
 
deque< long int > GetFrameNumbers ()
 Return a deque of all frame numbers in this queue (returns just a copy of the data) More...
 
int64 GetMaxBytes ()
 Gets the maximum bytes value. More...
 
tr1::shared_ptr< FrameGetSmallestFrame ()
 Get the smallest frame number. More...
 
void MoveToFront (long int frame_number)
 Move frame to front of queue (so it lasts longer) More...
 
void Remove (long int frame_number)
 Remove a specific frame. More...
 
void SetMaxBytes (int64 number_of_bytes)
 Set maximum bytes to a different amount. More...
 
void SetMaxBytesFromInfo (long int 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...
 
 ~Cache ()
 

Detailed Description

This class is a 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 55 of file Cache.h.

Constructor & Destructor Documentation

Cache::Cache ( )

Default constructor, no max bytes.

Definition at line 34 of file Cache.cpp.

Cache::Cache ( int64  max_bytes)

Constructor that sets the max bytes to cache.

Parameters
max_bytesThe maximum bytes to allow in the cache. Once exceeded, the cache will purge the oldest frames.

Definition at line 40 of file Cache.cpp.

Cache::~Cache ( )

Definition at line 46 of file Cache.cpp.

Member Function Documentation

void Cache::Add ( long int  frame_number,
tr1::shared_ptr< Frame frame 
)

Add a Frame to the cache.

Parameters
frame_numberThe frame number of the cached frame
frameThe openshot::Frame object needing to be cached.

Definition at line 57 of file Cache.cpp.

void Cache::Clear ( )

Clear the cache of all frames.

Definition at line 202 of file Cache.cpp.

long int Cache::Count ( )

Count the frames in the queue.

Definition at line 212 of file Cache.cpp.

void Cache::Display ( )

Display a list of cached frame numbers.

Definition at line 242 of file Cache.cpp.

int64 Cache::GetBytes ( )

Gets the maximum bytes value.

Definition at line 134 of file Cache.cpp.

tr1::shared_ptr< Frame > Cache::GetFrame ( long int  frame_number)

Get a frame from the cache.

Parameters
frame_numberThe frame number of the cached frame

Definition at line 79 of file Cache.cpp.

deque< long int > Cache::GetFrameNumbers ( )

Return a deque of all frame numbers in this queue (returns just a copy of the data)

Definition at line 95 of file Cache.cpp.

int64 openshot::Cache::GetMaxBytes ( )
inline

Gets the maximum bytes value.

Definition at line 105 of file Cache.h.

tr1::shared_ptr< Frame > Cache::GetSmallestFrame ( )

Get the smallest frame number.

Definition at line 112 of file Cache.cpp.

void Cache::MoveToFront ( long int  frame_number)

Move frame to front of queue (so it lasts longer)

Parameters
frame_numberThe frame number of the cached frame

Definition at line 176 of file Cache.cpp.

void Cache::Remove ( long int  frame_number)

Remove a specific frame.

Parameters
frame_numberThe frame number of the cached frame

Definition at line 154 of file Cache.cpp.

void openshot::Cache::SetMaxBytes ( int64  number_of_bytes)
inline

Set maximum bytes to a different amount.

Parameters
number_of_bytesThe maximum bytes to allow in the cache. Once exceeded, the cache will purge the oldest frames.

Definition at line 120 of file Cache.h.

void Cache::SetMaxBytesFromInfo ( long int  number_of_frames,
int  width,
int  height,
int  sample_rate,
int  channels 
)

Set maximum bytes to a different amount based on a ReaderInfo struct.

Parameters
number_of_framesThe maximum number of frames to hold in cache
widthThe width of the frame's image
heightThe height of the frame's image
sample_rateThe sample rate of the frame's audio data
channelsThe number of audio channels in the frame

Definition at line 256 of file Cache.cpp.


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