diff --git a/include/Cache.h b/include/CacheMemory.h similarity index 96% rename from include/Cache.h rename to include/CacheMemory.h index d40b4615..b0753e21 100644 --- a/include/Cache.h +++ b/include/CacheMemory.h @@ -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 > frames; ///< This map holds the frame number and Frame objects deque 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. diff --git a/include/ChunkReader.h b/include/ChunkReader.h index dd612573..8a52f56e 100644 --- a/include/ChunkReader.h +++ b/include/ChunkReader.h @@ -41,7 +41,7 @@ #include #include #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) diff --git a/include/ChunkWriter.h b/include/ChunkWriter.h index cc0d9a38..5246719a 100644 --- a/include/ChunkWriter.h +++ b/include/ChunkWriter.h @@ -41,7 +41,7 @@ #include #include #include -#include "Cache.h" +#include "CacheMemory.h" #include "Exceptions.h" #include "Json.h" diff --git a/include/DecklinkInput.h b/include/DecklinkInput.h index 94221752..8fb5930a 100644 --- a/include/DecklinkInput.h +++ b/include/DecklinkInput.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 raw_video_frames; - openshot::Cache final_frames; + openshot::CacheMemory final_frames; // Convert between YUV and RGB IDeckLinkOutput *deckLinkOutput; diff --git a/include/DecklinkOutput.h b/include/DecklinkOutput.h index 06ef6cf1..6eab8107 100644 --- a/include/DecklinkOutput.h +++ b/include/DecklinkOutput.h @@ -62,7 +62,7 @@ #include #include "DeckLinkAPI.h" -#include "../include/Cache.h" +#include "CacheMemory.h" #include "../include/Frame.h" #include "../include/OpenMPUtilities.h" diff --git a/include/DecklinkReader.h b/include/DecklinkReader.h index ba36cb22..70e41711 100644 --- a/include/DecklinkReader.h +++ b/include/DecklinkReader.h @@ -42,7 +42,7 @@ #include #include -#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. diff --git a/include/DecklinkWriter.h b/include/DecklinkWriter.h index 38ce109e..6094b05f 100644 --- a/include/DecklinkWriter.h +++ b/include/DecklinkWriter.h @@ -42,7 +42,7 @@ #include #include -#include "Cache.h" +#include "CacheMemory.h" #include "Exceptions.h" #include "Frame.h" #include "DecklinkOutput.h" diff --git a/include/DummyReader.h b/include/DummyReader.h index 73783cfd..3ddf7bff 100644 --- a/include/DummyReader.h +++ b/include/DummyReader.h @@ -36,7 +36,7 @@ #include #include #include -#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. diff --git a/include/FFmpegReader.h b/include/FFmpegReader.h index 21d8fed0..79ea7821 100644 --- a/include/FFmpegReader.h +++ b/include/FFmpegReader.h @@ -41,7 +41,7 @@ #include #include #include -#include "Cache.h" +#include "CacheMemory.h" #include "Exceptions.h" #include "OpenMPUtilities.h" @@ -110,8 +110,8 @@ namespace openshot int rescaler_position; vector image_rescalers; - Cache working_cache; - Cache missing_frames; + CacheMemory working_cache; + CacheMemory missing_frames; map packets; map frames; map 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. /// diff --git a/include/FFmpegWriter.h b/include/FFmpegWriter.h index 3c51a8ab..ca5c8dda 100644 --- a/include/FFmpegWriter.h +++ b/include/FFmpegWriter.h @@ -47,7 +47,7 @@ #include #include #include -#include "Cache.h" +#include "CacheMemory.h" #include "Exceptions.h" #include "OpenMPUtilities.h" #include "ZmqLogger.h" diff --git a/include/FrameMapper.h b/include/FrameMapper.h index b00c84f8..ecc20c85 100644 --- a/include/FrameMapper.h +++ b/include/FrameMapper.h @@ -33,7 +33,7 @@ #include #include #include -#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 diff --git a/include/ImageReader.h b/include/ImageReader.h index e51b40ae..8891c339 100644 --- a/include/ImageReader.h +++ b/include/ImageReader.h @@ -37,7 +37,7 @@ #include #include #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. diff --git a/include/ImageWriter.h b/include/ImageWriter.h index 11db493d..c1884712 100644 --- a/include/ImageWriter.h +++ b/include/ImageWriter.h @@ -45,7 +45,7 @@ #include #include #include "Magick++.h" -#include "Cache.h" +#include "CacheMemory.h" #include "Exceptions.h" #include "OpenMPUtilities.h" diff --git a/include/OpenShot.h b/include/OpenShot.h index 6d7d3821..110c3d23 100644 --- a/include/OpenShot.h +++ b/include/OpenShot.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" diff --git a/include/QtImageReader.h b/include/QtImageReader.h index 594ef269..2904f96f 100644 --- a/include/QtImageReader.h +++ b/include/QtImageReader.h @@ -39,7 +39,7 @@ #include #include #include -#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. diff --git a/include/ReaderBase.h b/include/ReaderBase.h index 4ac65854..c9a507b3 100644 --- a/include/ReaderBase.h +++ b/include/ReaderBase.h @@ -33,7 +33,7 @@ #include #include #include -#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 diff --git a/include/TextReader.h b/include/TextReader.h index bb8bdd70..edee2be3 100644 --- a/include/TextReader.h +++ b/include/TextReader.h @@ -37,7 +37,7 @@ #include #include #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. diff --git a/include/Timeline.h b/include/Timeline.h index 433009dd..7759a56b 100644 --- a/include/Timeline.h +++ b/include/Timeline.h @@ -32,7 +32,7 @@ #include #include #include -#include "Cache.h" +#include "CacheMemory.h" #include "Color.h" #include "Clip.h" #include "Point.h" @@ -147,7 +147,7 @@ namespace openshot { list closing_clips; /// open_clips; /// effects; /// 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 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. /// diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 680bc6d3..640ea7de 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -188,7 +188,7 @@ SET ( OPENSHOT_SOURCE_FILES AudioReaderSource.cpp AudioResampler.cpp CacheBase.cpp - Cache.cpp + CacheMemory.cpp ChunkReader.cpp ChunkWriter.cpp Color.cpp diff --git a/src/Cache.cpp b/src/CacheMemory.cpp similarity index 90% rename from src/Cache.cpp rename to src/CacheMemory.cpp index 172681c3..54123819 100644 --- a/src/Cache.cpp +++ b/src/CacheMemory.cpp @@ -25,23 +25,23 @@ * along with OpenShot Library. If not, see . */ -#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) +void CacheMemory::Add(tr1::shared_ptr frame) { // Create a scoped lock, to protect the cache from multiple threads const GenericScopedLock lock(*cacheCriticalSection); @@ -75,7 +75,7 @@ void Cache::Add(tr1::shared_ptr frame) } // Get a frame from the cache (or NULL shared_ptr if no frame is found) -tr1::shared_ptr Cache::GetFrame(long int frame_number) +tr1::shared_ptr CacheMemory::GetFrame(long int frame_number) { // Create a scoped lock, to protect the cache from multiple threads const GenericScopedLock lock(*cacheCriticalSection); @@ -91,7 +91,7 @@ tr1::shared_ptr Cache::GetFrame(long int frame_number) } // Get the smallest frame number (or NULL shared_ptr if no frame is found) -tr1::shared_ptr Cache::GetSmallestFrame() +tr1::shared_ptr CacheMemory::GetSmallestFrame() { // Create a scoped lock, to protect the cache from multiple threads const GenericScopedLock lock(*cacheCriticalSection); @@ -113,7 +113,7 @@ tr1::shared_ptr 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 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 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 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 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 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 lock(*cacheCriticalSection); diff --git a/src/bindings/python/openshot.i b/src/bindings/python/openshot.i index bdbc483a..bdd5b5cd 100644 --- a/src/bindings/python/openshot.i +++ b/src/bindings/python/openshot.i @@ -56,7 +56,7 @@ #include "../../../include/ReaderBase.h" #include "../../../include/WriterBase.h" #include "../../../include/CacheBase.h" -#include "../../../include/Cache.h" +#include "../../../include/CacheMemory.h" #include "../../../include/ChannelLayouts.h" #include "../../../include/ChunkReader.h" #include "../../../include/ChunkWriter.h" @@ -117,7 +117,7 @@ %include "../../../include/ReaderBase.h" %include "../../../include/WriterBase.h" %include "../../../include/CacheBase.h" -%include "../../../include/Cache.h" +%include "../../../include/CacheMemory.h" %include "../../../include/ChannelLayouts.h" %include "../../../include/ChunkReader.h" %include "../../../include/ChunkWriter.h" diff --git a/src/bindings/ruby/openshot.i b/src/bindings/ruby/openshot.i index 8de25546..cc2c8961 100644 --- a/src/bindings/ruby/openshot.i +++ b/src/bindings/ruby/openshot.i @@ -62,7 +62,7 @@ namespace tr1 #include "../../../include/ReaderBase.h" #include "../../../include/WriterBase.h" #include "../../../include/CacheBase.h" -#include "../../../include/Cache.h" +#include "../../../include/CacheMemory.h" #include "../../../include/ChannelLayouts.h" #include "../../../include/ChunkReader.h" #include "../../../include/ChunkWriter.h" @@ -112,7 +112,7 @@ namespace tr1 %include "../../../include/ReaderBase.h" %include "../../../include/WriterBase.h" %include "../../../include/CacheBase.h" -%include "../../../include/Cache.h" +%include "../../../include/CacheMemory.h" %include "../../../include/ChannelLayouts.h" %include "../../../include/ChunkReader.h" %include "../../../include/ChunkWriter.h" diff --git a/tests/Cache_Tests.cpp b/tests/Cache_Tests.cpp index d661f2a3..4c8ab9e6 100644 --- a/tests/Cache_Tests.cpp +++ b/tests/Cache_Tests.cpp @@ -34,7 +34,7 @@ using namespace openshot; TEST(Cache_Default_Constructor) { // Create cache object - Cache c; + CacheMemory c; // Loop 50 times for (int i = 0; i < 50; i++) @@ -52,7 +52,7 @@ TEST(Cache_Default_Constructor) TEST(Cache_Max_Bytes_Constructor) { // Create cache object (with a max of 5 previous items) - Cache c(250 * 1024); + CacheMemory c(250 * 1024); // Loop 20 times for (int i = 30; i > 0; i--) @@ -91,7 +91,7 @@ TEST(Cache_Max_Bytes_Constructor) TEST(Cache_Clear) { // Create cache object - Cache c(250 * 1024); + CacheMemory c(250 * 1024); // Loop 10 times for (int i = 0; i < 10; i++) @@ -115,7 +115,7 @@ TEST(Cache_Clear) TEST(Cache_Add_Duplicate_Frames) { // Create cache object - Cache c(250 * 1024); + CacheMemory c(250 * 1024); // Loop 10 times for (int i = 0; i < 10; i++) @@ -132,7 +132,7 @@ TEST(Cache_Add_Duplicate_Frames) TEST(Cache_Check_If_Frame_Exists) { // Create cache object - Cache c(250 * 1024); + CacheMemory c(250 * 1024); // Loop 5 times for (int i = 1; i < 6; i++) @@ -156,7 +156,7 @@ TEST(Cache_Check_If_Frame_Exists) TEST(Cache_GetFrame) { // Create cache object - Cache c(250 * 1024); + CacheMemory c(250 * 1024); // Create 3 frames Frame *red = new Frame(1, 300, 300, "red"); @@ -181,7 +181,7 @@ TEST(Cache_GetFrame) TEST(Cache_GetSmallest) { // Create cache object (with a max of 10 items) - Cache c(250 * 1024); + CacheMemory c(250 * 1024); // Create 3 frames Frame *red = new Frame(1, 300, 300, "red"); @@ -209,7 +209,7 @@ TEST(Cache_GetSmallest) TEST(Cache_Remove) { // Create cache object (with a max of 10 items) - Cache c(250 * 1024); + CacheMemory c(250 * 1024); // Create 3 frames Frame *red = new Frame(1, 300, 300, "red"); @@ -249,7 +249,7 @@ TEST(Cache_Remove) TEST(Cache_Set_Max_Bytes) { // Create cache object - Cache c; + CacheMemory c; // Loop 20 times for (int i = 0; i < 20; i++) diff --git a/tests/ReaderBase_Tests.cpp b/tests/ReaderBase_Tests.cpp index 1369c07c..ac8f8c76 100644 --- a/tests/ReaderBase_Tests.cpp +++ b/tests/ReaderBase_Tests.cpp @@ -40,7 +40,7 @@ TEST(ReaderBase_Derived_Class) { public: TestReader() { }; - Cache* GetCache() { return NULL; }; + CacheMemory* GetCache() { return NULL; }; tr1::shared_ptr GetFrame(long int number) { tr1::shared_ptr f(new Frame()); return f; } void Close() { }; void Open() { };