You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Added new CacheDisk class, which caches frames to the hard drive, dramatically speeding up preview speeds, at the expense of IO operations. New unittests for caching framework. Fixed a few bugs with Frame constructor, which was causing invalid # width & height. Integrated JSON into the cache framework, to quickly share the state of the cache (including ranges of cached frame numbers). Fixed a bug where some Timeline frames could have no audio samples.
This commit is contained in:
@@ -37,7 +37,7 @@ CacheBase::CacheBase() : max_bytes(0) {
|
||||
};
|
||||
|
||||
// Constructor that sets the max frames to cache
|
||||
CacheBase::CacheBase(int64 max_bytes) : max_bytes(max_bytes) {
|
||||
CacheBase::CacheBase(long long int max_bytes) : max_bytes(max_bytes) {
|
||||
// Init the critical section
|
||||
cacheCriticalSection = new CriticalSection();
|
||||
};
|
||||
@@ -46,7 +46,27 @@ CacheBase::CacheBase(int64 max_bytes) : max_bytes(max_bytes) {
|
||||
void CacheBase::SetMaxBytesFromInfo(long int number_of_frames, int width, int height, int sample_rate, int channels)
|
||||
{
|
||||
// n frames X height X width X 4 colors of chars X audio channels X 4 byte floats
|
||||
int64 bytes = number_of_frames * (height * width * 4 + (sample_rate * channels * 4));
|
||||
long long int bytes = number_of_frames * (height * width * 4 + (sample_rate * channels * 4));
|
||||
SetMaxBytes(bytes);
|
||||
}
|
||||
|
||||
// Generate Json::JsonValue for this object
|
||||
Json::Value CacheBase::JsonValue() {
|
||||
|
||||
// Create root json object
|
||||
Json::Value root;
|
||||
stringstream max_bytes_stream;
|
||||
max_bytes_stream << max_bytes;
|
||||
root["max_bytes"] = max_bytes_stream.str();
|
||||
|
||||
// return JsonValue
|
||||
return root;
|
||||
}
|
||||
|
||||
// Load Json::JsonValue into this object
|
||||
void CacheBase::SetJsonValue(Json::Value root) {
|
||||
|
||||
// Set data from Json (if key is found)
|
||||
if (!root["max_bytes"].isNull())
|
||||
max_bytes = atoll(root["max_bytes"].asString().c_str());
|
||||
}
|
||||
Reference in New Issue
Block a user