You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Refactoring/renaming Cache to CacheMemory.
This commit is contained in:
@@ -45,7 +45,7 @@ namespace openshot {
|
||||
* 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.
|
||||
*/
|
||||
class Cache : public CacheBase {
|
||||
class CacheMemory : public CacheBase {
|
||||
private:
|
||||
map<long int, tr1::shared_ptr<Frame> > frames; ///< This map holds the frame number and Frame objects
|
||||
deque<long int> frame_numbers; ///< This queue holds a sequential list of cached Frame numbers
|
||||
@@ -56,14 +56,14 @@ namespace openshot {
|
||||
|
||||
public:
|
||||
/// Default constructor, no max bytes
|
||||
Cache();
|
||||
CacheMemory();
|
||||
|
||||
/// @brief Constructor that sets the max bytes to cache
|
||||
/// @param max_bytes The maximum bytes to allow in the cache. Once exceeded, the cache will purge the oldest frames.
|
||||
Cache(int64 max_bytes);
|
||||
CacheMemory(int64 max_bytes);
|
||||
|
||||
// Default destructor
|
||||
~Cache();
|
||||
~CacheMemory();
|
||||
|
||||
/// @brief Add a Frame to the cache
|
||||
/// @param frame The openshot::Frame object needing to be cached.
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <tr1/memory>
|
||||
#include "Json.h"
|
||||
#include "Cache.h"
|
||||
#include "CacheMemory.h"
|
||||
#include "Exceptions.h"
|
||||
|
||||
using namespace std;
|
||||
@@ -144,7 +144,7 @@ namespace openshot
|
||||
void SetChunkSize(int new_size) { chunk_size = new_size; };
|
||||
|
||||
/// Get the cache object used by this reader (always return NULL for this reader)
|
||||
Cache* GetCache() { return NULL; };
|
||||
CacheMemory* GetCache() { return NULL; };
|
||||
|
||||
/// @brief Get an openshot::Frame object for a specific frame number of this reader.
|
||||
/// @returns The requested frame (containing the image and audio)
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <stdio.h>
|
||||
#include <sstream>
|
||||
#include <unistd.h>
|
||||
#include "Cache.h"
|
||||
#include "CacheMemory.h"
|
||||
#include "Exceptions.h"
|
||||
#include "Json.h"
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
#include "DeckLinkAPI.h"
|
||||
#include "../include/Frame.h"
|
||||
#include "../include/Cache.h"
|
||||
#include "CacheMemory.h"
|
||||
#include "../include/OpenMPUtilities.h"
|
||||
|
||||
/// Implementation of the Blackmagic Decklink API (used by the DecklinkReader)
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
|
||||
// Queue of raw video frames
|
||||
deque<IDeckLinkMutableVideoFrame*> raw_video_frames;
|
||||
openshot::Cache final_frames;
|
||||
openshot::CacheMemory final_frames;
|
||||
|
||||
// Convert between YUV and RGB
|
||||
IDeckLinkOutput *deckLinkOutput;
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "DeckLinkAPI.h"
|
||||
#include "../include/Cache.h"
|
||||
#include "CacheMemory.h"
|
||||
#include "../include/Frame.h"
|
||||
#include "../include/OpenMPUtilities.h"
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#include <tr1/memory>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "Cache.h"
|
||||
#include "CacheMemory.h"
|
||||
#include "Exceptions.h"
|
||||
#include "Frame.h"
|
||||
#include "DecklinkInput.h"
|
||||
@@ -100,7 +100,7 @@ namespace openshot
|
||||
void Close();
|
||||
|
||||
/// Get the cache object used by this reader (always returns NULL for this reader)
|
||||
Cache* GetCache() { return NULL; };
|
||||
CacheMemory* GetCache() { return NULL; };
|
||||
|
||||
/// Get an openshot::Frame object for a specific frame number of this reader. Frame number
|
||||
/// is ignored, since it always gets the latest LIVE frame.
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#include <tr1/memory>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "Cache.h"
|
||||
#include "CacheMemory.h"
|
||||
#include "Exceptions.h"
|
||||
#include "Frame.h"
|
||||
#include "DecklinkOutput.h"
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <omp.h>
|
||||
#include <stdio.h>
|
||||
#include <tr1/memory>
|
||||
#include "Cache.h"
|
||||
#include "CacheMemory.h"
|
||||
#include "Exceptions.h"
|
||||
#include "Fraction.h"
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace openshot
|
||||
void Close();
|
||||
|
||||
/// Get the cache object used by this reader (always returns NULL for this reader)
|
||||
Cache* GetCache() { return NULL; };
|
||||
CacheMemory* GetCache() { return NULL; };
|
||||
|
||||
/// Get an openshot::Frame object for a specific frame number of this reader. All numbers
|
||||
/// return the same Frame, since they all share the same image data.
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <tr1/memory>
|
||||
#include "Cache.h"
|
||||
#include "CacheMemory.h"
|
||||
#include "Exceptions.h"
|
||||
#include "OpenMPUtilities.h"
|
||||
|
||||
@@ -110,8 +110,8 @@ namespace openshot
|
||||
int rescaler_position;
|
||||
vector<SwsContext*> image_rescalers;
|
||||
|
||||
Cache working_cache;
|
||||
Cache missing_frames;
|
||||
CacheMemory working_cache;
|
||||
CacheMemory missing_frames;
|
||||
map<AVPacket*, AVPacket*> packets;
|
||||
map<AVPicture*, AVPicture*> frames;
|
||||
map<long int, long int> processing_video_frames;
|
||||
@@ -230,7 +230,7 @@ namespace openshot
|
||||
|
||||
public:
|
||||
/// Final cache object used to hold final frames
|
||||
Cache final_cache;
|
||||
CacheMemory final_cache;
|
||||
|
||||
/// Enable or disable seeking. Seeking can more quickly locate the requested frame, but some
|
||||
/// codecs have trouble seeking, and can introduce artifacts or blank images into the video.
|
||||
@@ -247,7 +247,7 @@ namespace openshot
|
||||
void Close();
|
||||
|
||||
/// Get the cache object used by this reader
|
||||
Cache* GetCache() { return &final_cache; };
|
||||
CacheMemory* GetCache() { return &final_cache; };
|
||||
|
||||
/// Get a shared pointer to a openshot::Frame object for a specific frame number of this reader.
|
||||
///
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "Cache.h"
|
||||
#include "CacheMemory.h"
|
||||
#include "Exceptions.h"
|
||||
#include "OpenMPUtilities.h"
|
||||
#include "ZmqLogger.h"
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <math.h>
|
||||
#include <vector>
|
||||
#include <tr1/memory>
|
||||
#include "../include/Cache.h"
|
||||
#include "CacheMemory.h"
|
||||
#include "../include/ReaderBase.h"
|
||||
#include "../include/Frame.h"
|
||||
#include "../include/Fraction.h"
|
||||
@@ -144,7 +144,7 @@ namespace openshot
|
||||
Fraction target; // The target frame rate
|
||||
PulldownType pulldown; // The pull-down technique
|
||||
ReaderBase *reader; // The source video reader
|
||||
Cache final_cache; // Cache of actual Frame objects
|
||||
CacheMemory final_cache; // Cache of actual Frame objects
|
||||
bool is_dirty; // When this is true, the next call to GetFrame will re-init the mapping
|
||||
AVAudioResampleContext *avr; // Audio resampling context object
|
||||
|
||||
@@ -182,7 +182,7 @@ namespace openshot
|
||||
MappedFrame GetMappedFrame(long int TargetFrameNumber) throw(OutOfBoundsFrame);
|
||||
|
||||
/// Get the cache object used by this reader
|
||||
Cache* GetCache() { return &final_cache; };
|
||||
CacheMemory* GetCache() { return &final_cache; };
|
||||
|
||||
/// @brief This method is required for all derived classes of ReaderBase, and return the
|
||||
/// openshot::Frame object, which contains the image and audio information for that
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include <stdio.h>
|
||||
#include <tr1/memory>
|
||||
#include "Magick++.h"
|
||||
#include "Cache.h"
|
||||
#include "CacheMemory.h"
|
||||
#include "Exceptions.h"
|
||||
|
||||
using namespace std;
|
||||
@@ -81,7 +81,7 @@ namespace openshot
|
||||
void Close();
|
||||
|
||||
/// Get the cache object used by this reader (always returns NULL for this object)
|
||||
Cache* GetCache() { return NULL; };
|
||||
CacheMemory* GetCache() { return NULL; };
|
||||
|
||||
/// Get an openshot::Frame object for a specific frame number of this reader. All numbers
|
||||
/// return the same Frame, since they all share the same image data.
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "Magick++.h"
|
||||
#include "Cache.h"
|
||||
#include "CacheMemory.h"
|
||||
#include "Exceptions.h"
|
||||
#include "OpenMPUtilities.h"
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
#include "AudioBufferSource.h"
|
||||
#include "AudioReaderSource.h"
|
||||
#include "AudioResampler.h"
|
||||
#include "Cache.h"
|
||||
#include "CacheMemory.h"
|
||||
#include "ChunkReader.h"
|
||||
#include "ChunkWriter.h"
|
||||
#include "Clip.h"
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include <QtCore/QString>
|
||||
#include <QtGui/QImage>
|
||||
#include <QtGui/QPainter>
|
||||
#include "Cache.h"
|
||||
#include "CacheMemory.h"
|
||||
#include "Exceptions.h"
|
||||
|
||||
using namespace std;
|
||||
@@ -83,7 +83,7 @@ namespace openshot
|
||||
void Close();
|
||||
|
||||
/// Get the cache object used by this reader (always returns NULL for this object)
|
||||
Cache* GetCache() { return NULL; };
|
||||
CacheMemory* GetCache() { return NULL; };
|
||||
|
||||
/// Get an openshot::Frame object for a specific frame number of this reader. All numbers
|
||||
/// return the same Frame, since they all share the same image data.
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <tr1/memory>
|
||||
#include <stdlib.h>
|
||||
#include <sstream>
|
||||
#include "Cache.h"
|
||||
#include "CacheMemory.h"
|
||||
#include "ChannelLayouts.h"
|
||||
#include "Fraction.h"
|
||||
#include "Frame.h"
|
||||
@@ -117,7 +117,7 @@ namespace openshot
|
||||
void DrawFrameOnScene(string path, long _graphics_scene_address);
|
||||
|
||||
/// Get the cache object used by this reader (note: not all readers use cache)
|
||||
virtual Cache* GetCache() = 0;
|
||||
virtual CacheMemory* GetCache() = 0;
|
||||
|
||||
/// This method is required for all derived classes of ReaderBase, and returns the
|
||||
/// openshot::Frame object, which contains the image and audio information for that
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include <stdio.h>
|
||||
#include <tr1/memory>
|
||||
#include "Magick++.h"
|
||||
#include "Cache.h"
|
||||
#include "CacheMemory.h"
|
||||
#include "Enums.h"
|
||||
#include "Exceptions.h"
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace openshot
|
||||
void Close();
|
||||
|
||||
/// Get the cache object used by this reader (always returns NULL for this object)
|
||||
Cache* GetCache() { return NULL; };
|
||||
CacheMemory* GetCache() { return NULL; };
|
||||
|
||||
/// Get an openshot::Frame object for a specific frame number of this reader. All numbers
|
||||
/// return the same Frame, since they all share the same image data.
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include <tr1/memory>
|
||||
#include <QtGui/QImage>
|
||||
#include <QtGui/QPainter>
|
||||
#include "Cache.h"
|
||||
#include "CacheMemory.h"
|
||||
#include "Color.h"
|
||||
#include "Clip.h"
|
||||
#include "Point.h"
|
||||
@@ -147,7 +147,7 @@ namespace openshot {
|
||||
list<Clip*> closing_clips; ///<List of clips that need to be closed
|
||||
map<Clip*, Clip*> open_clips; ///<List of 'opened' clips on this timeline
|
||||
list<EffectBase*> effects; ///<List of clips on this timeline
|
||||
Cache final_cache; ///<Final cache of timeline frames
|
||||
CacheMemory final_cache; ///<Final cache of timeline frames
|
||||
|
||||
/// Process a new layer of video or audio
|
||||
void add_layer(tr1::shared_ptr<Frame> new_frame, Clip* source_clip, long int clip_frame_number, long int timeline_frame_number, bool is_top_clip);
|
||||
@@ -228,7 +228,7 @@ namespace openshot {
|
||||
list<EffectBase*> Effects() { return effects; };
|
||||
|
||||
/// Get the cache object used by this reader
|
||||
Cache* GetCache() { return &final_cache; };
|
||||
CacheMemory* GetCache() { return &final_cache; };
|
||||
|
||||
/// Get an openshot::Frame object for a specific frame number of this timeline.
|
||||
///
|
||||
|
||||
@@ -188,7 +188,7 @@ SET ( OPENSHOT_SOURCE_FILES
|
||||
AudioReaderSource.cpp
|
||||
AudioResampler.cpp
|
||||
CacheBase.cpp
|
||||
Cache.cpp
|
||||
CacheMemory.cpp
|
||||
ChunkReader.cpp
|
||||
ChunkWriter.cpp
|
||||
Color.cpp
|
||||
|
||||
@@ -25,23 +25,23 @@
|
||||
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../include/Cache.h"
|
||||
#include "../include/CacheMemory.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace openshot;
|
||||
|
||||
// Default constructor, no max bytes
|
||||
Cache::Cache() : CacheBase(0) {
|
||||
CacheMemory::CacheMemory() : CacheBase(0) {
|
||||
|
||||
};
|
||||
|
||||
// Constructor that sets the max bytes to cache
|
||||
Cache::Cache(int64 max_bytes) : CacheBase(max_bytes) {
|
||||
CacheMemory::CacheMemory(int64 max_bytes) : CacheBase(max_bytes) {
|
||||
|
||||
};
|
||||
|
||||
// Default destructor
|
||||
Cache::~Cache()
|
||||
CacheMemory::~CacheMemory()
|
||||
{
|
||||
frames.clear();
|
||||
frame_numbers.clear();
|
||||
@@ -52,7 +52,7 @@ Cache::~Cache()
|
||||
}
|
||||
|
||||
// Add a Frame to the cache
|
||||
void Cache::Add(tr1::shared_ptr<Frame> frame)
|
||||
void CacheMemory::Add(tr1::shared_ptr<Frame> frame)
|
||||
{
|
||||
// Create a scoped lock, to protect the cache from multiple threads
|
||||
const GenericScopedLock<CriticalSection> lock(*cacheCriticalSection);
|
||||
@@ -75,7 +75,7 @@ void Cache::Add(tr1::shared_ptr<Frame> frame)
|
||||
}
|
||||
|
||||
// Get a frame from the cache (or NULL shared_ptr if no frame is found)
|
||||
tr1::shared_ptr<Frame> Cache::GetFrame(long int frame_number)
|
||||
tr1::shared_ptr<Frame> CacheMemory::GetFrame(long int frame_number)
|
||||
{
|
||||
// Create a scoped lock, to protect the cache from multiple threads
|
||||
const GenericScopedLock<CriticalSection> lock(*cacheCriticalSection);
|
||||
@@ -91,7 +91,7 @@ tr1::shared_ptr<Frame> Cache::GetFrame(long int frame_number)
|
||||
}
|
||||
|
||||
// Get the smallest frame number (or NULL shared_ptr if no frame is found)
|
||||
tr1::shared_ptr<Frame> Cache::GetSmallestFrame()
|
||||
tr1::shared_ptr<Frame> CacheMemory::GetSmallestFrame()
|
||||
{
|
||||
// Create a scoped lock, to protect the cache from multiple threads
|
||||
const GenericScopedLock<CriticalSection> lock(*cacheCriticalSection);
|
||||
@@ -113,7 +113,7 @@ tr1::shared_ptr<Frame> Cache::GetSmallestFrame()
|
||||
}
|
||||
|
||||
// Gets the maximum bytes value
|
||||
int64 Cache::GetBytes()
|
||||
int64 CacheMemory::GetBytes()
|
||||
{
|
||||
// Create a scoped lock, to protect the cache from multiple threads
|
||||
const GenericScopedLock<CriticalSection> lock(*cacheCriticalSection);
|
||||
@@ -131,7 +131,7 @@ int64 Cache::GetBytes()
|
||||
}
|
||||
|
||||
// Remove a specific frame
|
||||
void Cache::Remove(long int frame_number)
|
||||
void CacheMemory::Remove(long int frame_number)
|
||||
{
|
||||
// Create a scoped lock, to protect the cache from multiple threads
|
||||
const GenericScopedLock<CriticalSection> lock(*cacheCriticalSection);
|
||||
@@ -153,7 +153,7 @@ void Cache::Remove(long int frame_number)
|
||||
}
|
||||
|
||||
// Move frame to front of queue (so it lasts longer)
|
||||
void Cache::MoveToFront(long int frame_number)
|
||||
void CacheMemory::MoveToFront(long int frame_number)
|
||||
{
|
||||
// Create a scoped lock, to protect the cache from multiple threads
|
||||
const GenericScopedLock<CriticalSection> lock(*cacheCriticalSection);
|
||||
@@ -182,7 +182,7 @@ void Cache::MoveToFront(long int frame_number)
|
||||
}
|
||||
|
||||
// Clear the cache of all frames
|
||||
void Cache::Clear()
|
||||
void CacheMemory::Clear()
|
||||
{
|
||||
// Create a scoped lock, to protect the cache from multiple threads
|
||||
const GenericScopedLock<CriticalSection> lock(*cacheCriticalSection);
|
||||
@@ -192,7 +192,7 @@ void Cache::Clear()
|
||||
}
|
||||
|
||||
// Count the frames in the queue
|
||||
long int Cache::Count()
|
||||
long int CacheMemory::Count()
|
||||
{
|
||||
// Create a scoped lock, to protect the cache from multiple threads
|
||||
const GenericScopedLock<CriticalSection> lock(*cacheCriticalSection);
|
||||
@@ -202,7 +202,7 @@ long int Cache::Count()
|
||||
}
|
||||
|
||||
// Clean up cached frames that exceed the number in our max_bytes variable
|
||||
void Cache::CleanUp()
|
||||
void CacheMemory::CleanUp()
|
||||
{
|
||||
// Create a scoped lock, to protect the cache from multiple threads
|
||||
const GenericScopedLock<CriticalSection> lock(*cacheCriticalSection);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user