You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Removing caching from Clip object. Causes too many issues and does not add any performance (in my tests)
This commit is contained in:
35
src/Clip.cpp
35
src/Clip.cpp
@@ -99,7 +99,7 @@ void Clip::init_settings()
|
||||
has_audio = Keyframe(-1.0);
|
||||
has_video = Keyframe(-1.0);
|
||||
|
||||
// Init reader info struct and cache size
|
||||
// Init reader info struct
|
||||
init_reader_settings();
|
||||
}
|
||||
|
||||
@@ -111,9 +111,6 @@ void Clip::init_reader_settings() {
|
||||
|
||||
// Initialize info struct
|
||||
info = reader->info;
|
||||
|
||||
// Initialize Clip cache
|
||||
cache.SetMaxBytesFromInfo(OPEN_MP_NUM_PROCESSORS * 2, info.width, info.height, info.sample_rate, info.channels);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +159,7 @@ Clip::Clip(ReaderBase* new_reader) : resampler(NULL), reader(new_reader), alloca
|
||||
if (reader) {
|
||||
End(reader->info.duration);
|
||||
reader->ParentClip(this);
|
||||
// Init reader info struct and cache size
|
||||
// Init reader info struct
|
||||
init_reader_settings();
|
||||
}
|
||||
}
|
||||
@@ -222,7 +219,7 @@ Clip::Clip(std::string path) : resampler(NULL), reader(NULL), allocated_reader(N
|
||||
End(reader->info.duration);
|
||||
reader->ParentClip(this);
|
||||
allocated_reader = reader;
|
||||
// Init reader info struct and cache size
|
||||
// Init reader info struct
|
||||
init_reader_settings();
|
||||
}
|
||||
}
|
||||
@@ -252,7 +249,7 @@ void Clip::Reader(ReaderBase* new_reader)
|
||||
// set parent
|
||||
reader->ParentClip(this);
|
||||
|
||||
// Init reader info struct and cache size
|
||||
// Init reader info struct
|
||||
init_reader_settings();
|
||||
}
|
||||
|
||||
@@ -357,16 +354,6 @@ std::shared_ptr<Frame> Clip::GetFrame(std::shared_ptr<openshot::Frame> backgroun
|
||||
// Adjust out of bounds frame number
|
||||
frame_number = adjust_frame_number_minimum(frame_number);
|
||||
|
||||
// Check the cache for this frame
|
||||
std::shared_ptr<Frame> cached_frame = cache.GetFrame(frame_number);
|
||||
if (cached_frame) {
|
||||
// Debug output
|
||||
ZmqLogger::Instance()->AppendDebugMethod("Clip::GetFrame", "returned cached frame", frame_number);
|
||||
|
||||
// Return the cached frame
|
||||
return cached_frame;
|
||||
}
|
||||
|
||||
// Adjust has_video and has_audio overrides
|
||||
int enabled_audio = has_audio.GetInt(frame_number);
|
||||
if (enabled_audio == -1 && reader && reader->info.has_audio)
|
||||
@@ -411,11 +398,6 @@ std::shared_ptr<Frame> Clip::GetFrame(std::shared_ptr<openshot::Frame> backgroun
|
||||
// Apply keyframe / transforms
|
||||
apply_keyframes(original_frame, background_frame->GetImage());
|
||||
|
||||
// Cache frame
|
||||
// TODO: disable clip cache temporarily for testing
|
||||
// with this enabled, black frames appear when seeking to previous frames
|
||||
//cache.Add(original_frame);
|
||||
|
||||
// Return processed 'frame'
|
||||
return original_frame;
|
||||
}
|
||||
@@ -896,9 +878,6 @@ void Clip::SetJsonValue(const Json::Value root) {
|
||||
// Set parent data
|
||||
ClipBase::SetJsonValue(root);
|
||||
|
||||
// Clear cache
|
||||
cache.Clear();
|
||||
|
||||
// Set data from Json (if key is found)
|
||||
if (!root["gravity"].isNull())
|
||||
gravity = (GravityType) root["gravity"].asInt();
|
||||
@@ -1082,18 +1061,12 @@ void Clip::AddEffect(EffectBase* effect)
|
||||
|
||||
// Sort effects
|
||||
sort_effects();
|
||||
|
||||
// Clear cache
|
||||
cache.Clear();
|
||||
}
|
||||
|
||||
// Remove an effect from the clip
|
||||
void Clip::RemoveEffect(EffectBase* effect)
|
||||
{
|
||||
effects.remove(effect);
|
||||
|
||||
// Clear cache
|
||||
cache.Clear();
|
||||
}
|
||||
|
||||
// Apply effects to the source frame (if any)
|
||||
|
||||
@@ -192,8 +192,8 @@ namespace openshot {
|
||||
/// Destructor
|
||||
virtual ~Clip();
|
||||
|
||||
/// Get the cache object used by this clip
|
||||
CacheMemory* GetCache() override { return &cache; };
|
||||
/// Get the cache object (always return NULL for this reader)
|
||||
openshot::CacheMemory* GetCache() override { return NULL; };
|
||||
|
||||
/// Determine if reader is open or closed
|
||||
bool IsOpen() override { return is_open; };
|
||||
|
||||
@@ -1176,12 +1176,6 @@ void Timeline::apply_json_to_effects(Json::Value change, EffectBase* existing_ef
|
||||
|
||||
// Add Effect to Timeline
|
||||
AddEffect(e);
|
||||
|
||||
// Clear cache on parent clip (if any)
|
||||
Clip* parent_clip = (Clip*) e->ParentClip();
|
||||
if (parent_clip && parent_clip->GetCache()) {
|
||||
parent_clip->GetCache()->Clear();
|
||||
}
|
||||
}
|
||||
|
||||
} else if (change_type == "update") {
|
||||
@@ -1194,12 +1188,6 @@ void Timeline::apply_json_to_effects(Json::Value change, EffectBase* existing_ef
|
||||
int64_t old_ending_frame = ((existing_effect->Position() + existing_effect->Duration()) * info.fps.ToDouble()) + 1;
|
||||
final_cache->Remove(old_starting_frame - 8, old_ending_frame + 8);
|
||||
|
||||
// Clear cache on parent clip (if any)
|
||||
Clip* parent_clip = (Clip*) existing_effect->ParentClip();
|
||||
if (parent_clip && parent_clip->GetCache()) {
|
||||
parent_clip->GetCache()->Clear();
|
||||
}
|
||||
|
||||
// Update effect properties from JSON
|
||||
existing_effect->SetJsonValue(change["value"]);
|
||||
}
|
||||
@@ -1214,12 +1202,6 @@ void Timeline::apply_json_to_effects(Json::Value change, EffectBase* existing_ef
|
||||
int64_t old_ending_frame = ((existing_effect->Position() + existing_effect->Duration()) * info.fps.ToDouble()) + 1;
|
||||
final_cache->Remove(old_starting_frame - 8, old_ending_frame + 8);
|
||||
|
||||
// Clear cache on parent clip (if any)
|
||||
Clip* parent_clip = (Clip*) existing_effect->ParentClip();
|
||||
if (parent_clip && parent_clip->GetCache()) {
|
||||
parent_clip->GetCache()->Clear();
|
||||
}
|
||||
|
||||
// Remove effect from timeline
|
||||
RemoveEffect(existing_effect);
|
||||
}
|
||||
@@ -1363,7 +1345,6 @@ void Timeline::ClearAllCache() {
|
||||
for (auto clip : clips)
|
||||
{
|
||||
// Clear cache on clip
|
||||
clip->GetCache()->Clear();
|
||||
clip->Reader()->GetCache()->Clear();
|
||||
|
||||
// Clear nested Reader (if any)
|
||||
|
||||
Reference in New Issue
Block a user